From 8028efde2262de64a10bb4a39990d8340a54a4aa Mon Sep 17 00:00:00 2001 From: Hartmut Goebel Date: Sat, 19 Jan 2019 22:01:18 +0100 Subject: Use upper-case names for global constant values. --- gnunet/block.py | 2 +- gnunet/dht.py | 8 ++++---- gnunet/gns.py | 6 +++--- gnunet/gnsrecord.py | 11 ++++++----- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/gnunet/block.py b/gnunet/block.py index ec363e0..2c9fbd0 100644 --- a/gnunet/block.py +++ b/gnunet/block.py @@ -1,4 +1,4 @@ -types = set([ +TYPES = set([ "any", "fs_dblock", "fs_iblock", diff --git a/gnunet/dht.py b/gnunet/dht.py index 8e4ae85..b97c7a1 100644 --- a/gnunet/dht.py +++ b/gnunet/dht.py @@ -70,8 +70,8 @@ class GetRequest: def put(key, desired_replication_level, block_type, data, expiry=None, demultiplex_everywhere=False, record_route=False, bart=False): key = dbusize(HashCode(key), True) desired_replication_level = dbus.UInt32(desired_replication_level) - if block_type not in block.types: - raise ValueError("'block_type' must be one of %s" % block.types) + if block_type not in block.TYPES: + raise ValueError("'block_type' must be one of %s" % block.TYPES) block_type = dbus.String(block_type, variant_level=1) if expiry is not None: if not isinstance(expiry, datetime.datetime): @@ -95,8 +95,8 @@ def put(key, desired_replication_level, block_type, data, expiry=None, demultipl def get_start(callback, block_type, key, desired_replication_level, demultiplex_everywhere=False, record_route=False, bart=False): - if block_type not in block.types: - raise ValueError("'block_type' must be one of %s" % block.types) + if block_type not in block.TYPES: + raise ValueError("'block_type' must be one of %s" % block.TYPES) block_type = dbus.String(block_type, variant_level=1) key = dbusize(HashCode(key), True) desired_replication_level = dbus.UInt32(desired_replication_level) diff --git a/gnunet/gns.py b/gnunet/gns.py index f60fe63..5f33566 100644 --- a/gnunet/gns.py +++ b/gnunet/gns.py @@ -10,9 +10,9 @@ from ._dbus_utils import * def lookup(name, zone, record_type, only_cached): name = str(name) zone = dbusize(crypto.EcdsaPublicKey(zone), True) - if record_type not in gnsrecord.types: - raise ValueError("'record_type' must be one of %s" % gnsrecord.types) - # record_type = dbus.UInt32(gnsrecord.types[record_type], variant_level=1) + if record_type not in gnsrecord.TYPES: + raise ValueError("'record_type' must be one of %s" % gnsrecord.TYPES) + # record_type = dbus.UInt32(gnsrecord.TYPES[record_type], variant_level=1) record_type = dbus.String(record_type, variant_level=1) only_cached = dbus.Boolean(only_cached) diff --git a/gnunet/gnsrecord.py b/gnunet/gnsrecord.py index 1cb0d72..e9774c4 100644 --- a/gnunet/gnsrecord.py +++ b/gnunet/gnsrecord.py @@ -1,7 +1,7 @@ import datetime -dns_types = { +DNS_TYPES = { "A": 1, "NS": 2, "CNAME": 5, @@ -13,7 +13,7 @@ dns_types = { "TLSA": 52} -gns_types = { +GNS_TYPES = { "PKEY": 65536, "NICK": 65537, "LEHO": 65538, @@ -21,14 +21,15 @@ gns_types = { "GNS2DNS": 65540} -types = dict(list(dns_types.items()) + list(gns_types.items())) +TYPES = dict(DNS_TYPES.items()) +TYPES.update(GNS_TYPES.items()) class Data: def __init__(self, record_type, data, expiration_time=None, private=None, pending=None, shadow=None): self.record_type = str(record_type) - if record_type not in types: - raise ValueError("'record_type' must be one of %s" % types) + if record_type not in TYPES: + raise ValueError("'record_type' must be one of %s" % TYPES) # self.data = bytearray(data) self.data = str(data) if expiration_time is not None and not isinstance(expiration_time, datetime.datetime) or isinstance(expiration_time, datetime.timedelta): -- cgit v1.2.3