changeset 220e1936c4d2 in /home/hg/repos/python-nbxmpp
details:http://hg.gajim.org/python-nbxmpp?cmd=changeset;node=220e1936c4d2
description: more py3 fixes
diffstat:
nbxmpp/bosh.py | 12 ++++++------
nbxmpp/client_nb.py | 6 +++---
nbxmpp/dispatcher_nb.py | 8 ++++----
nbxmpp/idlequeue.py | 9 ++++-----
nbxmpp/protocol.py | 8 ++++----
nbxmpp/roster_nb.py | 24 ++++++++++++------------
nbxmpp/simplexml.py | 12 ++++++------
nbxmpp/stringprepare.py | 26 +++++++++++++-------------
nbxmpp/transports_nb.py | 2 +-
9 files changed, 53 insertions(+), 54 deletions(-)
diffs (truncated from 385 to 300 lines):
diff -r 5ba63540b68d -r 220e1936c4d2 nbxmpp/bosh.py
--- a/nbxmpp/bosh.py Wed Jan 02 13:51:30 2013 +0100
+++ b/nbxmpp/bosh.py Wed Jan 02 14:15:21 2013 +0100
@@ -321,27 +321,27 @@
self.remove_bosh_wait_timeout()
if self.after_init:
- if stanza_attrs.has_key('sid'):
+ if 'sid' in stanza_attrs:
# session ID should be only in init response
self.bosh_sid = stanza_attrs['sid']
- if stanza_attrs.has_key('requests'):
+ if 'requests' in stanza_attrs:
self.bosh_requests = int(stanza_attrs['requests'])
- if stanza_attrs.has_key('wait'):
+ if 'wait' in stanza_attrs:
self.bosh_wait = int(stanza_attrs['wait'])
self.after_init = False
ack = None
- if stanza_attrs.has_key('ack'):
+ if 'ack' in stanza_attrs:
ack = stanza_attrs['ack']
self.ack_checker.process_incoming_ack(ack=ack,
socket=self.current_recv_socket)
- if stanza_attrs.has_key('type'):
+ if 'type' in stanza_attrs:
if stanza_attrs['type'] in ['terminate', 'terminal']:
condition = 'n/a'
- if stanza_attrs.has_key('condition'):
+ if 'condition' in stanza_attrs:
condition = stanza_attrs['condition']
if condition == 'n/a':
log.info('Received sesion-ending terminating stanza')
diff -r 5ba63540b68d -r 220e1936c4d2 nbxmpp/client_nb.py
--- a/nbxmpp/client_nb.py Wed Jan 02 13:51:30 2013 +0100
+++ b/nbxmpp/client_nb.py Wed Jan 02 14:15:21 2013 +0100
@@ -320,7 +320,7 @@
if not mode:
# starting state
- if self.__dict__.has_key('Dispatcher'):
+ if 'Dispatcher' in self.__dict__:
self.Dispatcher.PlugOut()
self.got_features = False
dispatcher_nb.Dispatcher.get_instance().PlugIn(self)
@@ -564,7 +564,7 @@
"""
Plug in the roster
"""
- if not self.__dict__.has_key('NonBlockingRoster'):
+ if 'NonBlockingRoster' not in self.__dict__:
return roster_nb.NonBlockingRoster.get_instance(version=version).PlugIn(self)
def getRoster(self, on_ready=None, force=False):
@@ -572,7 +572,7 @@
Return the Roster instance, previously plugging it in and requesting
roster from server if needed
"""
- if self.__dict__.has_key('NonBlockingRoster'):
+ if 'NonBlockingRoster' in self.__dict__:
return self.NonBlockingRoster.getRoster(on_ready, force)
return None
diff -r 5ba63540b68d -r 220e1936c4d2 nbxmpp/dispatcher_nb.py
--- a/nbxmpp/dispatcher_nb.py Wed Jan 02 13:51:30 2013 +0100
+++ b/nbxmpp/dispatcher_nb.py Wed Jan 02 14:15:21 2013 +0100
@@ -100,17 +100,17 @@
c = '\ufdd0'
r = c.encode('utf8')
while (c < '\ufdef'):
- c = unichr(ord(c) + 1)
+ c = chr(ord(c) + 1)
r += '|' + c.encode('utf8')
# \ufffe-\uffff, \u1fffe-\u1ffff, ..., \u10fffe-\u10ffff
c = '\ufffe'
r += '|' + c.encode('utf8')
- r += '|' + unichr(ord(c) + 1).encode('utf8')
+ r += '|' + chr(ord(c) + 1).encode('utf8')
while (c < '\U0010fffe'):
- c = unichr(ord(c) + 0x10000)
+ c = chr(ord(c) + 0x10000)
r += '|' + c.encode('utf8')
- r += '|' + unichr(ord(c) + 1).encode('utf8')
+ r += '|' + chr(ord(c) + 1).encode('utf8')
self.invalid_chars_re = re.compile(r)
diff -r 5ba63540b68d -r 220e1936c4d2 nbxmpp/idlequeue.py
--- a/nbxmpp/idlequeue.py Wed Jan 02 13:51:30 2013 +0100
+++ b/nbxmpp/idlequeue.py Wed Jan 02 14:15:21 2013 +0100
@@ -128,8 +128,7 @@
"""
Return one line representation of command and its arguments
"""
- return reduce(lambda left, right: left + ' ' + right,
- self._compose_command_args())
+ return ' '.join(self._compose_command_args())
def wait_child(self):
if self.pipe.poll() is None:
@@ -323,7 +322,7 @@
self.queue[fd].read_timeout()
self.remove_timeout(fd, timeout)
- times = self.alarms.keys()
+ times = list(self.alarms.keys())
for alarm_time in times:
if alarm_time > current_time:
continue
@@ -478,8 +477,8 @@
self._check_time_events()
return True
try:
- waiting_descriptors = select.select(self.read_fds.keys(),
- self.write_fds.keys(), self.error_fds.keys(), 0)
+ waiting_descriptors = select.select(list(self.read_fds.keys()),
+ list(self.write_fds.keys()), list(self.error_fds.keys()), 0)
except select.error as e:
waiting_descriptors = ((), (), ())
if e[0] != 4: # interrupt
diff -r 5ba63540b68d -r 220e1936c4d2 nbxmpp/protocol.py
--- a/nbxmpp/protocol.py Wed Jan 02 13:51:30 2013 +0100
+++ b/nbxmpp/protocol.py Wed Jan 02 14:15:21 2013 +0100
@@ -761,7 +761,7 @@
if self['from']:
self.setFrom(self['from'])
if node and type(self) == type(node) and \
- self.__class__ == node.__class__ and self.attrs.has_key('id'):
+ self.__class__ == node.__class__ and 'id' in self.attrs:
del self.attrs['id']
self.timestamp = None
for d in self.getTags('delay', namespace=NS_DELAY2):
@@ -1550,7 +1550,7 @@
"""
Add one more label-option pair to this field
"""
- if isinstance(opt, basestring):
+ if isinstance(opt, str):
self.addChild('option').setTagData('value', opt)
else:
self.addChild('option', {'label': opt[0]}).setTagData('value',
@@ -1621,7 +1621,7 @@
newdata.append(DataField(name, data[name]))
data = newdata
for child in data:
- if isinstance(child, basestring):
+ if isinstance(child, str):
self.addInstructions(child)
elif child.__class__.__name__ == 'DataField':
self.kids.append(child)
@@ -1695,7 +1695,7 @@
for field in self.getTags('field'):
name = field.getAttr('var')
typ = field.getType()
- if isinstance(typ, basestring) and typ.endswith('-multi'):
+ if isinstance(typ, str) and typ.endswith('-multi'):
val = []
for i in field.getTags('value'):
val.append(i.getData())
diff -r 5ba63540b68d -r 220e1936c4d2 nbxmpp/roster_nb.py
--- a/nbxmpp/roster_nb.py Wed Jan 02 13:51:30 2013 +0100
+++ b/nbxmpp/roster_nb.py Wed Jan 02 14:15:21 2013 +0100
@@ -86,16 +86,16 @@
for item in query.getTags('item'):
jid=item.getAttr('jid')
if item.getAttr('subscription')=='remove':
- if self._data.has_key(jid): del self._data[jid]
+ if jid in self._data: del self._data[jid]
# Looks like we have a workaround
# raise NodeProcessed # a MUST
log.info('Setting roster item %s...' % jid)
- if not self._data.has_key(jid): self._data[jid]={}
+ if jid not in self._data: self._data[jid]={}
self._data[jid]['name']=item.getAttr('name')
self._data[jid]['ask']=item.getAttr('ask')
self._data[jid]['subscription']=item.getAttr('subscription')
self._data[jid]['groups']=[]
- if not self._data[jid].has_key('resources'): self._data[jid]['resources']={}
+ if 'resources' not in self._data[jid]: self._data[jid]['resources']={}
for group in item.getTags('group'):
if group.getData() not in self._data[jid]['groups']:
self._data[jid]['groups'].append(group.getData())
@@ -116,7 +116,7 @@
# If no from attribue, it's from server
jid=self._owner.Server
jid=JID(jid)
- if not self._data.has_key(jid.getStripped()): self._data[jid.getStripped()]={'name':None,'ask':None,'subscription':'none','groups':['Not in roster'],'resources':{}}
+ if jid.getStripped() not in self._data: self._data[jid.getStripped()]={'name':None,'ask':None,'subscription':'none','groups':['Not in roster'],'resources':{}}
if type(self._data[jid.getStripped()]['resources'])!=type(dict()):
self._data[jid.getStripped()]['resources']={}
item=self._data[jid.getStripped()]
@@ -130,7 +130,7 @@
if pres.getTag('priority'): res['priority']=pres.getPriority()
if not pres.getTimestamp(): pres.setTimestamp()
res['timestamp']=pres.getTimestamp()
- elif typ=='unavailable' and item['resources'].has_key(jid.getResource()): del item['resources'][jid.getResource()]
+ elif typ=='unavailable' and jid.getResource() in item['resources']: del item['resources'][jid.getResource()]
# Need to handle type='error' also
def _getItemData(self, jid, dataname):
@@ -147,11 +147,11 @@
"""
if jid.find('/') + 1:
jid, resource = jid.split('/', 1)
- if self._data[jid]['resources'].has_key(resource):
+ if resource in self._data[jid]['resources']:
return self._data[jid]['resources'][resource][dataname]
- elif self._data[jid]['resources'].keys():
+ elif list(self._data[jid]['resources'].keys()):
lastpri = -129
- for r in self._data[jid]['resources'].keys():
+ for r in list(self._data[jid]['resources'].keys()):
if int(self._data[jid]['resources'][r]['priority']) > lastpri:
resource, lastpri=r, int(self._data[jid]['resources'][r]['priority'])
return self._data[jid]['resources'][resource][dataname]
@@ -222,7 +222,7 @@
"""
Return list of connected resources of contact 'jid'
"""
- return self._data[jid[:(jid+'/').find('/')]]['resources'].keys()
+ return list(self._data[jid[:(jid+'/').find('/')]]['resources'].keys())
def setItem(self, jid, name=None, groups=[]):
"""
@@ -257,13 +257,13 @@
"""
Return list of all [bare] JIDs that the roster is currently tracks
"""
- return self._data.keys()
+ return list(self._data.keys())
def keys(self):
"""
Same as getItems. Provided for the sake of dictionary interface
"""
- return self._data.keys()
+ return list(self._data.keys())
def __getitem__(self, item):
"""
@@ -277,7 +277,7 @@
Get the contact in the internal format (or None if JID 'item' is not in
roster)
"""
- if self._data.has_key(item):
+ if item in self._data:
return self._data[item]
def Subscribe(self, jid):
diff -r 5ba63540b68d -r 220e1936c4d2 nbxmpp/simplexml.py
--- a/nbxmpp/simplexml.py Wed Jan 02 13:51:30 2013 +0100
+++ b/nbxmpp/simplexml.py Wed Jan 02 14:15:21 2013 +0100
@@ -39,14 +39,14 @@
Converts object "what" to unicode string using it's own __str__ method if
accessible or unicode method otherwise
"""
- if isinstance(what, unicode):
+ if isinstance(what, str):
return what
try:
r = what.__str__()
except AttributeError:
r = str(what)
- if not isinstance(r, unicode):
- return unicode(r, ENCODING)
+ if not isinstance(r, str):
+ return str(r, ENCODING)
return r
class Node(object):
@@ -124,7 +124,7 @@
self.namespace, self.name = tag.split()
else:
self.name = tag
- if isinstance(payload, basestring): payload=[payload]
+ if isinstance(payload, str): payload=[payload]
for i in payload:
if isinstance(i, Node):
self.addChild(node=i)
@@ -163,7 +163,7 @@
for a in self.kids:
if not fancy and (len(self.data)-1)>=cnt: s=s+XMLescape(self.data[cnt])
elif (len(self.data)-1)>=cnt: s=s+XMLescape(self.data[cnt].strip())
- if isinstance(a, str) or isinstance(a, unicode):
+ if isinstance(a, str) or isinstance(a, str):
s = s + a.__str__()
else:
s = s + a.__str__(fancy and fancy+1)
@@ -384,7 +384,7 @@
replaces all node's previous content. If you wish just to add child or
CDATA - use addData or addChild methods
"""
- if isinstance(payload, basestring):
+ if isinstance(payload, str):
payload = [payload]
changeset 5ba63540b68d in /home/hg/repos/python-nbxmpp
details:http://hg.gajim.org/python-nbxmpp?cmd=changeset;node=5ba63540b68d
description: hardcode error values in protocol.py
diffstat:
nbxmpp/protocol.py | 376 +++++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 308 insertions(+), 68 deletions(-)
diffs (truncated from 389 to 300 lines):
diff -r 5c97346d371c -r 5ba63540b68d nbxmpp/protocol.py
--- a/nbxmpp/protocol.py Wed Jan 02 13:17:03 2013 +0100
+++ b/nbxmpp/protocol.py Wed Jan 02 13:51:30 2013 +0100
@@ -166,77 +166,317 @@
NS_HASHES_SHA256 = 'urn:xmpp:hash-function-textual-names:sha-256'
NS_HASHES_SHA512 = 'urn:xmpp:hash-function-textual-names:sha-512'
-xmpp_stream_error_conditions = '''
-bad-format -- -- -- The entity has sent XML that cannot be processed.
-bad-namespace-prefix -- -- -- The entity has sent a namespace prefix that is unsupported, or has sent no namespace prefix on an element that requires such a prefix.
-conflict -- -- -- The server is closing the active stream for this entity because a new stream has been initiated that conflicts with the existing stream.
-connection-timeout -- -- -- The entity has not generated any traffic over the stream for some period of time.
-host-gone -- -- -- The value of the 'to' attribute provided by the initiating entity in the stream header corresponds to a hostname that is no longer hosted by the server.
-host-unknown -- -- -- The value of the 'to' attribute provided by the initiating entity in the stream header does not correspond to a hostname that is hosted by the server.
-improper-addressing -- -- -- A stanza sent between two servers lacks a 'to' or 'from' attribute (or the attribute has no value).
-internal-server-error -- -- -- The server has experienced a misconfiguration or an otherwise-undefined internal error that prevents it from servicing the stream.
-invalid-from -- cancel -- -- The JID or hostname provided in a 'from' address does not match an authorized JID or validated domain negotiated between servers via SASL or dialback, or between a client and a server via authentication and resource authorization.
-invalid-id -- -- -- The stream ID or dialback ID is invalid or does not match an ID previously provided.
-invalid-namespace -- -- -- The streams namespace name is something other than "http://etherx.jabber.org/streams" or the dialback namespace name is something other than "jabber:server:dialback".
-invalid-xml -- -- -- The entity has sent invalid XML over the stream to a server that performs validation.
-not-authorized -- -- -- The entity has attempted to send data before the stream has been authenticated, or otherwise is not authorized to perform an action related to stream negotiation.
-policy-violation -- -- -- The entity has violated some local service policy.
-remote-connection-failed -- -- -- The server is unable to properly connect to a remote resource that is required for authentication or authorization.
-resource-constraint -- -- -- The server lacks the system resources necessary to service the stream.
-restricted-xml -- -- -- The entity has attempted to send restricted XML features such as a comment, processing instruction, DTD, entity reference, or unescaped character.
-see-other-host -- -- -- The server will not provide service to the initiating entity but is redirecting traffic to another host.
-system-shutdown -- -- -- The server is being shut down and all active streams are being closed.
-undefined-condition -- -- -- The error condition is not one of those defined by the other conditions in this list.
-unsupported-encoding -- -- -- The initiating entity has encoded the stream in an encoding that is not supported by the server.
-unsupported-stanza-type -- -- -- The initiating entity has sent a first-level child of the stream that is not supported by the server.
-unsupported-version -- -- -- The value of the 'version' attribute provided by the initiating entity in the stream header specifies a version of XMPP that is not supported by the server.
-xml-not-well-formed -- -- -- The initiating entity has sent XML that is not well-formed.'''
+#xmpp_stream_error_conditions = '''
+#bad-format -- -- -- The entity has sent XML that cannot be processed.
+#bad-namespace-prefix -- -- -- The entity has sent a namespace prefix that is unsupported, or has sent no namespace prefix on an element that requires such a prefix.
+#conflict -- -- -- The server is closing the active stream for this entity because a new stream has been initiated that conflicts with the existing stream.
+#connection-timeout -- -- -- The entity has not generated any traffic over the stream for some period of time.
+#host-gone -- -- -- The value of the 'to' attribute provided by the initiating entity in the stream header corresponds to a hostname that is no longer hosted by the server.
+#host-unknown -- -- -- The value of the 'to' attribute provided by the initiating entity in the stream header does not correspond to a hostname that is hosted by the server.
+#improper-addressing -- -- -- A stanza sent between two servers lacks a 'to' or 'from' attribute (or the attribute has no value).
+#internal-server-error -- -- -- The server has experienced a misconfiguration or an otherwise-undefined internal error that prevents it from servicing the stream.
+#invalid-from -- cancel -- -- The JID or hostname provided in a 'from' address does not match an authorized JID or validated domain negotiated between servers via SASL or dialback, or between a client and a server via authentication and resource authorization.
+#invalid-id -- -- -- The stream ID or dialback ID is invalid or does not match an ID previously provided.
+#invalid-namespace -- -- -- The streams namespace name is something other than "http://etherx.jabber.org/streams" or the dialback namespace name is something other than "jabber:server:dialback".
+#invalid-xml -- -- -- The entity has sent invalid XML over the stream to a server that performs validation.
+#not-authorized -- -- -- The entity has attempted to send data before the stream has been authenticated, or otherwise is not authorized to perform an action related to stream negotiation.
+#policy-violation -- -- -- The entity has violated some local service policy.
+#remote-connection-failed -- -- -- The server is unable to properly connect to a remote resource that is required for authentication or authorization.
+#resource-constraint -- -- -- The server lacks the system resources necessary to service the stream.
+#restricted-xml -- -- -- The entity has attempted to send restricted XML features such as a comment, processing instruction, DTD, entity reference, or unescaped character.
+#see-other-host -- -- -- The server will not provide service to the initiating entity but is redirecting traffic to another host.
+#system-shutdown -- -- -- The server is being shut down and all active streams are being closed.
+#undefined-condition -- -- -- The error condition is not one of those defined by the other conditions in this list.
+#unsupported-encoding -- -- -- The initiating entity has encoded the stream in an encoding that is not supported by the server.
+#unsupported-stanza-type -- -- -- The initiating entity has sent a first-level child of the stream that is not supported by the server.
+#unsupported-version -- -- -- The value of the 'version' attribute provided by the initiating entity in the stream header specifies a version of XMPP that is not supported by the server.
+#xml-not-well-formed -- -- -- The initiating entity has sent XML that is not well-formed.'''
-xmpp_stanza_error_conditions = '''
-bad-request -- 400 -- modify -- The sender has sent XML that is malformed or that cannot be processed.
-conflict -- 409 -- cancel -- Access cannot be granted because an existing resource or session exists with the same name or address.
-feature-not-implemented -- 501 -- cancel -- The feature requested is not implemented by the recipient or server and therefore cannot be processed.
-forbidden -- 403 -- auth -- The requesting entity does not possess the required permissions to perform the action.
-gone -- 302 -- modify -- The recipient or server can no longer be contacted at this address.
-internal-server-error -- 500 -- wait -- The server could not process the stanza because of a misconfiguration or an otherwise-undefined internal server error.
-item-not-found -- 404 -- cancel -- The addressed JID or item requested cannot be found.
-jid-malformed -- 400 -- modify -- The value of the 'to' attribute in the sender's stanza does not adhere to the syntax defined in Addressing Scheme.
-not-acceptable -- 406 -- cancel -- The recipient or server understands the request but is refusing to process it because it does not meet criteria defined by the recipient or server.
-not-allowed -- 405 -- cancel -- The recipient or server does not allow any entity to perform the action.
-not-authorized -- 401 -- auth -- The sender must provide proper credentials before being allowed to perform the action, or has provided improper credentials.
-payment-required -- 402 -- auth -- The requesting entity is not authorized to access the requested service because payment is required.
-recipient-unavailable -- 404 -- wait -- The intended recipient is temporarily unavailable.
-redirect -- 302 -- modify -- The recipient or server is redirecting requests for this information to another entity.
-registration-required -- 407 -- auth -- The requesting entity is not authorized to access the requested service because registration is required.
-remote-server-not-found -- 404 -- cancel -- A remote server or service specified as part or all of the JID of the intended recipient does not exist.
-remote-server-timeout -- 504 -- wait -- A remote server or service specified as part or all of the JID of the intended recipient could not be contacted within a reasonable amount of time.
-resource-constraint -- 500 -- wait -- The server or recipient lacks the system resources necessary to service the request.
-service-unavailable -- 503 -- cancel -- The server or recipient does not currently provide the requested service.
-subscription-required -- 407 -- auth -- The requesting entity is not authorized to access the requested service because a subscription is required.
-undefined-condition -- 500 -- -- Undefined Condition
-unexpected-request -- 400 -- wait -- The recipient or server understood the request but was not expecting it at this time (e.g., the request was out of order).'''
+#xmpp_stanza_error_conditions = '''
+#bad-request -- 400 -- modify -- The sender has sent XML that is malformed or that cannot be processed.
+#conflict -- 409 -- cancel -- Access cannot be granted because an existing resource or session exists with the same name or address.
+#feature-not-implemented -- 501 -- cancel -- The feature requested is not implemented by the recipient or server and therefore cannot be processed.
+#forbidden -- 403 -- auth -- The requesting entity does not possess the required permissions to perform the action.
+#gone -- 302 -- modify -- The recipient or server can no longer be contacted at this address.
+#internal-server-error -- 500 -- wait -- The server could not process the stanza because of a misconfiguration or an otherwise-undefined internal server error.
+#item-not-found -- 404 -- cancel -- The addressed JID or item requested cannot be found.
+#jid-malformed -- 400 -- modify -- The value of the 'to' attribute in the sender's stanza does not adhere to the syntax defined in Addressing Scheme.
+#not-acceptable -- 406 -- cancel -- The recipient or server understands the request but is refusing to process it because it does not meet criteria defined by the recipient or server.
+#not-allowed -- 405 -- cancel -- The recipient or server does not allow any entity to perform the action.
+#not-authorized -- 401 -- auth -- The sender must provide proper credentials before being allowed to perform the action, or has provided improper credentials.
+#payment-required -- 402 -- auth -- The requesting entity is not authorized to access the requested service because payment is required.
+#recipient-unavailable -- 404 -- wait -- The intended recipient is temporarily unavailable.
+#redirect -- 302 -- modify -- The recipient or server is redirecting requests for this information to another entity.
+#registration-required -- 407 -- auth -- The requesting entity is not authorized to access the requested service because registration is required.
+#remote-server-not-found -- 404 -- cancel -- A remote server or service specified as part or all of the JID of the intended recipient does not exist.
+#remote-server-timeout -- 504 -- wait -- A remote server or service specified as part or all of the JID of the intended recipient could not be contacted within a reasonable amount of time.
+#resource-constraint -- 500 -- wait -- The server or recipient lacks the system resources necessary to service the request.
+#service-unavailable -- 503 -- cancel -- The server or recipient does not currently provide the requested service.
+#subscription-required -- 407 -- auth -- The requesting entity is not authorized to access the requested service because a subscription is required.
+#undefined-condition -- 500 -- -- Undefined Condition
+#unexpected-request -- 400 -- wait -- The recipient or server understood the request but was not expecting it at this time (e.g., the request was out of order).'''
-sasl_error_conditions = '''
-aborted -- -- -- The receiving entity acknowledges an <abort/> element sent by the initiating entity; sent in reply to the <abort/> element.
-incorrect-encoding -- -- -- The data provided by the initiating entity could not be processed because the [BASE64]Josefsson, S., The Base16, Base32, and Base64 Data Encodings, July 2003. encoding is incorrect (e.g., because the encoding does not adhere to the definition in Section 3 of [BASE64]Josefsson, S., The Base16, Base32, and Base64 Data Encodings, July 2003.); sent in reply to a <response/> element or an <auth/> element with initial response data.
-invalid-authzid -- -- -- The authzid provided by the initiating entity is invalid, either because it is incorrectly formatted or because the initiating entity does not have permissions to authorize that ID; sent in reply to a <response/> element or an <auth/> element with initial response data.
-invalid-mechanism -- -- -- The initiating entity did not provide a mechanism or requested a mechanism that is not supported by the receiving entity; sent in reply to an <auth/> element.
-mechanism-too-weak -- -- -- The mechanism requested by the initiating entity is weaker than server policy permits for that initiating entity; sent in reply to a <response/> element or an <auth/> element with initial response data.
-not-authorized -- -- -- The authentication failed because the initiating entity did not provide valid credentials (this includes but is not limited to the case of an unknown username); sent in reply to a <response/> element or an <auth/> element with initial response data.
-temporary-auth-failure -- -- -- The authentication failed because of a temporary error condition within the receiving entity; sent in reply to an <auth/> element or <response/> element.'''
+#sasl_error_conditions = '''
+#aborted -- -- -- The receiving entity acknowledges an <abort/> element sent by the initiating entity; sent in reply to the <abort/> element.
+#incorrect-encoding -- -- -- The data provided by the initiating entity could not be processed because the [BASE64]Josefsson, S., The Base16, Base32, and Base64 Data Encodings, July 2003. encoding is incorrect (e.g., because the encoding does not adhere to the definition in Section 3 of [BASE64]Josefsson, S., The Base16, Base32, and Base64 Data Encodings, July 2003.); sent in reply to a <response/> element or an <auth/> element with initial response data.
+#invalid-authzid -- -- -- The authzid provided by the initiating entity is invalid, either because it is incorrectly formatted or because the initiating entity does not have permissions to authorize that ID; sent in reply to a <response/> element or an <auth/> element with initial response data.
+#invalid-mechanism -- -- -- The initiating entity did not provide a mechanism or requested a mechanism that is not supported by the receiving entity; sent in reply to an <auth/> element.
+#mechanism-too-weak -- -- -- The mechanism requested by the initiating entity is weaker than server policy permits for that initiating entity; sent in reply to a <response/> element or an <auth/> element with initial response data.
+#not-authorized -- -- -- The authentication failed because the initiating entity did not provide valid credentials (this includes but is not limited to the case of an unknown username); sent in reply to a <response/> element or an <auth/> element with initial response data.
+#temporary-auth-failure -- -- -- The authentication failed because of a temporary error condition within the receiving entity; sent in reply to an <auth/> element or <response/> element.'''
-ERRORS, _errorcodes = {}, {}
-for ns, errname, errpool in ((NS_XMPP_STREAMS, 'STREAM',
-xmpp_stream_error_conditions), (NS_STANZAS, 'ERR', xmpp_stanza_error_conditions),
-(NS_SASL, 'SASL', sasl_error_conditions)):
- for err in errpool.split('\n')[1:]:
- cond, code, typ, text = err.split(' -- ')
- name = errname + '_' + ascii_upper(cond).replace('-', '_')
- locals()[name] = ns + ' ' + cond
- ERRORS[ns + ' ' + cond] = [code, typ, text]
- if code:
- _errorcodes[code] = cond
-del ns, errname, errpool, err, cond, code, typ, text
+#ERRORS, _errorcodes, loc = {}, {}, {}
+#for ns, errname, errpool in ((NS_XMPP_STREAMS, 'STREAM',
+#xmpp_stream_error_conditions), (NS_STANZAS, 'ERR', xmpp_stanza_error_conditions),
+#(NS_SASL, 'SASL', sasl_error_conditions)):
+ #for err in errpool.split('\n')[1:]:
+ #cond, code, typ, text = err.split(' -- ')
+ #name = errname + '_' + ascii_upper(cond).replace('-', '_')
+ #locals()[name] = ns + ' ' + cond
+ #loc[name] = ns + ' ' + cond
+ #ERRORS[ns + ' ' + cond] = [code, typ, text]
+ #if code:
+ #_errorcodes[code] = cond
+#del ns, errname, errpool, err, cond, code, typ, text
+#import pprint
+#pprint.pprint(ERRORS)
+#pprint.pprint(_errorcodes)
+#for (k, v) in loc.items():
+ #print('%s = \'%s\'' % (k, v))
+
+ERRORS = {
+ 'urn:ietf:params:xml:ns:xmpp-sasl aborted': ['',
+ '',
+ 'The receiving entity acknowledges an <abort/> element sent by the initiating entity; sent in reply to the <abort/> element.'],
+ 'urn:ietf:params:xml:ns:xmpp-sasl incorrect-encoding': ['',
+ '',
+ 'The data provided by the initiating entity could not be processed because the [BASE64]Josefsson, S., The Base16, Base32, and Base64 Data Encodings, July 2003. encoding is incorrect (e.g., because the encoding does not adhere to the definition in Section 3 of [BASE64]Josefsson, S., The Base16, Base32, and Base64 Data Encodings, July 2003.); sent in reply to a <response/> element or an <auth/> element with initial response data.'],
+ 'urn:ietf:params:xml:ns:xmpp-sasl invalid-authzid': ['',
+ '',
+ 'The authzid provided by the initiating entity is invalid, either because it is incorrectly formatted or because the initiating entity does not have permissions to authorize that ID; sent in reply to a <response/> element or an <auth/> element with initial response data.'],
+ 'urn:ietf:params:xml:ns:xmpp-sasl invalid-mechanism': ['',
+ '',
+ 'The initiating entity did not provide a mechanism or requested a mechanism that is not supported by the receiving entity; sent in reply to an <auth/> element.'],
+ 'urn:ietf:params:xml:ns:xmpp-sasl mechanism-too-weak': ['',
+ '',
+ 'The mechanism requested by the initiating entity is weaker than server policy permits for that initiating entity; sent in reply to a <response/> element or an <auth/> element with initial response data.'],
+ 'urn:ietf:params:xml:ns:xmpp-sasl not-authorized': ['',
+ '',
+ 'The authentication failed because the initiating entity did not provide valid credentials (this includes but is not limited to the case of an unknown username); sent in reply to a <response/> element or an <auth/> element with initial response data.'],
+ 'urn:ietf:params:xml:ns:xmpp-sasl temporary-auth-failure': ['',
+ '',
+ 'The authentication failed because of a temporary error condition within the receiving entity; sent in reply to an <auth/> element or <response/> element.'],
+ 'urn:ietf:params:xml:ns:xmpp-stanzas bad-request': ['400',
+ 'modify',
+ 'The sender has sent XML that is malformed or that cannot be processed.'],
+ 'urn:ietf:params:xml:ns:xmpp-stanzas conflict': ['409',
+ 'cancel',
+ 'Access cannot be granted because an existing resource or session exists with the same name or address.'],
+ 'urn:ietf:params:xml:ns:xmpp-stanzas feature-not-implemented': ['501',
+ 'cancel',
+ 'The feature requested is not implemented by the recipient or server and therefore cannot be processed.'],
+ 'urn:ietf:params:xml:ns:xmpp-stanzas forbidden': ['403',
+ 'auth',
+ 'The requesting entity does not possess the required permissions to perform the action.'],
+ 'urn:ietf:params:xml:ns:xmpp-stanzas gone': ['302',
+ 'modify',
+ 'The recipient or server can no longer be contacted at this address.'],
+ 'urn:ietf:params:xml:ns:xmpp-stanzas internal-server-error': ['500',
+ 'wait',
+ 'The server could not process the stanza because of a misconfiguration or an otherwise-undefined internal server error.'],
+ 'urn:ietf:params:xml:ns:xmpp-stanzas item-not-found': ['404',
+ 'cancel',
+ 'The addressed JID or item requested cannot be found.'],
+ 'urn:ietf:params:xml:ns:xmpp-stanzas jid-malformed': ['400',
+ 'modify',
+ "The value of the 'to' attribute in the sender's stanza does not adhere to the syntax defined in Addressing Scheme."],
+ 'urn:ietf:params:xml:ns:xmpp-stanzas not-acceptable': ['406',
+ 'cancel',
+ 'The recipient or server understands the request but is refusing to process it because it does not meet criteria defined by the recipient or server.'],
+ 'urn:ietf:params:xml:ns:xmpp-stanzas not-allowed': ['405',
+ 'cancel',
+ 'The recipient or server does not allow any entity to perform the action.'],
+ 'urn:ietf:params:xml:ns:xmpp-stanzas not-authorized': ['401',
+ 'auth',
+ 'The sender must provide proper credentials before being allowed to perform the action, or has provided improper credentials.'],
+ 'urn:ietf:params:xml:ns:xmpp-stanzas payment-required': ['402',
+ 'auth',
+ 'The requesting entity is not authorized to access the requested service because payment is required.'],
+ 'urn:ietf:params:xml:ns:xmpp-stanzas recipient-unavailable': ['404',
+ 'wait',
+ 'The intended recipient is temporarily unavailable.'],
+ 'urn:ietf:params:xml:ns:xmpp-stanzas redirect': ['302',
+ 'modify',
+ 'The recipient or server is redirecting requests for this information to another entity.'],
+ 'urn:ietf:params:xml:ns:xmpp-stanzas registration-required': ['407',
+ 'auth',
+ 'The requesting entity is not authorized to access the requested service because registration is required.'],
+ 'urn:ietf:params:xml:ns:xmpp-stanzas remote-server-not-found': ['404',
+ 'cancel',
+ 'A remote server or service specified as part or all of the JID of the intended recipient does not exist.'],
+ 'urn:ietf:params:xml:ns:xmpp-stanzas remote-server-timeout': ['504',
+ 'wait',
+ 'A remote server or service specified as part or all of the JID of the intended recipient could not be contacted within a reasonable amount of time.'],
+ 'urn:ietf:params:xml:ns:xmpp-stanzas resource-constraint': ['500',
+ 'wait',
+ 'The server or recipient lacks the system resources necessary to service the request.'],
+ 'urn:ietf:params:xml:ns:xmpp-stanzas service-unavailable': ['503',
+ 'cancel',
+ 'The server or recipient does not currently provide the requested service.'],
+ 'urn:ietf:params:xml:ns:xmpp-stanzas subscription-required': ['407',
+ 'auth',
+ 'The requesting entity is not authorized to access the requested service because a subscription is required.'],
+ 'urn:ietf:params:xml:ns:xmpp-stanzas undefined-condition': ['500',
+ '',
+ 'Undefined Condition'],
+ 'urn:ietf:params:xml:ns:xmpp-stanzas unexpected-request': ['400',
+ 'wait',
+ 'The recipient or server understood the request but was not expecting it at this time (e.g., the request was out of order).'],
+ 'urn:ietf:params:xml:ns:xmpp-streams bad-format': ['',
+ '',
+ 'The entity has sent XML that cannot be processed.'],
+ 'urn:ietf:params:xml:ns:xmpp-streams bad-namespace-prefix': ['',
+ '',
+ 'The entity has sent a namespace prefix that is unsupported, or has sent no namespace prefix on an element that requires such a prefix.'],
+ 'urn:ietf:params:xml:ns:xmpp-streams conflict': ['',
+ '',
+ 'The server is closing the active stream for this entity because a new stream has been initiated that conflicts with the existing stream.'],
+ 'urn:ietf:params:xml:ns:xmpp-streams connection-timeout': ['',
+ '',
+ 'The entity has not generated any traffic over the stream for some period of time.'],
+ 'urn:ietf:params:xml:ns:xmpp-streams host-gone': ['',
+ '',
+ "The value of the 'to' attribute provided by the initiating entity in the stream header corresponds to a hostname that is no longer hosted by the server."],
+ 'urn:ietf:params:xml:ns:xmpp-streams host-unknown': ['',
+ '',
+ "The value of the 'to' attribute provided by the initiating entity in the stream header does not correspond to a hostname that is hosted by the server."],
+ 'urn:ietf:params:xml:ns:xmpp-streams improper-addressing': ['',
+ '',
+ "A stanza sent between two servers lacks a 'to' or 'from' attribute (or the attribute has no value)."],
+ 'urn:ietf:params:xml:ns:xmpp-streams internal-server-error': ['',
+ '',
+ 'The server has experienced a misconfiguration or an otherwise-undefined internal error that prevents it from servicing the stream.'],
+ 'urn:ietf:params:xml:ns:xmpp-streams invalid-from': ['cancel',
+ '',
+ "The JID or hostname provided in a 'from' address does not match an authorized JID or validated domain negotiated between servers via SASL or dialback, or between a client and a server via authentication and resource authorization."],
+ 'urn:ietf:params:xml:ns:xmpp-streams invalid-id': ['',
+ '',
+ 'The stream ID or dialback ID is invalid or does not match an ID previously provided.'],
+ 'urn:ietf:params:xml:ns:xmpp-streams invalid-namespace': ['',
+ '',
+ 'The streams namespace name is something other than "http://etherx.jabber.org/streams" or the dialback namespace name is something other than "jabber:server:dialback".'],
+ 'urn:ietf:params:xml:ns:xmpp-streams invalid-xml': ['',
+ '',
+ 'The entity has sent invalid XML over the stream to a server that performs validation.'],
+ 'urn:ietf:params:xml:ns:xmpp-streams not-authorized': ['',
+ '',
+ 'The entity has attempted to send data before the stream has been authenticated, or otherwise is not authorized to perform an action related to stream negotiation.'],
+ 'urn:ietf:params:xml:ns:xmpp-streams policy-violation': ['',
+ '',
+ 'The entity has violated some local service policy.'],
+ 'urn:ietf:params:xml:ns:xmpp-streams remote-connection-failed': ['',
+ '',
+ 'The server is unable to properly connect to a remote resource that is required for authentication or authorization.'],
+ 'urn:ietf:params:xml:ns:xmpp-streams resource-constraint': ['',
+ '',
+ 'The server lacks the system resources necessary to service the stream.'],
+ 'urn:ietf:params:xml:ns:xmpp-streams restricted-xml': ['',
+ '',
+ 'The entity has attempted to send restricted XML features such as a comment, processing instruction, DTD, entity reference, or unescaped character.'],
+ 'urn:ietf:params:xml:ns:xmpp-streams see-other-host': ['',
+ '',
+ 'The server will not provide service to the initiating entity but is redirecting traffic to another host.'],
+ 'urn:ietf:params:xml:ns:xmpp-streams system-shutdown': ['',
+ '',
+ 'The server is being shut down and all active streams are being closed.'],
+ 'urn:ietf:params:xml:ns:xmpp-streams undefined-condition': ['',
+ '',