summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorJoe Guo <joeg@catalyst.net.nz>2019-03-25 12:59:44 +1300
committerAndrew Bartlett <abartlet@samba.org>2019-04-30 23:18:28 +0000
commite98340e3e2132c73ed002166e2e01dc761765b25 (patch)
tree744698292614931650e5d90b9debe0fa2ce98b64 /python
parente387cf92884c55b7945fbd7898312896fbf9cfd9 (diff)
downloadsamba-e98340e3e2132c73ed002166e2e01dc761765b25.tar.gz
traffic: make code more pythonic
Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
Diffstat (limited to 'python')
-rw-r--r--python/samba/emulate/traffic.py12
1 files 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.