xrange and tupple instead of range and list in common/

This commit is contained in:
Nikos Kouremenos 2005-10-27 13:22:42 +00:00
parent ca60bacdb5
commit bf4a1b28ac
2 changed files with 11 additions and 11 deletions

View File

@ -229,7 +229,7 @@ class Connection:
card = vc.getChildren()[0] card = vc.getChildren()[0]
for info in card.getChildren(): for info in card.getChildren():
name = info.getName() name = info.getName()
if name in ['ADR', 'TEL', 'EMAIL']: # we can have several if name in ('ADR', 'TEL', 'EMAIL'): # we can have several
if not vcard.has_key(name): if not vcard.has_key(name):
vcard[name] = [] vcard[name] = []
entry = {} entry = {}
@ -937,7 +937,7 @@ class Connection:
file_tag = si.getTag('file') file_tag = si.getTag('file')
file_props = {'type': 'r'} file_props = {'type': 'r'}
for attribute in file_tag.getAttrs(): for attribute in file_tag.getAttrs():
if attribute in ['name', 'size', 'hash', 'date']: if attribute in ('name', 'size', 'hash', 'date'):
val = file_tag.getAttr(attribute) val = file_tag.getAttr(attribute)
if val is None: if val is None:
continue continue
@ -1148,7 +1148,7 @@ class Connection:
for tag in tags: for tag in tags:
data = tag.getData() data = tag.getData()
if ctype == 'boolean': if ctype == 'boolean':
if data in ['yes', 'true', 'assent', '1']: if data in ('yes', 'true', 'assent', '1'):
data = True data = True
else: else:
data = False data = False
@ -1283,7 +1283,7 @@ class Connection:
def _HttpAuthCB(self, con, iq_obj): def _HttpAuthCB(self, con, iq_obj):
gajim.log.debug('HttpAuthCB') gajim.log.debug('HttpAuthCB')
opt = gajim.config.get_per('accounts', self.name, 'http_auth') opt = gajim.config.get_per('accounts', self.name, 'http_auth')
if opt in ['yes', 'no']: if opt in ('yes', 'no'):
self.build_http_auth_answer(iq_obj, opt) self.build_http_auth_answer(iq_obj, opt)
else: else:
method = iq_obj.getTagAttr('confirm', 'method') method = iq_obj.getTagAttr('confirm', 'method')

View File

@ -306,7 +306,7 @@ running instance of Gajim. \nFile Transfer will be canceled.\n==================
''' '''
if result is None: if result is None:
return return
if result in [0, -1] and \ if result in (0, -1) and \
self.complete_transfer_cb is not None: self.complete_transfer_cb is not None:
account = actor.account account = actor.account
self.complete_transfer_cb(account, self.complete_transfer_cb(account,
@ -439,7 +439,7 @@ class Socks5:
try: try:
lenn = self._send(buff) lenn = self._send(buff)
except Exception, e: except Exception, e:
if e.args[0] not in [EINTR, ENOBUFS, EWOULDBLOCK]: if e.args[0] not in (EINTR, ENOBUFS, EWOULDBLOCK):
# peer stopped reading # peer stopped reading
self.state = 8 # end connection self.state = 8 # end connection
self.close_file() self.close_file()
@ -594,7 +594,7 @@ class Socks5:
auth_mechanisms = [] auth_mechanisms = []
try: try:
ver, num_auth = struct.unpack('!BB', buff[:2]) ver, num_auth = struct.unpack('!BB', buff[:2])
for i in range(num_auth): for i in xrange(num_auth):
mechanism, = struct.unpack('!B', buff[1 + i]) mechanism, = struct.unpack('!B', buff[1 + i])
auth_mechanisms.append(mechanism) auth_mechanisms.append(mechanism)
except: except:
@ -718,9 +718,9 @@ class Socks5Sender(Socks5):
if self._sock is None: if self._sock is None:
return False return False
try: try:
if self.state in [1, 3, 5]: # (initial, request, send file) if self.state in (1, 3, 5): # (initial, request, send file)
return self.pending_read(timeout) return self.pending_read(timeout)
elif self.state in [2, 4]: # send auth and positive response elif self.state in (2, 4): # send auth and positive response
return True return True
except Exception, e: except Exception, e:
return False return False
@ -908,9 +908,9 @@ class Socks5Receiver(Socks5):
if self._sock is None: if self._sock is None:
return False return False
try: try:
if self.state in [2, 4, 6]: # auth response, connect, file data if self.state in (2, 4, 6): # auth response, connect, file data
return self.pending_read(0) return self.pending_read(0)
elif self.state in [1, 3, 5]: # auth types, connect request elif self.state in (1, 3, 5): # auth types, connect request
return True return True
except Exception, e: except Exception, e:
return False return False