Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dev.gajim.org/gajim/gajim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYann Leboulanger <asterix@lagaule.org>2008-10-11 13:32:59 +0400
committerYann Leboulanger <asterix@lagaule.org>2008-10-11 13:32:59 +0400
commit84e717c8df33fbe4c762e85189a3ba4552d4f16e (patch)
tree4e072d254cc4ac21ebdaedc30d6caa3c06d5baab /src
parent6cc8204319b59da4a506f80f310ea5a013f34d65 (diff)
[thorstenp] use startswith and endswith instead of array indices on strings
Diffstat (limited to 'src')
-rw-r--r--src/common/connection.py2
-rw-r--r--src/common/connection_handlers.py4
-rw-r--r--src/common/xmpp/auth.py2
-rw-r--r--src/common/xmpp/c14n.py2
-rw-r--r--src/common/xmpp/protocol.py2
-rw-r--r--src/common/xmpp/simplexml.py2
-rw-r--r--src/common/zeroconf/connection_handlers_zeroconf.py4
-rw-r--r--src/common/zeroconf/connection_zeroconf.py2
-rw-r--r--src/dialogs.py2
-rw-r--r--src/remote_control.py2
10 files changed, 12 insertions, 12 deletions
diff --git a/src/common/connection.py b/src/common/connection.py
index ec2da038e..c3d2d0e61 100644
--- a/src/common/connection.py
+++ b/src/common/connection.py
@@ -1093,7 +1093,7 @@ class Connection(ConnectionHandlers):
if keyID and self.USE_GPG:
if keyID == 'UNKNOWN':
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])
else:
#encrypt
diff --git a/src/common/connection_handlers.py b/src/common/connection_handlers.py
index d0089c142..044e42cc3 100644
--- a/src/common/connection_handlers.py
+++ b/src/common/connection_handlers.py
@@ -470,7 +470,7 @@ class ConnectionBytestream:
raise common.xmpp.NodeProcessed
if streamhost is None:
# proxy approves the activate query
- if real_id[:3] == 'au_':
+ if real_id.startswith('au_'):
id = real_id[3:]
if 'streamhost-used' not in file_props or \
file_props['streamhost-used'] is False:
@@ -488,7 +488,7 @@ class ConnectionBytestream:
file_props['streamhost-used'] is True:
raise common.xmpp.NodeProcessed
- if real_id[:3] == 'au_':
+ if real_id.startswith('au_'):
if 'stopped' in file and file_props['stopped']:
self.remove_transfer(file_props)
else:
diff --git a/src/common/xmpp/auth.py b/src/common/xmpp/auth.py
index 698f09015..f524e2e11 100644
--- a/src/common/xmpp/auth.py
+++ b/src/common/xmpp/auth.py
@@ -175,7 +175,7 @@ class SASL(PlugIn):
self.DEBUG('Got challenge:'+data,'ok')
for pair in data.split(','):
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
if 'qop' in chal and chal['qop']=='auth':
resp={}
diff --git a/src/common/xmpp/c14n.py b/src/common/xmpp/c14n.py
index 91fecaa0d..dd44a349a 100644
--- a/src/common/xmpp/c14n.py
+++ b/src/common/xmpp/c14n.py
@@ -22,7 +22,7 @@ def c14n(node):
s = s + c14n(a)
cnt=cnt+1
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]+' />'
else:
s = s + "</" + node.name + ">"
diff --git a/src/common/xmpp/protocol.py b/src/common/xmpp/protocol.py
index 04bec8a58..3570cdbab 100644
--- a/src/common/xmpp/protocol.py
+++ b/src/common/xmpp/protocol.py
@@ -775,7 +775,7 @@ class DataForm(Node):
for field in self.getTags('field'):
name=field.getAttr('var')
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=[]
for i in field.getTags('value'): val.append(i.getData())
else: val=field.getTagData('value')
diff --git a/src/common/xmpp/simplexml.py b/src/common/xmpp/simplexml.py
index 0e4d3219f..515da3ba0 100644
--- a/src/common/xmpp/simplexml.py
+++ b/src/common/xmpp/simplexml.py
@@ -129,7 +129,7 @@ class Node(object):
cnt=cnt+1
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 not self.kids and s[-1:]=='>':
+ if not self.kids and s.endswith('>'):
s=s[:-1]+' />'
if fancy: s = s + "\n"
else:
diff --git a/src/common/zeroconf/connection_handlers_zeroconf.py b/src/common/zeroconf/connection_handlers_zeroconf.py
index ce71e2fcd..379d523bb 100644
--- a/src/common/zeroconf/connection_handlers_zeroconf.py
+++ b/src/common/zeroconf/connection_handlers_zeroconf.py
@@ -235,7 +235,7 @@ class ConnectionBytestream(connection_handlers.ConnectionBytestream):
raise common.xmpp.NodeProcessed
if streamhost is None:
# proxy approves the activate query
- if real_id[:3] == 'au_':
+ if real_id.startswith('au_'):
id = real_id[3:]
if 'streamhost-used' not in file_props or \
file_props['streamhost-used'] is False:
@@ -253,7 +253,7 @@ class ConnectionBytestream(connection_handlers.ConnectionBytestream):
file_props['streamhost-used'] is True:
raise common.xmpp.NodeProcessed
- if real_id[:3] == 'au_':
+ if real_id.startswith('au_'):
gajim.socks5queue.send_file(file_props, self.name)
raise common.xmpp.NodeProcessed
diff --git a/src/common/zeroconf/connection_zeroconf.py b/src/common/zeroconf/connection_zeroconf.py
index d78dd11ba..c21a54bdf 100644
--- a/src/common/zeroconf/connection_zeroconf.py
+++ b/src/common/zeroconf/connection_zeroconf.py
@@ -379,7 +379,7 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf):
if keyID and self.USE_GPG:
if keyID == 'UNKNOWN':
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])
else:
# encrypt
diff --git a/src/dialogs.py b/src/dialogs.py
index 0253cd9da..c2e431b97 100644
--- a/src/dialogs.py
+++ b/src/dialogs.py
@@ -3893,7 +3893,7 @@ class GPGInfoWindow:
verify_now_button.set_no_show_all(True)
verify_now_button.hide()
- if keyID[8:] == 'MISMATCH':
+ if keyID.endswith('MISMATCH'):
verification_status = _('''Contact's identity NOT verified''')
info = _('The contact\'s key (%s) <b>does not match</b> the key '
'assigned in Gajim.') % keyID[:8]
diff --git a/src/remote_control.py b/src/remote_control.py
index 6fd597c5f..cfaa04f3c 100644
--- a/src/remote_control.py
+++ b/src/remote_control.py
@@ -271,7 +271,7 @@ class SignalObject(dbus.service.Object):
connected_account, contact = self._get_account_and_contact(account, jid)
if connected_account:
- if file_path[:7] == 'file://':
+ if file_path.startswith('file://'):
file_path=file_path[7:]
if os.path.isfile(file_path): # is it file?
gajim.interface.instances['file_transfers'].send_file(