diff options
author | David Cournapeau <cournape@gmail.com> | 2009-12-03 16:03:57 +0000 |
---|---|---|
committer | David Cournapeau <cournape@gmail.com> | 2009-12-03 16:03:57 +0000 |
commit | 54d51ba9375a62a504bac2d560358e07e5f8d078 (patch) | |
tree | 4c81d621cf90c0ee8dce86150c1d625e004a38db /numpy/core/setup_common.py | |
parent | f7dd25718e2e8135be2287bfa22967c1c7981448 (diff) | |
download | numpy-54d51ba9375a62a504bac2d560358e07e5f8d078.tar.gz |
Py3k: add a py3k version of pyod.
Diffstat (limited to 'numpy/core/setup_common.py')
-rw-r--r-- | numpy/core/setup_common.py | 44 |
1 files changed, 32 insertions, 12 deletions
diff --git a/numpy/core/setup_common.py b/numpy/core/setup_common.py index 49bdac5ad..f361996a4 100644 --- a/numpy/core/setup_common.py +++ b/numpy/core/setup_common.py @@ -173,18 +173,38 @@ def pyod(filename): We only implement enough to get the necessary information for long double representation, this is not intended as a compatible replacement for od. """ - out = [] - - fid = open(filename, 'r') - try: - yo = [int(oct(int(binascii.b2a_hex(o), 16))) for o in fid.read()] - for i in range(0, len(yo), 16): - line = ['%07d' % int(oct(i))] - line.extend(['%03d' % c for c in yo[i:i+16]]) - out.append(" ".join(line)) - return out - finally: - fid.close() + def _pyod2(): + out = [] + + fid = open(filename, 'r') + try: + yo = [int(oct(int(binascii.b2a_hex(o), 16))) for o in fid.read()] + for i in range(0, len(yo), 16): + line = ['%07d' % int(oct(i))] + line.extend(['%03d' % c for c in yo[i:i+16]]) + out.append(" ".join(line)) + return out + finally: + fid.close() + + def _pyod3(): + out = [] + + fid = open(filename, 'rb') + try: + yo2 = [oct(o)[2:] for o in fid.read()] + for i in range(0, len(yo2), 16): + line = ['%07d' % int(oct(i)[2:])] + line.extend(['%03d' % int(c) for c in yo2[i:i+16]]) + out.append(" ".join(line)) + return out + finally: + fid.close() + + if sys.version_info[0] < 3: + return _pyod2() + else: + return _pyod3() _BEFORE_SEQ = ['000','000','000','000','000','000','000','000', '001','043','105','147','211','253','315','357'] |