diff options
author | nico <nico@magicbroccoli.de> | 2018-11-07 01:14:45 +0100 |
---|---|---|
committer | nico <nico@magicbroccoli.de> | 2018-11-07 01:14:45 +0100 |
commit | de56a9315cef894a2f3c3a9b39cad4ed10f55491 (patch) | |
tree | 41dbce08f29170a0e62def957b98e5008fb09157 /classes | |
parent | 146a4efc7f9bb97caaa97ddd02f1ce244cb4deb0 (diff) |
small error correction
* +x to main.py
+ added catch for a None response as some xeps have addition tags some do not have
Diffstat (limited to 'classes')
-rw-r--r-- | classes/xep.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/classes/xep.py b/classes/xep.py index a74c30f..fdddb22 100644 --- a/classes/xep.py +++ b/classes/xep.py @@ -75,17 +75,16 @@ class XEPRequest: # if requested number is member of acceptedxeps continue if str(self.reqxep) in self.acceptedxeps: searchstring = ".//*[@accepted='true']/[number='%s']" % self.reqxep + query = None for item in self.xeplist.findall(searchstring): # if the opt_arg references is member of xeptag return only that tag if self.opt_arg in xep_tags: query = item.find(self.opt_arg) - result.append("%s : %s" % (query.tag, query.text)) # if the opt_arg references is member of last-revision_tags return only that tag elif self.opt_arg in last_revision_tags: query = item.find("last-revision").find(self.opt_arg) - result.append("%s : %s" % (query.tag, query.text)) # in any other case return the general answer else: @@ -93,6 +92,12 @@ class XEPRequest: for tag in result_opts: result.append(item.find(tag).text) + # append opt_arg results to the result list + if query is not None: + result.append("%s : %s" % (query.tag, query.text)) + else: + result.append("%s does not have a %s tag." % (self.reqxep, self.opt_arg)) + # if the requested number is no member of acceptedxeps and/or not accepted return error. else: result.append("XEP-%s : is not available." % self.reqxep) |