[thorstenp] replace filter lambda with list comprehension
This commit is contained in:
parent
88ef121510
commit
89f02b1feb
|
@ -1321,7 +1321,7 @@ sent a message to.'''
|
|||
sessions = self.sessions[jid].values()
|
||||
|
||||
# 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
|
||||
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)
|
||||
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]
|
||||
except (KeyError, IndexError):
|
||||
|
|
|
@ -244,8 +244,8 @@ class EncryptedStanzaSession(StanzaSession):
|
|||
return crypto.encode_mpi(gajim.pubkey.sign(hash_, '')[0])
|
||||
|
||||
def encrypt_stanza(self, stanza):
|
||||
encryptable = filter(lambda x: x.getName() not in ('error', 'amp',
|
||||
'thread'), stanza.getChildren())
|
||||
encryptable = [x for x in stanza.getChildren() if x.getName() not in ('error', 'amp',
|
||||
'thread')]
|
||||
|
||||
# XXX can also encrypt contents of <error/> elements in stanzas @type =
|
||||
# 'error'
|
||||
|
@ -324,8 +324,7 @@ class EncryptedStanzaSession(StanzaSession):
|
|||
stanza.delChild(c)
|
||||
|
||||
# contents of <c>, minus <mac>, minus whitespace
|
||||
macable = ''.join(map(str, filter(lambda x: x.getName() != 'mac',
|
||||
c.getChildren())))
|
||||
macable = ''.join(str(x) for x in c.getChildren() if x.getName() != 'mac')
|
||||
|
||||
received_mac = base64.b64decode(c.getTagData('mac'))
|
||||
calculated_mac = self.hmac(self.km_o, macable + \
|
||||
|
@ -365,7 +364,7 @@ class EncryptedStanzaSession(StanzaSession):
|
|||
|
||||
def c7lize_mac_id(self, form):
|
||||
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))
|
||||
|
||||
def verify_identity(self, form, dh_i, sigmai, i_o):
|
||||
|
|
|
@ -2687,8 +2687,7 @@ class Interface:
|
|||
conn = gajim.connections[account]
|
||||
|
||||
if not session and fjid in conn.sessions:
|
||||
sessions = filter(lambda s: isinstance(s, ChatControlSession),
|
||||
conn.sessions[fjid].values())
|
||||
sessions = [s for s in conn.sessions[fjid].values() if isinstance(s, ChatControlSession)]
|
||||
|
||||
# look for an existing session with a chat control
|
||||
for s in sessions:
|
||||
|
|
|
@ -229,15 +229,15 @@ def get_running_processes():
|
|||
files = filter(str.isdigit, files)
|
||||
|
||||
# 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...
|
||||
# (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
|
||||
# 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
|
||||
processes = [os.path.basename(os.readlink('/proc/' + f +'/exe')) for f in files]
|
||||
|
|
Loading…
Reference in New Issue