gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnunet-python] 12/12: Break some very long lines and some other minor c


From: gnunet
Subject: [gnunet-python] 12/12: Break some very long lines and some other minor code-cleanup.
Date: Sun, 12 Apr 2020 23:22:30 +0200

This is an automated email from the git hooks/post-receive script.

htgoebel pushed a commit to branch master
in repository gnunet-python.

commit a3707a2ef303fe682ccd4faa77d1dd014b0f72ef
Author: Hartmut Goebel <address@hidden>
AuthorDate: Sat Jan 19 22:19:38 2019 +0100

    Break some very long lines and some other minor code-cleanup.
---
 gnunet/_dbus_utils.py | 24 +++++++++++++++---------
 gnunet/dht.py         | 19 +++++++++++++------
 gnunet/gns.py         |  7 +++++--
 gnunet/gnsrecord.py   | 10 +++++++---
 setup.py              |  8 +++++++-
 5 files changed, 47 insertions(+), 21 deletions(-)

diff --git a/gnunet/_dbus_utils.py b/gnunet/_dbus_utils.py
index 2eb317f..26cdadd 100644
--- a/gnunet/_dbus_utils.py
+++ b/gnunet/_dbus_utils.py
@@ -32,7 +32,8 @@ def pythonize(arg, argtype):
         if isinstance(arg, str):
             return strings.string_to_absolute_time(arg)
         if isinstance(arg. dbus.UInt64):
-            return datetime.datetime(1970, 1, 1) + 
datetime.timedelta(microseconds=arg)
+            return (datetime.datetime(1970, 1, 1)
+                    + datetime.timedelta(microseconds=arg))
         return datetime.datetime(arg)
 
 
@@ -48,7 +49,8 @@ def dbusize(arg, pretty):
 
     if isinstance(arg, datetime.datetime):
         if pretty:
-            return dbus.String(strings.absolute_time_to_string(arg), 
variant_level=1)
+            return dbus.String(strings.absolute_time_to_string(arg),
+                               variant_level=1)
         else:
             return dbus.UInt64((arg - datetime.datetime(1970, 1, 
1)).total_seconds() * 1000000, variant_level=1)
 
@@ -60,12 +62,16 @@ def handle_exception(e, daemon, daemon_address):
         raise e
     name = name[len("org.freedesktop.DBus.Error."):]
 
-    if name == "Failed" or name == "InvalidArgs":
+    if name in ("Failed", "InvalidArgs"):
         raise GNUNetDaemonError(message)
-    if name == "NoMemory":
+    elif name == "NoMemory":
         raise MemoryError(message)
