[thorstenp] use startswith and endswith instead of array indices on strings
This commit is contained in:
parent
6cc8204319
commit
84e717c8df
10 changed files with 12 additions and 12 deletions
|
@ -1093,7 +1093,7 @@ class Connection(ConnectionHandlers):
|
||||||
if keyID and self.USE_GPG:
|
if keyID and self.USE_GPG:
|
||||||
if keyID == 'UNKNOWN':
|
if keyID == 'UNKNOWN':
|
||||||
error = _('Neither the remote presence is signed, nor a key was assigned.')
|
error = _('Neither the remote presence is signed, nor a key was assigned.')
|
||||||
elif keyID[8:] == 'MISMATCH':
|
elif keyID.endswith('MISMATCH'):
|
||||||
error = _('The contact\'s key (%s) does not match the key assigned in Gajim.' % keyID[:8])
|
error = _('The contact\'s key (%s) does not match the key assigned in Gajim.' % keyID[:8])
|
||||||
else:
|
else:
|
||||||
#encrypt
|
#encrypt
|
||||||
|
|
|
@ -470,7 +470,7 @@ class ConnectionBytestream:
|
||||||
raise common.xmpp.NodeProcessed
|
raise common.xmpp.NodeProcessed
|
||||||
if streamhost is None:
|
if streamhost is None:
|
||||||
# proxy approves the activate query
|
# proxy approves the activate query
|
||||||
if real_id[:3] == 'au_':
|
if real_id.startswith('au_'):
|
||||||
id = real_id[3:]
|
id = real_id[3:]
|
||||||
if 'streamhost-used' not in file_props or \
|
if 'streamhost-used' not in file_props or \
|
||||||
file_props['streamhost-used'] is False:
|
file_props['streamhost-used'] is False:
|
||||||
|
@ -488,7 +488,7 @@ class ConnectionBytestream:
|
||||||
file_props['streamhost-used'] is True:
|
file_props['streamhost-used'] is True:
|
||||||
raise common.xmpp.NodeProcessed
|
raise common.xmpp.NodeProcessed
|
||||||
|
|
||||||
if real_id[:3] == 'au_':
|
if real_id.startswith('au_'):
|
||||||
if 'stopped' in file and file_props['stopped']:
|
if 'stopped' in file and file_props['stopped']:
|
||||||
self.remove_transfer(file_props)
|
self.remove_transfer(file_props)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -175,7 +175,7 @@ class SASL(PlugIn):
|
||||||
self.DEBUG('Got challenge:'+data,'ok')
|
self.DEBUG('Got challenge:'+data,'ok')
|
||||||
for pair in data.split(','):
|
for pair in data.split(','):
|
||||||
key,value=pair.split('=', 1)
|
key,value=pair.split('=', 1)
|
||||||
if value[:1]=='"' and value[-1:]=='"': value=value[1:-1]
|
if value.startswith('"') and value.endswith('"'): value=value[1:-1]
|
||||||
chal[key]=value
|
chal[key]=value
|
||||||
if 'qop' in chal and chal['qop']=='auth':
|
if 'qop' in chal and chal['qop']=='auth':
|
||||||
resp={}
|
resp={}
|
||||||
|
|
|
@ -22,7 +22,7 @@ def c14n(node):
|
||||||
s = s + c14n(a)
|
s = s + c14n(a)
|
||||||
cnt=cnt+1
|
cnt=cnt+1
|
||||||
if (len(node.data)-1) >= cnt: s = s + normalise_text(node.data[cnt])
|
if (len(node.data)-1) >= cnt: s = s + normalise_text(node.data[cnt])
|
||||||
if not node.kids and s[-1:]=='>':
|
if not node.kids and s.endswith('>'):
|
||||||
s=s[:-1]+' />'
|
s=s[:-1]+' />'
|
||||||
else:
|
else:
|
||||||
s = s + "</" + node.name + ">"
|
s = s + "</" + node.name + ">"
|
||||||
|
|
|
@ -775,7 +775,7 @@ class DataForm(Node):
|
||||||
for field in self.getTags('field'):
|
for field in self.getTags('field'):
|
||||||
name=field.getAttr('var')
|
name=field.getAttr('var')
|
||||||
typ=field.getType()
|
typ=field.getType()
|
||||||
if type(typ) in [type(''),type(u'')] and typ[-6:]=='-multi':
|
if type(typ) in [type(''),type(u'')] and typ.endswith('-multi'):
|
||||||
val=[]
|
val=[]
|
||||||
for i in field.getTags('value'): val.append(i.getData())
|
for i in field.getTags('value'): val.append(i.getData())
|
||||||
else: val=field.getTagData('value')
|
else: val=field.getTagData('value')
|
||||||
|
|
|
@ -129,7 +129,7 @@ class Node(object):
|
||||||
cnt=cnt+1
|
cnt=cnt+1
|
||||||
if not fancy and (len(self.data)-1) >= cnt: s = s + XMLescape(self.data[cnt])
|
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())
|
elif (len(self.data)-1) >= cnt: s = s + XMLescape(self.data[cnt].strip())
|
||||||
if not self.kids and s[-1:]=='>':
|
if not self.kids and s.endswith('>'):
|
||||||
s=s[:-1]+' />'
|
s=s[:-1]+' />'
|
||||||
if fancy: s = s + "\n"
|
if fancy: s = s + "\n"
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -235,7 +235,7 @@ class ConnectionBytestream(connection_handlers.ConnectionBytestream):
|
||||||
raise common.xmpp.NodeProcessed
|
raise common.xmpp.NodeProcessed
|
||||||
if streamhost is None:
|
if streamhost is None:
|
||||||
# proxy approves the activate query
|
# proxy approves the activate query
|
||||||
if real_id[:3] == 'au_':
|
if real_id.startswith('au_'):
|
||||||
id = real_id[3:]
|
id = real_id[3:]
|
||||||
if 'streamhost-used' not in file_props or \
|
if 'streamhost-used' not in file_props or \
|
||||||
file_props['streamhost-used'] is False:
|
file_props['streamhost-used'] is False:
|
||||||
|
@ -253,7 +253,7 @@ class ConnectionBytestream(connection_handlers.ConnectionBytestream):
|
||||||
file_props['streamhost-used'] is True:
|
file_props['streamhost-used'] is True:
|
||||||
raise common.xmpp.NodeProcessed
|
raise common.xmpp.NodeProcessed
|
||||||
|
|
||||||
if real_id[:3] == 'au_':
|
if real_id.startswith('au_'):
|
||||||
gajim.socks5queue.send_file(file_props, self.name)
|
gajim.socks5queue.send_file(file_props, self.name)
|
||||||
raise common.xmpp.NodeProcessed
|
raise common.xmpp.NodeProcessed
|
||||||
|
|
||||||
|
|
|
@ -379,7 +379,7 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf):
|
||||||
if keyID and self.USE_GPG:
|
if keyID and self.USE_GPG:
|
||||||
if keyID == 'UNKNOWN':
|
if keyID == 'UNKNOWN':
|
||||||
error = _('Neither the remote presence is signed, nor a key was assigned.')
|
error = _('Neither the remote presence is signed, nor a key was assigned.')
|
||||||
elif keyID[8:] == 'MISMATCH':
|
elif keyID.endswith('MISMATCH'):
|
||||||
error = _('The contact\'s key (%s) does not match the key assigned in Gajim.' % keyID[:8])
|
error = _('The contact\'s key (%s) does not match the key assigned in Gajim.' % keyID[:8])
|
||||||
else:
|
else:
|
||||||
# encrypt
|
# encrypt
|
||||||
|
|
|
@ -3893,7 +3893,7 @@ class GPGInfoWindow:
|
||||||
verify_now_button.set_no_show_all(True)
|
verify_now_button.set_no_show_all(True)
|
||||||
verify_now_button.hide()
|
verify_now_button.hide()
|
||||||
|
|
||||||
if keyID[8:] == 'MISMATCH':
|
if keyID.endswith('MISMATCH'):
|
||||||
verification_status = _('''Contact's identity NOT verified''')
|
verification_status = _('''Contact's identity NOT verified''')
|
||||||
info = _('The contact\'s key (%s) <b>does not match</b> the key '
|
info = _('The contact\'s key (%s) <b>does not match</b> the key '
|
||||||
'assigned in Gajim.') % keyID[:8]
|
'assigned in Gajim.') % keyID[:8]
|
||||||
|
|
|
@ -271,7 +271,7 @@ class SignalObject(dbus.service.Object):
|
||||||
connected_account, contact = self._get_account_and_contact(account, jid)
|
connected_account, contact = self._get_account_and_contact(account, jid)
|
||||||
|
|
||||||
if connected_account:
|
if connected_account:
|
||||||
if file_path[:7] == 'file://':
|
if file_path.startswith('file://'):
|
||||||
file_path=file_path[7:]
|
file_path=file_path[7:]
|
||||||
if os.path.isfile(file_path): # is it file?
|
if os.path.isfile(file_path): # is it file?
|
||||||
gajim.interface.instances['file_transfers'].send_file(
|
gajim.interface.instances['file_transfers'].send_file(
|
||||||
|
|
Loading…
Add table
Reference in a new issue