Use `try/except KeyError` in place of `if in dict/else`

This commit is contained in:
ZyX 2013-04-10 18:09:34 +04:00
parent 716f7617c4
commit f389c43e43
1 changed files with 2 additions and 2 deletions

View File

@ -697,13 +697,13 @@ class NetworkLoadSegment(KwThreadedSegment):
total = activity total = activity
interface = name interface = name
if interface in self.interfaces: try:
idata = self.interfaces[interface] idata = self.interfaces[interface]
try: try:
idata['prev'] = idata['last'] idata['prev'] = idata['last']
except KeyError: except KeyError:
pass pass
else: except KeyError:
idata = {} idata = {}
if self.run_once: if self.run_once:
idata['prev'] = (monotonic(), _get_bytes(interface)) idata['prev'] = (monotonic(), _get_bytes(interface))