Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dev.gajim.org/gajim/python-nbxmpp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/nbxmpp
diff options
context:
space:
mode:
authorlovetox <philipp@hoerist.com>2020-03-11 00:27:00 +0300
committerlovetox <philipp@hoerist.com>2020-03-11 00:28:02 +0300
commit656aa457c04aafc54dae3d2232960907d328d384 (patch)
treeaf25a122cf01551f07308c6f42b42de6c483a175 /nbxmpp
parent9cd576ebf095652ee8d8f6058fb6fab3836d9a2f (diff)
Fix pylint errors
- inconsistent-return-statements
Diffstat (limited to 'nbxmpp')
-rw-r--r--nbxmpp/idlequeue.py1
-rw-r--r--nbxmpp/modules/activity.py1
-rw-r--r--nbxmpp/modules/bookmarks.py8
-rw-r--r--nbxmpp/modules/dataforms.py1
-rw-r--r--nbxmpp/modules/date_and_time.py8
-rw-r--r--nbxmpp/modules/location.py2
-rw-r--r--nbxmpp/modules/muc.py42
-rw-r--r--nbxmpp/modules/nickname.py2
-rw-r--r--nbxmpp/modules/pubsub.py3
-rw-r--r--nbxmpp/modules/tune.py2
-rw-r--r--nbxmpp/old_dispatcher.py4
-rw-r--r--nbxmpp/plugin.py4
-rw-r--r--nbxmpp/protocol.py26
-rw-r--r--nbxmpp/simplexml.py10
-rw-r--r--nbxmpp/structs.py3
15 files changed, 73 insertions, 44 deletions
diff --git a/nbxmpp/idlequeue.py b/nbxmpp/idlequeue.py
index 5236739..b6f9b0e 100644
--- a/nbxmpp/idlequeue.py
+++ b/nbxmpp/idlequeue.py
@@ -203,6 +203,7 @@ class IdleCommand(IdleObject):
return self.pollend()
else:
self.result += res
+ return None
def read_timeout(self):
self.end()
diff --git a/nbxmpp/modules/activity.py b/nbxmpp/modules/activity.py
index 9e1f0b3..09e5026 100644
--- a/nbxmpp/modules/activity.py
+++ b/nbxmpp/modules/activity.py
@@ -81,6 +81,7 @@ class Activity:
for sub in activity.getChildren():
if sub.getName() in sub_activities:
return sub.getName()
+ return None
def set_activity(self, data):
item = Node('activity', {'xmlns': NS_ACTIVITY})
diff --git a/nbxmpp/modules/bookmarks.py b/nbxmpp/modules/bookmarks.py
index 5b6d8c3..0642566 100644
--- a/nbxmpp/modules/bookmarks.py
+++ b/nbxmpp/modules/bookmarks.py
@@ -168,20 +168,20 @@ class Bookmarks:
jid = item.getAttr('id')
if jid is None:
log.warning('No id attr found')
- return
+ return None
try:
jid = JID(jid)
except Exception as error:
log.warning('Invalid JID: %s', error)
log.warning(item)
- return
+ return None
conference = item.getTag('conference', namespace=NS_BOOKMARKS_2)
if conference is None:
log.warning('No conference node found')
log.warning(item)
- return
+ return None
autojoin = conference.getAttr('autojoin') in ('True', 'true', '1')
name = conference.getAttr('name')
@@ -215,6 +215,7 @@ class Bookmarks:
if type_ == BookmarkStoreType.PRIVATE:
log.info('Request bookmarks (Private Storage)')
return self.get_private_request(), {'type_': type_}
+ return None
@callback
def _bookmarks_received(self, stanza, type_):
@@ -418,3 +419,4 @@ class Bookmarks:
def _on_private_store_result(_client, stanza):
if not isResultNode(stanza):
return raise_error(log.info, stanza)
+ return None
diff --git a/nbxmpp/modules/dataforms.py b/nbxmpp/modules/dataforms.py
index 2e5cbcf..1f4f54d 100644
--- a/nbxmpp/modules/dataforms.py
+++ b/nbxmpp/modules/dataforms.py
@@ -227,6 +227,7 @@ class DataField(ExtendedNode):
media = self.getTag('media', namespace=NS_DATA_MEDIA)
if media:
return Media(media)
+ return None
@media.setter
def media(self, value):
diff --git a/nbxmpp/modules/date_and_time.py b/nbxmpp/modules/date_and_time.py
index 0f49ae6..ed10a79 100644
--- a/nbxmpp/modules/date_and_time.py
+++ b/nbxmpp/modules/date_and_time.py
@@ -108,19 +108,19 @@ def create_tzinfo(hours=0, minutes=0, tz_string=None):
hours, minutes = map(int, tz_string.split(':'))
except Exception:
log.warning('Wrong tz string: %s', tz_string)
- return
+ return None
if hours not in range(-24, 24):
log.warning('Wrong tz string: %s', tz_string)
- return
+ return None
if minutes not in range(0, 59):
log.warning('Wrong tz string: %s', tz_string)
- return
+ return None
if hours in (24, -24) and minutes != 0:
log.warning('Wrong tz string: %s', tz_string)
- return
+ return None
return timezone(timedelta(hours=hours, minutes=minutes))
diff --git a/nbxmpp/modules/location.py b/nbxmpp/modules/location.py
index 88ac35d..872014c 100644
--- a/nbxmpp/modules/location.py
+++ b/nbxmpp/modules/location.py
@@ -66,7 +66,7 @@ class Location:
def set_location(self, data):
item = Node('geoloc', {'xmlns': NS_LOCATION})
if data is None:
- return item
+ return
data = data._asdict()
for tag, value in data:
diff --git a/nbxmpp/modules/muc.py b/nbxmpp/modules/muc.py
index 28c96e1..0792dd4 100644
--- a/nbxmpp/modules/muc.py
+++ b/nbxmpp/modules/muc.py
@@ -531,23 +531,25 @@ class MUC:
@staticmethod
def _parse_muc_user(muc_user):
item = muc_user.getTag('item')
- if item is not None:
- item_dict = item.getAttrs(copy=True)
- if 'role' in item_dict:
- item_dict['role'] = Role(item_dict['role'])
- else:
- item_dict['role'] = None
-
- if 'affiliation' in item_dict:
- item_dict['affiliation'] = Affiliation(item_dict['affiliation'])
- else:
- item_dict['affiliation'] = None
-
- if 'jid' in item_dict:
- item_dict['jid'] = JID(item_dict['jid'])
- else:
- item_dict['jid'] = None
-
- item_dict['actor'] = item.getTagAttr('actor', 'nick')
- item_dict['reason'] = item.getTagData('reason')
- return MucUserData(**item_dict)
+ if item is None:
+ return None
+
+ item_dict = item.getAttrs(copy=True)
+ if 'role' in item_dict:
+ item_dict['role'] = Role(item_dict['role'])
+ else:
+ item_dict['role'] = None
+
+ if 'affiliation' in item_dict:
+ item_dict['affiliation'] = Affiliation(item_dict['affiliation'])
+ else:
+ item_dict['affiliation'] = None
+
+ if 'jid' in item_dict:
+ item_dict['jid'] = JID(item_dict['jid'])
+ else:
+ item_dict['jid'] = None
+
+ item_dict['actor'] = item.getTagAttr('actor', 'nick')
+ item_dict['reason'] = item.getTagData('reason')
+ return MucUserData(**item_dict)
diff --git a/nbxmpp/modules/nickname.py b/nbxmpp/modules/nickname.py
index 1da02cb..c9be9bc 100644
--- a/nbxmpp/modules/nickname.py
+++ b/nbxmpp/modules/nickname.py
@@ -81,7 +81,7 @@ class Nickname:
def _parse_nickname(stanza):
nickname = stanza.getTag('nick', namespace=NS_NICK)
if nickname is None:
- return
+ return None
return nickname.getData() or None
def set_nickname(self, nickname):
diff --git a/nbxmpp/modules/pubsub.py b/nbxmpp/modules/pubsub.py
index 3967568..52754f1 100644
--- a/nbxmpp/modules/pubsub.py
+++ b/nbxmpp/modules/pubsub.py
@@ -214,10 +214,11 @@ def get_pubsub_items(stanza, node=None):
pubsub_node = stanza.getTag('pubsub')
items_node = pubsub_node.getTag('items')
if node is not None and items_node.getAttr('node') != node:
- return
+ return None
if items_node is not None:
return items_node.getTags('item')
+ return None
def get_publish_options(config):
diff --git a/nbxmpp/modules/tune.py b/nbxmpp/modules/tune.py
index 15bc610..c8fde03 100644
--- a/nbxmpp/modules/tune.py
+++ b/nbxmpp/modules/tune.py
@@ -67,7 +67,7 @@ class Tune:
def set_tune(self, data):
item = Node('tune', {'xmlns': NS_TUNE})
if data is None:
- return item
+ return
data = data._asdict()
for tag, value in data.items():
diff --git a/nbxmpp/old_dispatcher.py b/nbxmpp/old_dispatcher.py
index b671d5e..c416524 100644
--- a/nbxmpp/old_dispatcher.py
+++ b/nbxmpp/old_dispatcher.py
@@ -319,7 +319,7 @@ class XMPPDispatcher(PlugIn):
if len(self._pendingExceptions) > 0:
_pendingException = self._pendingExceptions.pop()
sys.excepthook(*_pendingException)
- return
+ return None
try:
self.Stream.Parse(data)
# end stream:stream tag received
@@ -338,7 +338,7 @@ class XMPPDispatcher(PlugIn):
if len(self._pendingExceptions) > 0:
_pendingException = self._pendingExceptions.pop()
sys.excepthook(*_pendingException)
- return
+ return None
if len(data) == 0:
return '0'
return len(data)
diff --git a/nbxmpp/plugin.py b/nbxmpp/plugin.py
index a294945..2e54dbb 100644
--- a/nbxmpp/plugin.py
+++ b/nbxmpp/plugin.py
@@ -45,7 +45,7 @@ class PlugIn:
log.info('Plugging %s __INTO__ %s' % (self, self._owner))
if self.__class__.__name__ in owner.__dict__:
log.debug('Plugging ignored: another instance already plugged.')
- return
+ return None
self._old_owners_methods=[]
for method in self._exported_methods:
if method.__name__ in owner.__dict__:
@@ -61,6 +61,7 @@ class PlugIn:
# Execute hook
if hasattr(self, 'plugin'):
return self.plugin(owner, *args, **kwargs)
+ return None
def PlugOut(self, *args, **kwargs):
"""
@@ -82,6 +83,7 @@ class PlugIn:
if hasattr(self, 'plugout'):
return self.plugout(*args, **kwargs)
del self._owner
+ return None
@classmethod
def get_instance(cls, *args, **kwargs):
diff --git a/nbxmpp/protocol.py b/nbxmpp/protocol.py
index b4e8842..90dc25b 100644
--- a/nbxmpp/protocol.py
+++ b/nbxmpp/protocol.py
@@ -967,6 +967,7 @@ class StreamErrorNode(Node):
for tag in self.getChildren():
if tag.getName() != 'text' and tag.getNamespace() == NS_XMPP_STREAMS:
return tag.getName()
+ return None
def get_text(self, pref_lang=None):
if pref_lang is not None:
@@ -1047,7 +1048,8 @@ class Protocol(Node):
try:
return self['to']
except:
- return None
+ pass
+ return None
def getFrom(self):
"""
@@ -1056,7 +1058,8 @@ class Protocol(Node):
try:
return self['from']
except:
- return None
+ pass
+ return None
def getTimestamp(self):
"""
@@ -1126,26 +1129,29 @@ class Protocol(Node):
"""
errtag = self.getTag('error')
if errtag is None:
- return
+ return None
for tag in errtag.getChildren():
if tag.getName() != 'text' and tag.getNamespace() == NS_STANZAS:
return tag.getName()
+ return None
def getAppError(self):
errtag = self.getTag('error')
if errtag is None:
- return
+ return None
for tag in errtag.getChildren():
if tag.getName() != 'text' and tag.getNamespace() != NS_STANZAS:
return tag.getName()
+ return None
def getAppErrorNamespace(self):
errtag = self.getTag('error')
if errtag is None:
- return
+ return None
for tag in errtag.getChildren():
if tag.getName() != 'text' and tag.getNamespace() != NS_STANZAS:
return tag.getNamespace()
+ return None
def getErrorMsg(self):
"""
@@ -1158,6 +1164,7 @@ class Protocol(Node):
if tag.getName() == 'text':
return tag.getData()
return self.getError()
+ return None
def getErrorCode(self):
"""
@@ -1546,6 +1553,7 @@ class Iq(Protocol):
if children and self.getType() != 'error' and \
children[0].getName() != 'error':
return children[0]
+ return None
def getQueryNS(self):
"""
@@ -1554,6 +1562,7 @@ class Iq(Protocol):
tag = self.getQuery()
if tag:
return tag.getNamespace()
+ return None
def getQuerynode(self):
"""
@@ -1562,6 +1571,7 @@ class Iq(Protocol):
tag = self.getQuery()
if tag:
return tag.getAttr('node')
+ return None
def getQueryPayload(self):
"""
@@ -1570,6 +1580,7 @@ class Iq(Protocol):
tag = self.getQuery()
if tag:
return tag.getPayload()
+ return None
def getQueryChildren(self):
"""
@@ -1578,6 +1589,7 @@ class Iq(Protocol):
tag = self.getQuery()
if tag:
return tag.getChildren()
+ return None
def getQueryChild(self, name=None):
"""
@@ -1586,7 +1598,7 @@ class Iq(Protocol):
"""
query = self.getQuery()
if not query:
- return
+ return None
for node in query.getChildren():
if name is not None:
if node.getName() == name:
@@ -1594,6 +1606,7 @@ class Iq(Protocol):
else:
if node.getName() != 'error':
return node
+ return None
def setQuery(self, name=None):
"""
@@ -1830,6 +1843,7 @@ class Features(Node):
hostname = self.getTag('hostname', namespace=NS_DOMAIN_BASED_NAME)
if hostname is not None:
return hostname.getData()
+ return None
def has_bind(self):
return self.getTag('bind', namespace=NS_BIND) is not None
diff --git a/nbxmpp/simplexml.py b/nbxmpp/simplexml.py
index af0a2ed..f05d1ca 100644
--- a/nbxmpp/simplexml.py
+++ b/nbxmpp/simplexml.py
@@ -337,6 +337,7 @@ class Node:
return nodes[0]
if not one:
return nodes
+ return None
def iterTags(self, name, attrs=None, namespace=None):
"""
@@ -438,6 +439,7 @@ class Node:
if self.parent is not None:
return self.parent.getXmlLang()
+ return None
def has_attr(self, key):
"""
@@ -496,8 +498,8 @@ class T:
def __setattr__(self, attr, val):
if isinstance(val, Node):
Node.__init__(self.node.setTag(attr), node=val)
- else:
- return self.node.setTagData(attr, val)
+ return None
+ return self.node.setTagData(attr, val)
def __delattr__(self, attr):
return self.node.delChild(attr)
@@ -513,8 +515,8 @@ class NT(T):
def __setattr__(self, attr, val):
if isinstance(val, Node):
self.node.addChild(attr, node=val)
- else:
- return self.node.addChild(attr, payload=[val])
+ return None
+ return self.node.addChild(attr, payload=[val])
class NodeBuilder:
diff --git a/nbxmpp/structs.py b/nbxmpp/structs.py
index c35f2e5..c099523 100644
--- a/nbxmpp/structs.py
+++ b/nbxmpp/structs.py
@@ -216,6 +216,7 @@ class DiscoInfo(namedtuple('DiscoInfo', 'stanza identities features dataforms ti
return NS_MAM_2
if NS_MAM_1 in self.features:
return NS_MAM_1
+ return None
@property
def has_mam_2(self):
@@ -251,12 +252,14 @@ class DiscoInfo(namedtuple('DiscoInfo', 'stanza identities features dataforms ti
if self.jid is not None:
return self.jid.getNode()
+ return None
@property
def muc_identity_name(self):
for identity in self.identities:
if identity.category == 'conference':
return identity.name
+ return None
@property
def muc_room_name(self):