mirror of
https://github.com/wassname/segpy.git
synced 2026-08-13 12:40:51 +08:00
Improved portability between Python 2 and Python 3. Beginnings of code for writing SEG Y.
This commit is contained in:
+31
-1
@@ -1,4 +1,7 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
EMPTY_BYTE_STRING = b'' if sys.version_info >= (3, 0) else ''
|
||||
|
||||
|
||||
def seekable(fh):
|
||||
@@ -21,4 +24,31 @@ def seekable(fh):
|
||||
fh.seek(pos)
|
||||
except AttributeError:
|
||||
return False
|
||||
return True
|
||||
return True
|
||||
|
||||
|
||||
if sys.version_info >= (3, 0):
|
||||
long_int = int
|
||||
else:
|
||||
long_int = long
|
||||
|
||||
|
||||
if sys.version_info >= (3, 0):
|
||||
def byte_string(integers):
|
||||
return bytes(integers)
|
||||
else:
|
||||
def byte_string(integers):
|
||||
return ''.join(chr(i) for i in integers)
|
||||
|
||||
|
||||
if sys.version_info >= (3, 0):
|
||||
import reprlib
|
||||
reprlib = reprlib # Keep the static analyzer happy
|
||||
else:
|
||||
import repr as reprlib
|
||||
|
||||
if sys.version_info >= (3, 0):
|
||||
izip = zip
|
||||
else:
|
||||
from itertools import izip
|
||||
izip = izip # Keep the static analyzer happy
|
||||
|
||||
Reference in New Issue
Block a user