diff options
author | lovetox <philipp@hoerist.com> | 2020-03-11 01:10:01 +0300 |
---|---|---|
committer | lovetox <philipp@hoerist.com> | 2020-03-11 01:20:09 +0300 |
commit | 24e1bf2c910fec7da04534de7a188769dfcf970c (patch) | |
tree | 63b56e25a1a9e641f7fab7ed3fdf751ddcc0cfcc /nbxmpp | |
parent | eabe1064b64438b6d9ea4ba4db44cd1ef76c9d27 (diff) |
Fix pylint errors
- no-else-return
- pointless-string-statement
- multiple-statements
- unused-variable
- wrong-import-position
Diffstat (limited to 'nbxmpp')
-rw-r--r-- | nbxmpp/__init__.py | 3 | ||||
-rw-r--r-- | nbxmpp/c14n.py | 4 | ||||
-rw-r--r-- | nbxmpp/idlequeue.py | 27 | ||||
-rw-r--r-- | nbxmpp/modules/openpgp.py | 19 | ||||
-rw-r--r-- | nbxmpp/protocol.py | 7 | ||||
-rw-r--r-- | nbxmpp/simplexml.py | 9 | ||||
-rw-r--r-- | nbxmpp/stringprepare.py | 3 | ||||
-rw-r--r-- | nbxmpp/third_party/hsluv.py | 12 |
8 files changed, 38 insertions, 46 deletions
diff --git a/nbxmpp/__init__.py b/nbxmpp/__init__.py index d7d8a53..d4a83e7 100644 --- a/nbxmpp/__init__.py +++ b/nbxmpp/__init__.py @@ -1,6 +1,7 @@ import gi -gi.require_version('Soup', '2.4') from .protocol import * +gi.require_version('Soup', '2.4') + __version__ = "0.9.94" diff --git a/nbxmpp/c14n.py b/nbxmpp/c14n.py index 5b93009..ab554b0 100644 --- a/nbxmpp/c14n.py +++ b/nbxmpp/c14n.py @@ -1,4 +1,3 @@ -# -*- coding:utf-8 -*- ## c14n.py ## ## Copyright (C) 2007-2008 Brendan Taylor <whateley AT gmail.com> @@ -43,7 +42,8 @@ def c14n(node, is_buggy): s = s + normalise_text(node.data[cnt]) s = s + c14n(a, is_buggy) cnt += 1 - if (len(node.data)-1) >= cnt: s = s + normalise_text(node.data[cnt]) + if (len(node.data)-1) >= cnt: + s = s + normalise_text(node.data[cnt]) if not node.kids and s.endswith('>'): s=s[:-1]+' />' else: diff --git a/nbxmpp/idlequeue.py b/nbxmpp/idlequeue.py index b6f9b0e..8fe8efd 100644 --- a/nbxmpp/idlequeue.py +++ b/nbxmpp/idlequeue.py @@ -65,13 +65,12 @@ def get_idlequeue(): if os.name == 'nt': # gobject.io_add_watch does not work on windows return SelectIdleQueue() - else: - if HAVE_GLIB: - # Gajim's default Idlequeue - return GlibIdleQueue() - else: - # GUI less implementation - return SelectIdleQueue() + + if HAVE_GLIB: + # Gajim's default Idlequeue + return GlibIdleQueue() + # GUI less implementation + return SelectIdleQueue() class IdleObject: @@ -197,12 +196,12 @@ class IdleCommand(IdleObject): def pollin(self): try: res = self.pipe.read() - except Exception as e: + except Exception: res = '' if res == '': return self.pollend() - else: - self.result += res + + self.result += res return None def read_timeout(self): @@ -275,8 +274,8 @@ class IdleQueue: if not self.alarms[alarm_time]: del self.alarms[alarm_time] return True - else: - return False + + return False def remove_timeout(self, fd, timeout=None): """ @@ -449,8 +448,8 @@ class SelectIdleQueue(IdleQueue): union.update(self.error_fds) for fd in (union.keys()): try: - status = os.stat(fd) - except OSError as e: + _status = os.stat(fd) + except OSError: # This file descriptor is invalid. Add to list for closure. bad_fds.append(fd) diff --git a/nbxmpp/modules/openpgp.py b/nbxmpp/modules/openpgp.py index 0b2978d..40e3d14 100644 --- a/nbxmpp/modules/openpgp.py +++ b/nbxmpp/modules/openpgp.py @@ -81,13 +81,7 @@ class OpenPGP: return def _process_pubsub_openpgp(self, _client, stanza, properties): - if not properties.is_pubsub_event: - return - - if properties.pubsub_event.node != NS_OPENPGP_PK: - return - - ''' + """ <item> <public-keys-list xmlns='urn:xmpp:openpgp:0'> <pubkey-metadata @@ -99,8 +93,15 @@ class OpenPGP: date='1953-05-16T12:00:00Z' /> </public-keys-list> - </item> - ''' + </item> + """ + + if not properties.is_pubsub_event: + return + + if properties.pubsub_event.node != NS_OPENPGP_PK: + return + item = properties.pubsub_event.item if item is None: # Retract, Deleted or Purged diff --git a/nbxmpp/protocol.py b/nbxmpp/protocol.py index 90dc25b..6b0a466 100644 --- a/nbxmpp/protocol.py +++ b/nbxmpp/protocol.py @@ -1238,8 +1238,7 @@ class Protocol(Node): if protocol and tag: if name == 'message': return Message(node=tag) - else: - return Protocol(node=tag) + return Protocol(node=tag) return tag def __setitem__(self, item, val): @@ -1652,9 +1651,7 @@ class Iq(Protocol): class Hashes(Node): """ Hash elements for various XEPs as defined in XEP-300 - """ - """ RECOMENDED HASH USE: Algorithm Support MD2 MUST NOT @@ -1714,9 +1711,7 @@ class Hashes(Node): class Hashes2(Node): """ Hash elements for various XEPs as defined in XEP-300 - """ - """ RECOMENDED HASH USE: Algorithm Support MD2 MUST NOT diff --git a/nbxmpp/simplexml.py b/nbxmpp/simplexml.py index f05d1ca..09890dd 100644 --- a/nbxmpp/simplexml.py +++ b/nbxmpp/simplexml.py @@ -92,7 +92,8 @@ class Node: self.parent = parent self.nsp_cache = {} if nsp: - for k, v in nsp.items(): self.nsp_cache[k] = v + for k, v in nsp.items(): + self.nsp_cache[k] = v if attrs is not None: for attr, val in attrs.items(): @@ -409,8 +410,7 @@ class Node: node = self.getTags(name, attrs, namespace=namespace, one=1) if node: return node - else: - return self.addChild(name, attrs, namespace=namespace) + return self.addChild(name, attrs, namespace=namespace) def setTagAttr(self, tag, attr, val, namespace=None): """ @@ -657,7 +657,8 @@ class NodeBuilder: log.debug("Got higher than dispatch level. Stream terminated?") self._dec_depth() self.last_is_data = 0 - if self.__depth == 0: self.stream_footer_received() + if self.__depth == 0: + self.stream_footer_received() def handle_cdata(self, data): if self.last_is_data: diff --git a/nbxmpp/stringprepare.py b/nbxmpp/stringprepare.py index 99bcc34..2f17655 100644 --- a/nbxmpp/stringprepare.py +++ b/nbxmpp/stringprepare.py @@ -81,8 +81,7 @@ class EmptyMappingTable: def map(self, c): if self._in_table_function(c): return None - else: - return c + return c class Profile: diff --git a/nbxmpp/third_party/hsluv.py b/nbxmpp/third_party/hsluv.py index b6d873b..22b5db4 100644 --- a/nbxmpp/third_party/hsluv.py +++ b/nbxmpp/third_party/hsluv.py @@ -120,15 +120,13 @@ def _dot_product(a, b): def _from_linear(c): if c <= 0.0031308: return 12.92 * c - else: - return 1.055 * math.pow(c, 0.416666666666666685) - 0.055 + return 1.055 * math.pow(c, 0.416666666666666685) - 0.055 def _to_linear(c): if c > 0.04045: return math.pow((c + 0.055) / 1.055, 2.4) - else: - return c / 12.92 + return c / 12.92 def xyz_to_rgb(_hx_tuple): @@ -150,15 +148,13 @@ def rgb_to_xyz(_hx_tuple): def _y_to_l(y): if y <= epsilon: return y / refY * kappa - else: - return 116 * math.pow(y / refY, 0.333333333333333315) - 16 + return 116 * math.pow(y / refY, 0.333333333333333315) - 16 def _l_to_y(l): if l <= 8: return refY * l / kappa - else: - return refY * math.pow((l + 16) / 116, 3) + return refY * math.pow((l + 16) / 116, 3) def xyz_to_luv(_hx_tuple): |