From cd1442e216abf564daceaef5fe45555587eef69b Mon Sep 17 00:00:00 2001 From: nico Date: Fri, 9 Nov 2018 19:42:21 +0100 Subject: code quality improvements - remove unused variable * better iteration of xdata nodes - removed unnecessary else --- classes/servercontact.py | 8 ++++---- common/misc.py | 3 +-- common/strings.py | 4 ++-- main.py | 6 ------ 4 files changed, 7 insertions(+), 14 deletions(-) diff --git a/classes/servercontact.py b/classes/servercontact.py index ea7216d..749a2c3 100644 --- a/classes/servercontact.py +++ b/classes/servercontact.py @@ -34,11 +34,11 @@ class ServerContact: # extract jabber:x:data from query xdata = query.findall('{jabber:x:data}x') - # check for multiple x nodes - for x in range(len(xdata)): + # iterate over all nodes with the xdata tag + for node in xdata: - # iterate over all x nodes - for child in xdata[x]: + # iterate over all child elements in node + for child in node: # if one opt_arg is defined return just that one if self.opt_arg in self.possible_vars: diff --git a/common/misc.py b/common/misc.py index e0df882..abcc05e 100755 --- a/common/misc.py +++ b/common/misc.py @@ -46,8 +46,7 @@ def validate(keyword, target): return True # if the target could not be validated until this return False - else: - return False + return False # diff --git a/common/strings.py b/common/strings.py index faac65c..7a10471 100644 --- a/common/strings.py +++ b/common/strings.py @@ -33,9 +33,9 @@ class StaticAnswers: # if specific keyword in referenced return that if key in self.keywords.keys(): return self.keywords[key] + # in any other case return the whole dict - else: - return self.keywords["keywords"] + return self.keywords["keywords"] def gen_help(self): helpdoc = "\n".join(['%s' % value for (_, value) in self.helpfile.items()]) diff --git a/main.py b/main.py index 97a1110..24171cd 100755 --- a/main.py +++ b/main.py @@ -38,12 +38,6 @@ class QueryBot(slixmpp.ClientXMPP): "!xep": XEPRequest() } - self.data = { - 'words': list(), - 'reply': list(), - 'queue': list() - } - # session start event, starting point for the presence and roster requests self.add_event_handler('session_start', self.start) -- cgit v1.2.3-18-g5258