-    if name == "ServiceUnknown" or name == "NameHasNoOwner":
-        raise GNUNetDaemonError("Failed to contact " + daemon + " daemon at " 
+ daemon_address)
-    if name == "NoReply" or name == "Timeout":
-        raise GNUNetDaemonError("Did not receive reply from " + daemon + " 
daemon at " + daemon_address + ". Daemon might of crashed")
-    raise e
+    elif name in ("ServiceUnknown", "NameHasNoOwner"):
+        raise GNUNetDaemonError("Failed to contact %s daemon at %s" %
+                                (daemon, daemon_address))
+    elif name in ("NoReply", "Timeout"):
+        raise GNUNetDaemonError("Did not receive reply from %s daemon at %s. "
+                                "Daemon might of crashed."
+                                % (daemon, daemon_address))
+    else:
+        raise e
diff --git a/gnunet/dht.py b/gnunet/dht.py
index b97c7a1..e9aa525 100644
--- a/gnunet/dht.py
+++ b/gnunet/dht.py
@@ -30,9 +30,12 @@ class GetResult(threading.Thread):
 
         if request:
             if request.record_route:
-                request.callback(self.block_type, self.key, self.data, 
self.expiry, get_path=self.get_path, put_path=self.put_path)
+                request.callback(self.block_type, self.key, self.data,
+                                 self.expiry, get_path=self.get_path,
+                                 put_path=self.put_path)
             else:
-                request.callback(self.block_type, self.key, self.data, 
self.expiry)
+                request.callback(self.block_type, self.key, self.data,
+                                 self.expiry)
 
 
 def _result(expiry, key, get_path, put_path, block_type, data, path):
@@ -44,7 +47,8 @@ def _result(expiry, key, get_path, put_path, block_type, 
data, path):
     data = bytearray(data)
     GetResult(expiry, key, get_path, put_path, block_type, data, path)
 
-sysbus.add_signal_receiver(_result, "result", "gnu.gnunet.dht.get", 
"gnu.gnunet.dht", path_keyword="path")
+sysbus.add_signal_receiver(_result, "result", "gnu.gnunet.dht.get",
+                           "gnu.gnunet.dht", path_keyword="path")
 
 
 class GetRequest:
@@ -54,7 +58,8 @@ class GetRequest:
         self.record_route = record_route
 
     def filter_known_results(self, keys):
-        keys = dbus.Array([dbusize(HashCode(key)) for key in list(keys)], 
signature="v")
+        keys = dbus.Array([dbusize(HashCode(key))
+                           for key in list(keys)], signature="v")
         try:
             sysbus.get_object("gnu.gnunet.dht", 
self._path).filter_known_results(keys, dbus_interface="gnu.gnunet.dht.get")
         except dbus.DBusException as e:
@@ -67,7 +72,8 @@ class GetRequest:
             handle_exception(e, "dht", "gnu.gnunet.dht")
 
 
-def put(key, desired_replication_level, block_type, data, expiry=None, 
demultiplex_everywhere=False, record_route=False, bart=False):
+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:
@@ -94,7 +100,8 @@ def put(key, desired_replication_level, block_type, data, 
expiry=None, demultipl
         handle_exception(e, "dht", "gnu.gnunet.dht")
 
 
-def get_start(callback, block_type, key, desired_replication_level, 
demultiplex_everywhere=False, record_route=False, bart=False):
+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)
     block_type = dbus.String(block_type, variant_level=1)
diff --git a/gnunet/gns.py b/gnunet/gns.py
index 5f33566..b46b681 100644
--- a/gnunet/gns.py
+++ b/gnunet/gns.py
@@ -17,7 +17,9 @@ def lookup(name, zone, record_type, only_cached):
     only_cached = dbus.Boolean(only_cached)
 
     try:
-        results = sysbus.get_object("gnu.gnunet.gns", "/").lookup(name, zone, 
record_type, only_cached)
+        results = sysbus.get_object("gnu.gnunet.gns", "/").lookup(name, zone,
+                                                                  record_type,
+                                                                  only_cached)
     except dbus.DBusException as e:
         handle_exception(e, "gns", "gnu.gnunet.gns")
 
@@ -43,6 +45,7 @@ def lookup(name, zone, record_type, only_cached):
             expiration_time = pythonize(r[3], datetime.timedelta)
         else:
             expiration_time = pythonize(r[3], datetime.datetime)
-        ret.append(gnsrecord.Data(record_type, data, expiration_time, private, 
pending, shadow))
+        ret.append(gnsrecord.Data(record_type, data, expiration_time,
+                                  private, pending, shadow))
 
     return ret
diff --git a/gnunet/gnsrecord.py b/gnunet/gnsrecord.py
index e9774c4..d869d05 100644
--- a/gnunet/gnsrecord.py
+++ b/gnunet/gnsrecord.py
@@ -26,14 +26,18 @@ TYPES.update(GNS_TYPES.items())
 
 
 class Data:
-    def __init__(self, record_type, data, expiration_time=None, private=None, 
pending=None, shadow=None):
+    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)
         # 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):
-            raise TypeError("'expiration_time' must be a datetime.datetime or 
a datetime.timedelta")
+        if (expiration_time is not None and
+            not isinstance(expiration_time,
+                           (datetime.datetime, datetime.timedelta))):
+            raise TypeError("'expiration_time' must be a datetime.datetime "
+                            "or a datetime.timedelta")
         self.expiration_time = expiration_time
         self.private = private
         self.pending = pending
diff --git a/setup.py b/setup.py
index 2d7b91e..f0a6dfd 100644
--- a/setup.py
+++ b/setup.py
@@ -20,7 +20,13 @@ setup(
     license="GNU GPLv3+",
     keywords="GNUnet binding p2p",
     url="https://gnunet.org";,
-    long_description="""GNUnet is an alternative network stack for building 
secure, decentralized and privacy-preserving distributed applications. Our goal 
is to replace the old insecure Internet protocol stack. Starting from an 
application for secure publication of files, it has grown to include all kinds 
of basic protocol components and applications towards the creation of a GNU 
internet.
+    long_description="""
+    GNUnet is an alternative network stack for building secure,
+    decentralized and privacy-preserving distributed applications. Our
+    goal is to replace the old insecure Internet protocol stack.
+    Starting from an application for secure publication of files, it
+    has grown to include all kinds of basic protocol components and
+    applications towards the creation of a GNU internet.
 
 GNUnet is an official GNU package.
 

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]