[thorstenp] replace filter lambda with list comprehension
This commit is contained in:
parent
88ef121510
commit
89f02b1feb
4 changed files with 10 additions and 12 deletions
|
@ -1321,7 +1321,7 @@ sent a message to.'''
|
||||||
sessions = self.sessions[jid].values()
|
sessions = self.sessions[jid].values()
|
||||||
|
|
||||||
# sessions that we haven't received a thread ID in
|
# sessions that we haven't received a thread ID in
|
||||||
idless = filter(lambda s: not s.received_thread_id, sessions)
|
idless = [s for s in sessions if not s.received_thread_id]
|
||||||
|
|
||||||
# filter out everything except the default session type
|
# filter out everything except the default session type
|
||||||
p = lambda s: isinstance(s, gajim.default_session_type)
|
p = lambda s: isinstance(s, gajim.default_session_type)
|
||||||
|
@ -1344,7 +1344,7 @@ sent a message to.'''
|
||||||
p = lambda s: isinstance(s, gajim.default_session_type)
|
p = lambda s: isinstance(s, gajim.default_session_type)
|
||||||
chat_sessions = filter(p, sessions)
|
chat_sessions = filter(p, sessions)
|
||||||
|
|
||||||
orphaned = filter(lambda s: not s.control, chat_sessions)
|
orphaned = [s for s in chat_sessions if not s.control]
|
||||||
|
|
||||||
return orphaned[0]
|
return orphaned[0]
|
||||||
except (KeyError, IndexError):
|
except (KeyError, IndexError):
|
||||||
|
|
|
@ -244,8 +244,8 @@ class EncryptedStanzaSession(StanzaSession):
|
||||||
return crypto.encode_mpi(gajim.pubkey.sign(hash_, '')[0])
|
return crypto.encode_mpi(gajim.pubkey.sign(hash_, '')[0])
|
||||||
|
|
||||||
def encrypt_stanza(self, stanza):
|
def encrypt_stanza(self, stanza):
|
||||||
encryptable = filter(lambda x: x.getName() not in ('error', 'amp',
|
encryptable = [x for x in stanza.getChildren() if x.getName() not in ('error', 'amp',
|
||||||
'thread'), stanza.getChildren())
|
'thread')]
|
||||||
|
|
||||||
# XXX can also encrypt contents of <error/> elements in stanzas @type =
|
# XXX can also encrypt contents of <error/> elements in stanzas @type =
|
||||||
# 'error'
|
# 'error'
|
||||||
|
@ -324,8 +324,7 @@ class EncryptedStanzaSession(StanzaSession):
|
||||||
stanza.delChild(c)
|
stanza.delChild(c)
|
||||||
|
|
||||||
# contents of <c>, minus <mac>, minus whitespace
|
# contents of <c>, minus <mac>, minus whitespace
|
||||||
macable = ''.join(map(str, filter(lambda x: x.getName() != 'mac',
|
macable = ''.join(str(x) for x in c.getChildren() if x.getName() != 'mac')
|
||||||
c.getChildren())))
|
|
||||||
|
|
||||||
received_mac = base64.b64decode(c.getTagData('mac'))
|
received_mac = base64.b64decode(c.getTagData('mac'))
|
||||||
calculated_mac = self.hmac(self.km_o, macable + \
|
calculated_mac = self.hmac(self.km_o, macable + \
|
||||||
|
@ -365,7 +364,7 @@ class EncryptedStanzaSession(StanzaSession):
|
||||||
|
|
||||||
def c7lize_mac_id(self, form):
|
def c7lize_mac_id(self, form):
|
||||||
kids = form.getChildren()
|
kids = form.getChildren()
|
||||||
macable = filter(lambda x: x.getVar() not in ('mac', 'identity'), kids)
|
macable = [x for x in kids if x.getVar() not in ('mac', 'identity')]
|
||||||
return ''.join(map(lambda el: xmpp.c14n.c14n(el), macable))
|
return ''.join(map(lambda el: xmpp.c14n.c14n(el), macable))
|
||||||
|
|
||||||
def verify_identity(self, form, dh_i, sigmai, i_o):
|
def verify_identity(self, form, dh_i, sigmai, i_o):
|
||||||
|
|
|
@ -2687,8 +2687,7 @@ class Interface:
|
||||||
conn = gajim.connections[account]
|
conn = gajim.connections[account]
|
||||||
|
|
||||||
if not session and fjid in conn.sessions:
|
if not session and fjid in conn.sessions:
|
||||||
sessions = filter(lambda s: isinstance(s, ChatControlSession),
|
sessions = [s for s in conn.sessions[fjid].values() if isinstance(s, ChatControlSession)]
|
||||||
conn.sessions[fjid].values())
|
|
||||||
|
|
||||||
# look for an existing session with a chat control
|
# look for an existing session with a chat control
|
||||||
for s in sessions:
|
for s in sessions:
|
||||||
|
|
|
@ -229,15 +229,15 @@ def get_running_processes():
|
||||||
files = filter(str.isdigit, files)
|
files = filter(str.isdigit, files)
|
||||||
|
|
||||||
# files that aren't directories...
|
# files that aren't directories...
|
||||||
files = filter(lambda f:os.path.isdir('/proc/' + f), files)
|
files = [f for f in files if os.path.isdir('/proc/' + f)]
|
||||||
|
|
||||||
# processes owned by somebody not running gajim...
|
# processes owned by somebody not running gajim...
|
||||||
# (we check if we have access to that file)
|
# (we check if we have access to that file)
|
||||||
files = filter(lambda f:os.access('/proc/' + f +'/exe', os.F_OK), files)
|
files = [f for f in files if os.access('/proc/' + f +'/exe', os.F_OK)]
|
||||||
|
|
||||||
# be sure that /proc/[number]/exe is really a symlink
|
# be sure that /proc/[number]/exe is really a symlink
|
||||||
# to avoid TBs in incorrectly configured systems
|
# to avoid TBs in incorrectly configured systems
|
||||||
files = filter(lambda f:os.path.islink('/proc/' + f + '/exe'), files)
|
files = [f for f in files if os.path.islink('/proc/' + f + '/exe')]
|
||||||
|
|
||||||
# list of processes
|
# list of processes
|
||||||
processes = [os.path.basename(os.readlink('/proc/' + f +'/exe')) for f in files]
|
processes = [os.path.basename(os.readlink('/proc/' + f +'/exe')) for f in files]
|
||||||
|
|
Loading…
Add table
Reference in a new issue