if PY3:
import io
- from pathlib import Path
StringIO = io.StringIO
BytesIO = io.BytesIO
def int2byte(i): return bytes((i,))
def byte2int(b): return b
- maxint = sys.maxsize
-
- def path_to_posix(s):
- return Path(s).as_posix()
-
else:
import cStringIO
import os
- import posixpath
StringIO = BytesIO = cStringIO.StringIO
byte2int = ord
def iterbytes(b):
return iter(b)
-
- maxint = sys.maxint
-
- def path_to_posix(s):
- return posixpath.join(*os.path.split(s))
# examples/ dir of the source distribution.
sys.path[0:0] = ['.', '..']
-from elftools.common.py3compat import maxint, bytes2str
+from elftools.common.py3compat import bytes2str
from elftools.dwarf.descriptions import describe_form_class
from elftools.elf.elffile import ELFFile
# This code is in the public domain
#-------------------------------------------------------------------------------
from __future__ import print_function
+from pathlib import Path
import sys
# If pyelftools is not installed, the example can also run from the root or
sys.path[0:0] = ['.', '..']
from elftools.elf.elffile import ELFFile
-from elftools.common.py3compat import path_to_posix
def process_file(filename):
print(' Top DIE with tag=%s' % top_DIE.tag)
# We're interested in the filename...
- print(' name=%s' % path_to_posix(top_DIE.get_full_path()))
+ print(' name=%s' % Path(top_DIE.get_full_path()).as_posix())
# Display DIEs recursively starting with top_DIE
die_info_rec(top_DIE)
# This code is in the public domain
#-------------------------------------------------------------------------------
from __future__ import print_function
+from pathlib import Path
import sys
# If pyelftools is not installed, the example can also run from the root or
sys.path[0:0] = ['.', '..']
from elftools.elf.elffile import ELFFile
-from elftools.common.py3compat import path_to_posix
def process_file(filename):
print(' Top DIE with tag=%s' % top_DIE.tag)
# We're interested in the filename...
- print(' name=%s' % path_to_posix(top_DIE.get_full_path()))
+ print(' name=%s' % Path(top_DIE.get_full_path()).as_posix())
if __name__ == '__main__':
if sys.argv[1] == '--test':