Commit 16a2cc00 authored by Juraj Sloboda's avatar Juraj Sloboda

Use Python3 everywhere (#38)

parent 48eb3b0e
......@@ -16,15 +16,9 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
Hexdump implementation in Python 2.7 and 3.
Hexdump implementation in Python 3.
"""
from __future__ import unicode_literals
import sys
__python3__ = sys.version_info > (3,)
def ordp(c):
"""
......@@ -32,19 +26,11 @@ def ordp(c):
"""
output = []
if __python3__:
for i in c:
if (i < 32) or (i >= 127):
output.append(".")
else:
output.append(chr(i))
else:
for i in c:
j = ord(i)
if (j < 32) or (j >= 127):
output.append(".")
else:
output.append(i)
for i in c:
if (i < 32) or (i >= 127):
output.append(".")
else:
output.append(chr(i))
return "".join(output)
......@@ -66,10 +52,7 @@ def hexdump(p):
output.append("{:04d} ".format(i))
for j in range(16):
if (i + j) < length:
if __python3__:
byte = p[i + j]
else:
byte = ord(p[i + j])
byte = p[i + j]
output.append("{:02X} ".format(byte))
else:
output.append(" ")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment