From: Eli Bendersky Date: Wed, 10 Apr 2013 04:25:54 +0000 (-0700) Subject: Examples should prefer local pyelftools to installed one X-Git-Tag: v0.21~4 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=cc1e55749666f1213a8715face63a37182230747;p=pyelftools.git Examples should prefer local pyelftools to installed one --- diff --git a/examples/dwarf_decode_address.py b/examples/dwarf_decode_address.py index 4b9ecdc..55b31c7 100644 --- a/examples/dwarf_decode_address.py +++ b/examples/dwarf_decode_address.py @@ -10,12 +10,9 @@ from __future__ import print_function import sys -# If elftools is not installed, maybe we're running from the root or examples -# dir of the source distribution -try: - import elftools -except ImportError: - sys.path[0:0] = ['.', '..'] +# If pyelftools is not installed, the example can also run from the root or +# examples/ dir of the source distribution. +sys.path[0:0] = ['.', '..'] from elftools.common.py3compat import maxint, bytes2str from elftools.elf.elffile import ELFFile diff --git a/examples/dwarf_die_tree.py b/examples/dwarf_die_tree.py index 66280e6..9dcb6b6 100644 --- a/examples/dwarf_die_tree.py +++ b/examples/dwarf_die_tree.py @@ -10,12 +10,9 @@ from __future__ import print_function import sys -# If elftools is not installed, maybe we're running from the root or examples -# dir of the source distribution -try: - import elftools -except ImportError: - sys.path[0:0] = ['.', '..'] +# If pyelftools is not installed, the example can also run from the root or +# examples/ dir of the source distribution. +sys.path[0:0] = ['.', '..'] from elftools.common.py3compat import bytes2str from elftools.elf.elffile import ELFFile diff --git a/examples/dwarf_location_lists.py b/examples/dwarf_location_lists.py index 308dbe6..d8ee1e9 100644 --- a/examples/dwarf_location_lists.py +++ b/examples/dwarf_location_lists.py @@ -10,12 +10,10 @@ from __future__ import print_function import sys -# If elftools is not installed, maybe we're running from the root or examples -# dir of the source distribution -try: - import elftools -except ImportError: - sys.path[0:0] = ['.', '..'] +# If pyelftools is not installed, the example can also run from the root or +# examples/ dir of the source distribution. +sys.path[0:0] = ['.', '..'] + from elftools.common.py3compat import itervalues from elftools.elf.elffile import ELFFile diff --git a/examples/dwarf_range_lists.py b/examples/dwarf_range_lists.py index 63fd6c7..fced6a6 100644 --- a/examples/dwarf_range_lists.py +++ b/examples/dwarf_range_lists.py @@ -10,12 +10,9 @@ from __future__ import print_function import sys -# If elftools is not installed, maybe we're running from the root or examples -# dir of the source distribution -try: - import elftools -except ImportError: - sys.path[0:0] = ['.', '..'] +# If pyelftools is not installed, the example can also run from the root or +# examples/ dir of the source distribution. +sys.path[0:0] = ['.', '..'] from elftools.common.py3compat import itervalues from elftools.elf.elffile import ELFFile diff --git a/examples/elf_low_high_api.py b/examples/elf_low_high_api.py index b06b9e6..e2d7f49 100644 --- a/examples/elf_low_high_api.py +++ b/examples/elf_low_high_api.py @@ -11,12 +11,9 @@ from __future__ import print_function import sys -# If elftools is not installed, maybe we're running from the root or examples -# dir of the source distribution -try: - import elftools -except ImportError: - sys.path[0:0] = ['.', '..'] +# If pyelftools is not installed, the example can also run from the root or +# examples/ dir of the source distribution. +sys.path[0:0] = ['.', '..'] from elftools.common.py3compat import bytes2str from elftools.elf.elffile import ELFFile diff --git a/examples/elf_relocations.py b/examples/elf_relocations.py index 540f477..0086266 100644 --- a/examples/elf_relocations.py +++ b/examples/elf_relocations.py @@ -10,12 +10,10 @@ from __future__ import print_function import sys -# If elftools is not installed, maybe we're running from the root or examples -# dir of the source distribution -try: - import elftools -except ImportError: - sys.path[0:0] = ['.', '..'] +# If pyelftools is not installed, the example can also run from the root or +# examples/ dir of the source distribution. +sys.path[0:0] = ['.', '..'] + from elftools.common.py3compat import bytes2str from elftools.elf.elffile import ELFFile diff --git a/examples/elf_show_debug_sections.py b/examples/elf_show_debug_sections.py index 8ffe8ad..4e4da61 100644 --- a/examples/elf_show_debug_sections.py +++ b/examples/elf_show_debug_sections.py @@ -9,12 +9,9 @@ from __future__ import print_function import sys -# If elftools is not installed, maybe we're running from the root or examples -# dir of the source distribution -try: - import elftools -except ImportError: - sys.path[0:0] = ['.', '..'] +# If pyelftools is not installed, the example can also run from the root or +# examples/ dir of the source distribution. +sys.path[0:0] = ['.', '..'] from elftools.common.py3compat import bytes2str from elftools.elf.elffile import ELFFile diff --git a/examples/elfclass_address_size.py b/examples/elfclass_address_size.py index e6448a6..ac2bfaa 100644 --- a/examples/elfclass_address_size.py +++ b/examples/elfclass_address_size.py @@ -10,12 +10,9 @@ from __future__ import print_function import sys -# If elftools is not installed, maybe we're running from the root or examples -# dir of the source distribution -try: - import elftools -except ImportError: - sys.path[0:0] = ['.', '..'] +# If pyelftools is not installed, the example can also run from the root or +# examples/ dir of the source distribution. +sys.path[0:0] = ['.', '..'] from elftools.elf.elffile import ELFFile diff --git a/examples/examine_dwarf_info.py b/examples/examine_dwarf_info.py index 45cdc67..1aa28c6 100644 --- a/examples/examine_dwarf_info.py +++ b/examples/examine_dwarf_info.py @@ -9,12 +9,9 @@ from __future__ import print_function import sys -# If elftools is not installed, maybe we're running from the root or examples -# dir of the source distribution -try: - import elftools -except ImportError: - sys.path[0:0] = ['.', '..'] +# If pyelftools is not installed, the example can also run from the root or +# examples/ dir of the source distribution. +sys.path[0:0] = ['.', '..'] from elftools.common.py3compat import bytes2str from elftools.elf.elffile import ELFFile