aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHartmut Goebel <h.goebel@crazy-compilers.com>2019-01-19 22:01:18 +0100
committerHartmut Goebel <h.goebel@crazy-compilers.com>2019-01-19 22:01:18 +0100
commit8028efde2262de64a10bb4a39990d8340a54a4aa (patch)
tree50833b8220f3ebf7400d306b4173df85f3e6f539
parent4b41816ab4e8216e91d7e53812d27d9a9c47f5b4 (diff)
downloadgnunet-python-8028efde2262de64a10bb4a39990d8340a54a4aa.tar.gz
gnunet-python-8028efde2262de64a10bb4a39990d8340a54a4aa.zip
Use upper-case names for global constant values.
-rw-r--r--gnunet/block.py2
-rw-r--r--gnunet/dht.py8
-rw-r--r--gnunet/gns.py6
-rw-r--r--gnunet/gnsrecord.py11
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 @@
1types = set([ 1TYPES = set([
2 "any", 2 "any",
3 "fs_dblock", 3 "fs_dblock",
4 "fs_iblock", 4 "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:
70def put(key, desired_replication_level, block_type, data, expiry=None, demultiplex_everywhere=False, record_route=False, bart=False): 70def put(key, desired_replication_level, block_type, data, expiry=None, demultiplex_everywhere=False, record_route=False, bart=False):
71 key = dbusize(HashCode(key), True) 71 key = dbusize(HashCode(key), True)
72 desired_replication_level = dbus.UInt32(desired_replication_level) 72 desired_replication_level = dbus.UInt32(desired_replication_level)
73 if block_type not in block.types: 73 if block_type not in block.TYPES:
74 raise ValueError("'block_type' must be one of %s" % block.types) 74 raise ValueError("'block_type' must be one of %s" % block.TYPES)
75 block_type = dbus.String(block_type, variant_level=1) 75 block_type = dbus.String(block_type, variant_level=1)
76 if expiry is not None: 76 if expiry is not None:
77 if not isinstance(expiry, datetime.datetime): 77 if not isinstance(expiry, datetime.datetime):
@@ -95,8 +95,8 @@ def put(key, desired_replication_level, block_type, data, expiry=None, demultipl
95 95
96 96
97def get_start(callback, block_type, key, desired_replication_level, demultiplex_everywhere=False, record_route=False, bart=False): 97def get_start(callback, block_type, key, desired_replication_level, demultiplex_everywhere=False, record_route=False, bart=False):
98 if block_type not in block.types: 98 if block_type not in block.TYPES:
99 raise ValueError("'block_type' must be one of %s" % block.types) 99 raise ValueError("'block_type' must be one of %s" % block.TYPES)
100 block_type = dbus.String(block_type, variant_level=1) 100 block_type = dbus.String(block_type, variant_level=1)
101 key = dbusize(HashCode(key), True) 101 key = dbusize(HashCode(key), True)
102 desired_replication_level = dbus.UInt32(desired_replication_level) 102 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 *
10def lookup(name, zone, record_type, only_cached): 10def lookup(name, zone, record_type, only_cached):
11 name = str(name) 11 name = str(name)
12 zone = dbusize(crypto.EcdsaPublicKey(zone), True) 12 zone = dbusize(crypto.EcdsaPublicKey(zone), True)
13 if record_type not in gnsrecord.types: 13 if record_type not in gnsrecord.TYPES:
14 raise ValueError("'record_type' must be one of %s" % gnsrecord.types) 14 raise ValueError("'record_type' must be one of %s" % gnsrecord.TYPES)
15 # record_type = dbus.UInt32(gnsrecord.types[record_type], variant_level=1) 15 # record_type = dbus.UInt32(gnsrecord.TYPES[record_type], variant_level=1)
16 record_type = dbus.String(record_type, variant_level=1) 16 record_type = dbus.String(record_type, variant_level=1)
17 only_cached = dbus.Boolean(only_cached) 17 only_cached = dbus.Boolean(only_cached)
18 18
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 @@
1import datetime 1import datetime
2 2
3 3
4dns_types = { 4DNS_TYPES = {
5 "A": 1, 5 "A": 1,
6 "NS": 2, 6 "NS": 2,
7 "CNAME": 5, 7 "CNAME": 5,
@@ -13,7 +13,7 @@ dns_types = {
13 "TLSA": 52} 13 "TLSA": 52}
14 14
15 15
16gns_types = { 16GNS_TYPES = {
17 "PKEY": 65536, 17 "PKEY": 65536,
18 "NICK": 65537, 18 "NICK": 65537,
19 "LEHO": 65538, 19 "LEHO": 65538,
@@ -21,14 +21,15 @@ gns_types = {
21 "GNS2DNS": 65540} 21 "GNS2DNS": 65540}
22 22
23 23
24types = dict(list(dns_types.items()) + list(gns_types.items())) 24TYPES = dict(DNS_TYPES.items())
25TYPES.update(GNS_TYPES.items())
25 26
26 27
27class Data: 28class Data:
28 def __init__(self, record_type, data, expiration_time=None, private=None, pending=None, shadow=None): 29 def __init__(self, record_type, data, expiration_time=None, private=None, pending=None, shadow=None):
29 self.record_type = str(record_type) 30 self.record_type = str(record_type)
30 if record_type not in types: 31 if record_type not in TYPES:
31 raise ValueError("'record_type' must be one of %s" % types) 32 raise ValueError("'record_type' must be one of %s" % TYPES)
32 # self.data = bytearray(data) 33 # self.data = bytearray(data)
33 self.data = str(data) 34 self.data = str(data)
34 if expiration_time is not None and not isinstance(expiration_time, datetime.datetime) or isinstance(expiration_time, datetime.timedelta): 35 if expiration_time is not None and not isinstance(expiration_time, datetime.datetime) or isinstance(expiration_time, datetime.timedelta):