From e98340e3e2132c73ed002166e2e01dc761765b25 Mon Sep 17 00:00:00 2001 From: Joe Guo Date: Mon, 25 Mar 2019 12:59:44 +1300 Subject: [PATCH] traffic: make code more pythonic Signed-off-by: Joe Guo Reviewed-by: Andrew Bartlett Reviewed-by: Andreas Schneider --- python/samba/emulate/traffic.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/python/samba/emulate/traffic.py b/python/samba/emulate/traffic.py index 03603759816..9d439a43054 100644 --- a/python/samba/emulate/traffic.py +++ b/python/samba/emulate/traffic.py @@ -872,11 +872,8 @@ class Conversation(object): if not client: src, dest = dest, src key = (protocol, opcode) - desc = OP_DESCRIPTIONS[key] if key in OP_DESCRIPTIONS else '' - if protocol in IP_PROTOCOLS: - ip_protocol = IP_PROTOCOLS[protocol] - else: - ip_protocol = '06' + desc = OP_DESCRIPTIONS.get(key, '') + ip_protocol = IP_PROTOCOLS.get(protocol, '06') packet = Packet(timestamp - self.start_time, ip_protocol, '', src, dest, protocol, opcode, desc, extra) @@ -909,10 +906,7 @@ class Conversation(object): return self.packets[-1].timestamp - self.packets[0].timestamp def replay_as_summary_lines(self): - lines = [] - for p in self.packets: - lines.append(p.as_summary(self.start_time)) - return lines + return [p.as_summary(self.start_time) for p in self.packets] def replay_with_delay(self, start, context=None, account=None): """Replay the conversation at the right time. -- 2.47.3