- Switch to 'in' which works in 2/3 instead of legacy '.has_key()'

- Renamed 'id' variable use (which is a built-in) to my_id.
- Small formatting changes to make it more PEP compliant.
This commit is contained in:
cforgeron 2016-01-31 17:01:14 -04:00
parent 44fa4e29e7
commit de224f1573

View file

@ -8,14 +8,6 @@ from unicorn.x86_const import *
import struct import struct
import uuid import uuid
# Python 2/3 Compat without installing six
DEAD_PYTHON = False
import sys
if sys.version_info[0] < 3:
DEAD_PYTHON = True
print("Python 2.x is dead. Start thinking about migrating to 3.x. https://wiki.python.org/moin/Python2orPython3")
SIZE_REG = 4 SIZE_REG = 4
SOCKETCALL_MAX_ARGS = 3 SOCKETCALL_MAX_ARGS = 3
@ -105,14 +97,9 @@ class LogChain:
if fd in self.__chains: if fd in self.__chains:
return fd return fd
if DEAD_PYTHON: for orig_fd, links in self.__linking_fds.items():
for orig_fd, links in self.__linking_fds.iteritems(): if fd in links:
if fd in links: return orig_fd
return orig_fd
else:
for orig_fd, links in self.__linking_fds.items():
if fd in links:
return orig_fd
return None return None
@ -122,16 +109,11 @@ class LogChain:
| START REPORT | | START REPORT |
---------------- ----------------
""") """)
if DEAD_PYTHON:
for my_id, logs in self.__chains.iteritems(): for my_id, logs in self.__chains.items():
print("---- START FD(%d) ----" % my_id) print("---- START FD(%d) ----" % my_id)
print("\n".join(logs)) print("\n".join(logs))
print("---- END FD(%d) ----" % my_id) print("---- END FD(%d) ----" % my_id)
else:
for my_id, logs in self.__chains.items():
print("---- START FD(%d) ----" % my_id)
print("\n".join(logs))
print("---- END FD(%d) ----" % my_id)
print(""" print("""
-------------- --------------