coding style
This commit is contained in:
parent
ed8b7a51d2
commit
bd3d4f60a0
|
@ -981,7 +981,8 @@ def get_os_info():
|
|||
path_to_file.endswith('arch-release'):
|
||||
# file doesn't have version
|
||||
text = distro_name
|
||||
elif path_to_file.endswith('lfs-release'): # file just has version
|
||||
elif path_to_file.endswith('lfs-release'):
|
||||
# file just has version
|
||||
text = distro_name + ' ' + text
|
||||
os_info = text.replace('\n', '')
|
||||
gajim.os_info = os_info
|
||||
|
@ -1137,9 +1138,7 @@ def get_notification_icon_tooltip_dict():
|
|||
account['event_lines'].append(text)
|
||||
else:
|
||||
for jid in non_messages.keys():
|
||||
text = ngettext(
|
||||
'%d event pending',
|
||||
'%d events pending',
|
||||
text = ngettext('%d event pending', '%d events pending',
|
||||
non_messages[jid], non_messages[jid], non_messages[jid])
|
||||
text += _(' from user %s') % (jid)
|
||||
account[account]['event_lines'].append(text)
|
||||
|
@ -1273,9 +1272,11 @@ def prepare_and_validate_gpg_keyID(account, jid, keyID):
|
|||
if keyID in public_keys:
|
||||
for u in gajim.contacts.get_contacts(account, jid):
|
||||
u.keyID = keyID
|
||||
keys_str = gajim.config.get_per('accounts', account, 'attached_gpg_keys')
|
||||
keys_str = gajim.config.get_per('accounts', account,
|
||||
'attached_gpg_keys')
|
||||
keys_str += jid + ' ' + keyID + ' '
|
||||
gajim.config.set_per('accounts', account, 'attached_gpg_keys', keys_str)
|
||||
gajim.config.set_per('accounts', account, 'attached_gpg_keys',
|
||||
keys_str)
|
||||
elif keyID is None:
|
||||
keyID = 'UNKNOWN'
|
||||
return keyID
|
||||
|
|
|
@ -68,7 +68,7 @@ NS_FEATURE ='http://jabber.org/protocol/feature-neg'
|
|||
NS_FILE = 'http://jabber.org/protocol/si/profile/file-transfer' # JEP-0096
|
||||
NS_GAMING = 'http://jabber.org/protocol/gaming' # XEP-0196
|
||||
NS_GATEWAY = 'jabber:iq:gateway' # XEP-0100
|
||||
NS_GEOLOC ='http://jabber.org/protocol/geoloc' # JEP-0080
|
||||
NS_GEOLOC = 'http://jabber.org/protocol/geoloc' # XEP-0080
|
||||
NS_GROUPCHAT = 'gc-1.0'
|
||||
NS_HTTP_AUTH = 'http://jabber.org/protocol/http-auth' # XEP-0070
|
||||
NS_HTTP_BIND = 'http://jabber.org/protocol/httpbind' # XEP-0124
|
||||
|
@ -204,8 +204,8 @@ not-authorized -- -- -- The authentication failed because the initiating entit
|
|||
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),
|
||||
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(' -- ')
|
||||
|
@ -354,7 +354,8 @@ class JID:
|
|||
if not jid and not domain:
|
||||
raise ValueError('JID must contain at least domain name')
|
||||
elif type(jid) == type(self):
|
||||
self.node, self.domain, self.resource = jid.node, jid.domain, jid.resource
|
||||
self.node, self.domain = jid.node, jid.domain
|
||||
self.resource = jid.resource
|
||||
elif domain:
|
||||
self.node, self.domain, self.resource = node, domain, resource
|
||||
else:
|
||||
|
@ -375,7 +376,8 @@ class JID:
|
|||
|
||||
def setNode(self, node):
|
||||
"""
|
||||
Set the node part of the JID to new value. Specify None to remove the node part
|
||||
Set the node part of the JID to new value. Specify None to remove
|
||||
the node part
|
||||
"""
|
||||
self.node = node.lower()
|
||||
|
||||
|
@ -418,7 +420,8 @@ class JID:
|
|||
other = JID(other)
|
||||
except ValueError:
|
||||
return 0
|
||||
return self.resource == other.resource and self.__str__(0) == other.__str__(0)
|
||||
return self.resource == other.resource and \
|
||||
self.__str__(0) == other.__str__(0)
|
||||
|
||||
def __ne__(self, other):
|
||||
"""
|
||||
|
@ -446,7 +449,8 @@ class JID:
|
|||
|
||||
def __hash__(self):
|
||||
"""
|
||||
Produce hash of the JID, Allows to use JID objects as keys of the dictionary
|
||||
Produce hash of the JID, Allows to use JID objects as keys of the
|
||||
dictionary
|
||||
"""
|
||||
return hash(str(self))
|
||||
|
||||
|
@ -469,7 +473,8 @@ class Protocol(Node):
|
|||
def __init__(self, name=None, to=None, typ=None, frm=None, attrs={},
|
||||
payload=[], timestamp=None, xmlns=None, node=None):
|
||||
"""
|
||||
Constructor, name is the name of the stanza i.e. 'message' or 'presence' or 'iq'
|
||||
Constructor, name is the name of the stanza
|
||||
i.e. 'message' or 'presence'or 'iq'
|
||||
|
||||
to is the value of 'to' attribure, 'typ' - 'type' attribute
|
||||
frn - from attribure, attrs - other attributes mapping,
|
||||
|
@ -493,7 +498,8 @@ class Protocol(Node):
|
|||
self.setTo(self['to'])
|
||||
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'):
|
||||
if node and type(self) == type(node) and \
|
||||
self.__class__ == node.__class__ and self.attrs.has_key('id'):
|
||||
del self.attrs['id']
|
||||
self.timestamp = None
|
||||
for d in self.getTags('delay', namespace=NS_DELAY2):
|
||||
|
@ -584,19 +590,20 @@ class Protocol(Node):
|
|||
|
||||
def getError(self):
|
||||
"""
|
||||
Return the error-condition (if present) or the textual description of the
|
||||
error (otherwise)
|
||||
Return the error-condition (if present) or the textual description
|
||||
of the error (otherwise)
|
||||
"""
|
||||
errtag = self.getTag('error')
|
||||
if errtag:
|
||||
for tag in errtag.getChildren():
|
||||
if tag.getName() <> 'text':
|
||||
if tag.getName() != 'text':
|
||||
return tag.getName()
|
||||
return errtag.getData()
|
||||
|
||||
def getErrorMsg(self):
|
||||
"""
|
||||
Return the textual description of the error (if present) or the error condition
|
||||
Return the textual description of the error (if present)
|
||||
or the error condition
|
||||
"""
|
||||
errtag = self.getTag('error')
|
||||
if errtag:
|
||||
|
@ -619,7 +626,8 @@ class Protocol(Node):
|
|||
if str(code) in _errorcodes.keys():
|
||||
error = ErrorNode(_errorcodes[str(code)], text=error)
|
||||
else:
|
||||
error = ErrorNode(ERR_UNDEFINED_CONDITION, code=code, typ='cancel', text=error)
|
||||
error = ErrorNode(ERR_UNDEFINED_CONDITION, code=code,
|
||||
typ='cancel', text=error)
|
||||
elif type(error) in [type(''), type(u'')]:
|
||||
error=ErrorNode(error)
|
||||
self.setType('error')
|
||||
|
@ -724,7 +732,8 @@ class Message(Protocol):
|
|||
"""
|
||||
try:
|
||||
if xmllang:
|
||||
dom = NodeBuilder('<body xmlns="%s" xml:lang="%s">%s</body>' % (NS_XHTML, xmllang, val)).getDom()
|
||||
dom = NodeBuilder('<body xmlns="%s" xml:lang="%s">%s</body>' \
|
||||
% (NS_XHTML, xmllang, val)).getDom()
|
||||
else:
|
||||
dom = NodeBuilder('<body xmlns="%s">%s</body>' % (NS_XHTML,
|
||||
val), 0).getDom()
|
||||
|
@ -848,6 +857,7 @@ class Presence(Protocol):
|
|||
Return the presence role (for groupchat)
|
||||
"""
|
||||
return self._muc_getItemAttr('item', 'role')
|
||||
|
||||
def getAffiliation(self):
|
||||
"""
|
||||
Return the presence affiliation (for groupchat)
|
||||
|
@ -903,7 +913,8 @@ class Iq(Protocol):
|
|||
Alternatively you can pass in the other XML object as the 'node'
|
||||
parameted to replicate it as an iq
|
||||
"""
|
||||
Protocol.__init__(self, 'iq', to=to, typ=typ, attrs=attrs, frm=frm, xmlns=xmlns, node=node)
|
||||
Protocol.__init__(self, 'iq', to=to, typ=typ, attrs=attrs, frm=frm,
|
||||
xmlns=xmlns, node=node)
|
||||
if payload:
|
||||
self.setQueryPayload(payload)
|
||||
if queryNS:
|
||||
|
@ -978,7 +989,8 @@ class ErrorNode(Node):
|
|||
def __init__(self, name, code=None, typ=None, text=None):
|
||||
"""
|
||||
Mandatory parameter: name - name of error condition.
|
||||
Optional parameters: code, typ, text. Used for backwards compartibility with older jabber protocol.
|
||||
Optional parameters: code, typ, text.
|
||||
Used for backwards compartibility with older jabber protocol.
|
||||
"""
|
||||
if name in ERRORS:
|
||||
cod, type_, txt = ERRORS[name]
|
||||
|
@ -1043,8 +1055,8 @@ class DataField(Node):
|
|||
Create new data field of specified name,value and type
|
||||
|
||||
Also 'required','desc' and 'options' fields can be set. Alternatively
|
||||
other XML object can be passed in as the 'node' parameted to replicate it
|
||||
as a new datafiled.
|
||||
other XML object can be passed in as the 'node' parameted
|
||||
to replicate it as a new datafiled.
|
||||
"""
|
||||
Node.__init__(self, 'field', node=node)
|
||||
if name:
|
||||
|
@ -1153,7 +1165,8 @@ class DataField(Node):
|
|||
if isinstance(opt, basestring):
|
||||
self.addChild('option').setTagData('value', opt)
|
||||
else:
|
||||
self.addChild('option', {'label': opt[0]}).setTagData('value', opt[1])
|
||||
self.addChild('option', {'label': opt[0]}).setTagData('value',
|
||||
opt[1])
|
||||
|
||||
def getType(self):
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue