From ddbb2ec490a81d86a5dcc0ad851d642efed011c9 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 24 Nov 2025 21:13:15 +0000 Subject: [PATCH 1/2] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/pre-commit-hooks: v4.6.0 → v6.0.0](https://github.com/pre-commit/pre-commit-hooks/compare/v4.6.0...v6.0.0) - https://github.com/psf/black → https://github.com/psf/black-pre-commit-mirror - [github.com/psf/black-pre-commit-mirror: 24.10.0 → 25.11.0](https://github.com/psf/black-pre-commit-mirror/compare/24.10.0...25.11.0) - [github.com/astral-sh/ruff-pre-commit: v0.6.9 → v0.14.6](https://github.com/astral-sh/ruff-pre-commit/compare/v0.6.9...v0.14.6) - [github.com/pycqa/isort: 5.13.2 → 7.0.0](https://github.com/pycqa/isort/compare/5.13.2...7.0.0) - [github.com/asottile/pyupgrade: v3.17.0 → v3.21.2](https://github.com/asottile/pyupgrade/compare/v3.17.0...v3.21.2) - [github.com/PyCQA/bandit: 1.7.10 → 1.9.2](https://github.com/PyCQA/bandit/compare/1.7.10...1.9.2) --- .pre-commit-config.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 780e4e1..16ffd4b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,7 +17,7 @@ exclude: | repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v6.0.0 hooks: - id: check-added-large-files - id: check-toml @@ -34,32 +34,32 @@ repos: - id: end-of-file-fixer - id: trailing-whitespace - - repo: https://github.com/psf/black - rev: 24.10.0 + - repo: https://github.com/psf/black-pre-commit-mirror + rev: 25.11.0 hooks: - id: black language_version: python3.13 - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.6.9 + rev: v0.14.6 hooks: - id: ruff args: ["--fix", "--exit-non-zero-on-fix"] - repo: https://github.com/pycqa/isort - rev: 5.13.2 + rev: 7.0.0 hooks: - id: isort types_or: [cython, pyi, python] - repo: https://github.com/asottile/pyupgrade - rev: v3.17.0 + rev: v3.21.2 hooks: - id: pyupgrade args: ["--py39-plus"] - repo: https://github.com/PyCQA/bandit - rev: 1.7.10 + rev: 1.9.2 hooks: - id: bandit args: ["-c", "bandit.yml"] From cf20905217646db1b6cd3bb389ea583f04bc0a71 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 24 Nov 2025 21:13:30 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .gitignore | 1 - .pylintrc | 1156 +++++++++++++------------- CONTRIBUTORS | 2 +- docs/conf.py | 410 ++++----- docs/index.rst | 56 +- docs/installation.rst | 86 +- docs/make.bat | 72 +- docs/modules.rst | 14 +- docs/objutils.elf.rst | 122 +-- docs/objutils.rst | 472 +++++------ docs/requirements.txt | 12 +- docs/scripts.rst | 606 +++++++------- docs/tutorial.rst | 218 ++--- docs/tutorial1.ipynb | 44 +- objutils/binfile.py | 3 +- objutils/dwarf/__init__.py | 3 +- objutils/dwarf/sm.py | 2 +- objutils/elf/__init__.py | 3 +- objutils/hexdump.py | 3 +- objutils/hexfile.py | 21 +- objutils/image.py | 4 +- objutils/registry.py | 11 +- objutils/scripts/oj_elf_arm_attrs.py | 3 +- objutils/scripts/oj_elf_extract.py | 3 +- objutils/scripts/oj_elf_import.py | 1 - objutils/scripts/oj_elf_info.py | 3 +- objutils/scripts/oj_elf_syms.py | 3 +- objutils/scripts/oj_hex_info.py | 3 +- objutils/section.py | 11 +- objutils/shf.py | 3 +- objutils/srec.py | 3 +- 31 files changed, 1672 insertions(+), 1682 deletions(-) diff --git a/.gitignore b/.gitignore index 1c559b2..7244f46 100644 --- a/.gitignore +++ b/.gitignore @@ -260,4 +260,3 @@ cython_debug/ # and can be added to the global gitignore or merged into this file. For a more nuclear # option (not recommended) you can uncomment the following to ignore the entire idea folder. #.idea/ - diff --git a/.pylintrc b/.pylintrc index 811b771..c1ff118 100644 --- a/.pylintrc +++ b/.pylintrc @@ -1,578 +1,578 @@ -[MASTER] - -# A comma-separated list of package or module names from where C extensions may -# be loaded. Extensions are loading into the active Python interpreter and may -# run arbitrary code. -extension-pkg-whitelist= - -# Add files or directories to the blacklist. They should be base names, not -# paths. -ignore=CVS - -# Add files or directories matching the regex patterns to the blacklist. The -# regex matches against base names, not paths. -ignore-patterns= - -# Python code to execute, usually for sys.path manipulation such as -# pygtk.require(). -#init-hook= - -# Use multiple processes to speed up Pylint. Specifying 0 will auto-detect the -# number of processors available to use. -jobs=1 - -# Control the amount of potential inferred values when inferring a single -# object. This can help the performance when dealing with large functions or -# complex, nested conditions. -limit-inference-results=100 - -# List of plugins (as comma separated values of python modules names) to load, -# usually to register additional checkers. -load-plugins= - -# Pickle collected data for later comparisons. -persistent=yes - -# Specify a configuration file. -#rcfile= - -# When enabled, pylint would attempt to guess common misconfiguration and emit -# user-friendly hints instead of false-positive error messages. -suggestion-mode=yes - -# Allow loading of arbitrary C extensions. Extensions are imported into the -# active Python interpreter and may run arbitrary code. -unsafe-load-any-extension=no - - -[MESSAGES CONTROL] - -# Only show warnings with the listed confidence levels. Leave empty to show -# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED. -confidence= - -# Disable the message, report, category or checker with the given id(s). You -# can either give multiple identifiers separated by comma (,) or put this -# option multiple times (only on the command line, not in the configuration -# file where it should appear only once). You can also use "--disable=all" to -# disable everything first and then reenable specific checks. For example, if -# you want to run only the similarities checker, you can use "--disable=all -# --enable=similarities". If you want to run only the classes checker, but have -# no Warning level messages displayed, use "--disable=all --enable=classes -# --disable=W". -disable=print-statement, - parameter-unpacking, - unpacking-in-except, - old-raise-syntax, - backtick, - long-suffix, - old-ne-operator, - old-octal-literal, - import-star-module-level, - non-ascii-bytes-literal, - raw-checker-failed, - bad-inline-option, - locally-disabled, - file-ignored, - suppressed-message, - useless-suppression, - deprecated-pragma, - use-symbolic-message-instead, - apply-builtin, - basestring-builtin, - buffer-builtin, - cmp-builtin, - coerce-builtin, - execfile-builtin, - file-builtin, - long-builtin, - raw_input-builtin, - reduce-builtin, - standarderror-builtin, - unicode-builtin, - xrange-builtin, - coerce-method, - delslice-method, - getslice-method, - setslice-method, - no-absolute-import, - old-division, - dict-iter-method, - dict-view-method, - next-method-called, - metaclass-assignment, - indexing-exception, - raising-string, - reload-builtin, - oct-method, - hex-method, - nonzero-method, - cmp-method, - input-builtin, - round-builtin, - intern-builtin, - unichr-builtin, - map-builtin-not-iterating, - zip-builtin-not-iterating, - range-builtin-not-iterating, - filter-builtin-not-iterating, - using-cmp-argument, - eq-without-hash, - div-method, - idiv-method, - rdiv-method, - exception-message-attribute, - invalid-str-codec, - sys-max-int, - bad-python3-import, - deprecated-string-function, - deprecated-str-translate-call, - deprecated-itertools-function, - deprecated-types-field, - next-method-defined, - dict-items-not-iterating, - dict-keys-not-iterating, - dict-values-not-iterating, - deprecated-operator-function, - deprecated-urllib-function, - xreadlines-attribute, - deprecated-sys-function, - exception-escape, - comprehension-escape, -## -## Chris -## - bad-whitespace, # C0326 - trailing-newlines, # Trailing newlines *are* required for C/C++ compilation units... - no-else-return - - -# Enable the message, report, category or checker with the given id(s). You can -# either give multiple identifier separated by comma (,) or put this option -# multiple time (only on the command line, not in the configuration file where -# it should appear only once). See also the "--disable" option for examples. -enable=c-extension-no-member - - -[REPORTS] - -# Python expression which should return a note less than 10 (10 is the highest -# note). You have access to the variables errors warning, statement which -# respectively contain the number of errors / warnings messages and the total -# number of statements analyzed. This is used by the global evaluation report -# (RP0004). -evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) - -# Template used to display messages. This is a python new-style format string -# used to format the message information. See doc for all details. -#msg-template= - -# Set the output format. Available formats are text, parseable, colorized, json -# and msvs (visual studio). You can also give a reporter class, e.g. -# mypackage.mymodule.MyReporterClass. -output-format=text - -# Tells whether to display a full report or only the messages. -reports=no - -# Activate the evaluation score. -score=yes - - -[REFACTORING] - -# Maximum number of nested blocks for function / method body -max-nested-blocks=5 - -# Complete name of functions that never returns. When checking for -# inconsistent-return-statements if a never returning function is called then -# it will be considered as an explicit return statement and no message will be -# printed. -never-returning-functions=sys.exit - - -[BASIC] - -# Naming style matching correct argument names. -#argument-naming-style=snake_case -argument-naming-style=camelCase - -# Regular expression matching correct argument names. Overrides argument- -# naming-style. -#argument-rgx= -argument-rgx=[a-z][a-zA-Z0-9]*$ - -# Naming style matching correct attribute names. -attr-naming-style=snake_case - -# Regular expression matching correct attribute names. Overrides attr-naming- -# style. -#attr-rgx= -attr-rgx=[a-z][a-zA-Z0-9]*$ - -# Bad variable names which should always be refused, separated by a comma. -bad-names=foo, - bar, - baz, - toto, - tutu, - tata - -# Naming style matching correct class attribute names. -class-attribute-naming-style=any - -# Regular expression matching correct class attribute names. Overrides class- -# attribute-naming-style. -#class-attribute-rgx= - -# Naming style matching correct class names. -class-naming-style=PascalCase - -# Regular expression matching correct class names. Overrides class-naming- -# style. -#class-rgx= -class-rgx=[A-Z][a-zA-Z0-9]+$ - -# Naming style matching correct constant names. -const-naming-style=UPPER_CASE - -# Regular expression matching correct constant names. Overrides const-naming- -# style. -#const-rgx= - -# Minimum line length for functions/classes that require docstrings, shorter -# ones are exempt. -docstring-min-length=-1 - -# Naming style matching correct function names. -function-naming-style=snake_case - -# Regular expression matching correct function names. Overrides function- -# naming-style. -#function-rgx= -function-rgx=[a-z_][a-zA-Z0-9]*$ - - -# Good variable names which should always be accepted, separated by a comma. -good-names=i, - j, - k, - ex, - Run, - _ - -# Include a hint for the correct naming format with invalid-name. -include-naming-hint=no - -# Naming style matching correct inline iteration names. -inlinevar-naming-style=any - -# Regular expression matching correct inline iteration names. Overrides -# inlinevar-naming-style. -#inlinevar-rgx= - -# Naming style matching correct method names. -method-naming-style=snake_case - -# Regular expression matching correct method names. Overrides method-naming- -# style. -#method-rgx= -method-rgx=[a-z_][a-zA-Z0-9]*$ - - -# Naming style matching correct module names. -module-naming-style=snake_case - -# Regular expression matching correct module names. Overrides module-naming- -# style. -#module-rgx= -module-rgx=(([a-z][a-z0-9]*)|([A-Z][a-zA-Z0-9]+))$ - - -# Colon-delimited sets of names that determine each other's naming style when -# the name regexes allow several styles. -name-group= - -# Regular expression which should only match function or class names that do -# not require a docstring. -no-docstring-rgx=^_ - -# List of decorators that produce properties, such as abc.abstractproperty. Add -# to this list to register other decorators that produce valid properties. -# These decorators are taken in consideration only for invalid-name. -property-classes=abc.abstractproperty - -# Naming style matching correct variable names. -variable-naming-style=snake_case - -# Regular expression matching correct variable names. Overrides variable- -# naming-style. -#variable-rgx= -variable-rgx=[a-z][a-zA-Z0-9]*$ - -[FORMAT] - -# Expected format of line ending, e.g. empty (any line ending), LF or CRLF. -expected-line-ending-format= - -# Regexp for a line that is allowed to be longer than the limit. -ignore-long-lines=^\s*(# )??$ - -# Number of spaces of indent required inside a hanging or continued line. -indent-after-paren=4 - -# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 -# tab). -indent-string=' ' - -# Maximum number of characters on a single line. -max-line-length=132 - -# Maximum number of lines in a module. -max-module-lines=1000 - -# List of optional constructs for which whitespace checking is disabled. `dict- -# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}. -# `trailing-comma` allows a space between comma and closing bracket: (a, ). -# `empty-line` allows space-only lines. -no-space-check=trailing-comma, - dict-separator - -# Allow the body of a class to be on the same line as the declaration if body -# contains single statement. -single-line-class-stmt=no - -# Allow the body of an if to be on the same line as the test if there is no -# else. -single-line-if-stmt=no - - -[LOGGING] - -# Format style used to check logging format string. `old` means using % -# formatting, while `new` is for `{}` formatting. -logging-format-style=old - -# Logging modules to check that the string format arguments are in logging -# function parameter format. -logging-modules=logging - - -[MISCELLANEOUS] - -# List of note tags to take in consideration, separated by a comma. -notes=FIXME, - XXX, - TODO - - -[SIMILARITIES] - -# Ignore comments when computing similarities. -ignore-comments=yes - -# Ignore docstrings when computing similarities. -ignore-docstrings=yes - -# Ignore imports when computing similarities. -ignore-imports=no - -# Minimum lines number of a similarity. -min-similarity-lines=4 - - -[SPELLING] - -# Limits count of emitted suggestions for spelling mistakes. -max-spelling-suggestions=4 - -# Spelling dictionary name. Available dictionaries: none. To make it working -# install python-enchant package.. -spelling-dict= - -# List of comma separated words that should not be checked. -spelling-ignore-words= - -# A path to a file that contains private dictionary; one word per line. -spelling-private-dict-file= - -# Tells whether to store unknown words to indicated private dictionary in -# --spelling-private-dict-file option instead of raising a message. -spelling-store-unknown-words=no - - -[TYPECHECK] - -# List of decorators that produce context managers, such as -# contextlib.contextmanager. Add to this list to register other decorators that -# produce valid context managers. -contextmanager-decorators=contextlib.contextmanager - -# List of members which are set dynamically and missed by pylint inference -# system, and so shouldn't trigger E1101 when accessed. Python regular -# expressions are accepted. -generated-members= - -# Tells whether missing members accessed in mixin class should be ignored. A -# mixin class is detected if its name ends with "mixin" (case insensitive). -ignore-mixin-members=yes - -# Tells whether to warn about missing members when the owner of the attribute -# is inferred to be None. -ignore-none=yes - -# This flag controls whether pylint should warn about no-member and similar -# checks whenever an opaque object is returned when inferring. The inference -# can return multiple potential results while evaluating a Python object, but -# some branches might not be evaluated, which results in partial inference. In -# that case, it might be useful to still emit no-member and other checks for -# the rest of the inferred objects. -ignore-on-opaque-inference=yes - -# List of class names for which member attributes should not be checked (useful -# for classes with dynamically set attributes). This supports the use of -# qualified names. -ignored-classes=optparse.Values,thread._local,_thread._local - -# List of module names for which member attributes should not be checked -# (useful for modules/projects where namespaces are manipulated during runtime -# and thus existing member attributes cannot be deduced by static analysis. It -# supports qualified module names, as well as Unix pattern matching. -ignored-modules= - -# Show a hint with possible names when a member name was not found. The aspect -# of finding the hint is based on edit distance. -missing-member-hint=yes - -# The minimum edit distance a name should have in order to be considered a -# similar match for a missing member name. -missing-member-hint-distance=1 - -# The total number of similar names that should be taken in consideration when -# showing a hint for a missing member. -missing-member-max-choices=1 - - -[VARIABLES] - -# List of additional names supposed to be defined in builtins. Remember that -# you should avoid defining new builtins when possible. -additional-builtins= - -# Tells whether unused global variables should be treated as a violation. -allow-global-unused-variables=yes - -# List of strings which can identify a callback function by name. A callback -# name must start or end with one of those strings. -callbacks=cb_, - _cb - -# A regular expression matching the name of dummy variables (i.e. expected to -# not be used). -dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_ - -# Argument names that match this expression will be ignored. Default to name -# with leading underscore. -ignored-argument-names=_.*|^ignored_|^unused_ - -# Tells whether we should check for unused import in __init__ files. -init-import=no - -# List of qualified module names which can have objects that can redefine -# builtins. -redefining-builtins-modules=six.moves,past.builtins,future.builtins,builtins,io - - -[CLASSES] - -# List of method names used to declare (i.e. assign) instance attributes. -defining-attr-methods=__init__, - __new__, - setUp - -# List of member names, which should be excluded from the protected access -# warning. -exclude-protected=_asdict, - _fields, - _replace, - _source, - _make - -# List of valid names for the first argument in a class method. -valid-classmethod-first-arg=cls - -# List of valid names for the first argument in a metaclass class method. -valid-metaclass-classmethod-first-arg=cls - - -[DESIGN] - -# Maximum number of arguments for function / method. -max-args=6 - -# Maximum number of attributes for a class (see R0902). -max-attributes=12 - -# Maximum number of boolean expressions in an if statement. -max-bool-expr=5 - -# Maximum number of branch for function / method body. -max-branches=12 - -# Maximum number of locals for function / method body. -max-locals=15 - -# Maximum number of parents for a class (see R0901). -max-parents=7 - -# Maximum number of public methods for a class (see R0904). -max-public-methods=50 - -# Maximum number of return / yield for function / method body. -max-returns=6 - -# Maximum number of statements in function / method body. -max-statements=50 - -# Minimum number of public methods for a class (see R0903). -min-public-methods=2 - - -[IMPORTS] - -# Allow wildcard imports from modules that define __all__. -allow-wildcard-with-all=no - -# Analyse import fallback blocks. This can be used to support both Python 2 and -# 3 compatible code, which means that the block might have code that exists -# only in one or another interpreter, leading to false positives when analysed. -analyse-fallback-blocks=no - -# Deprecated modules which should not be used, separated by a comma. -deprecated-modules=optparse - -# Create a graph of external dependencies in the given file (report RP0402 must -# not be disabled). -ext-import-graph= - -# Create a graph of every (i.e. internal and external) dependencies in the -# given file (report RP0402 must not be disabled). -import-graph= - -# Create a graph of internal dependencies in the given file (report RP0402 must -# not be disabled). -int-import-graph= - -# Force import order to recognize a module as part of the standard -# compatibility libraries. -known-standard-library= - -# Force import order to recognize a module as part of a third party library. -known-third-party=enchant - - -[EXCEPTIONS] - -# Exceptions that will emit a warning when being caught. Defaults to -# "Exception". -overgeneral-exceptions=Exception +[MASTER] + +# A comma-separated list of package or module names from where C extensions may +# be loaded. Extensions are loading into the active Python interpreter and may +# run arbitrary code. +extension-pkg-whitelist= + +# Add files or directories to the blacklist. They should be base names, not +# paths. +ignore=CVS + +# Add files or directories matching the regex patterns to the blacklist. The +# regex matches against base names, not paths. +ignore-patterns= + +# Python code to execute, usually for sys.path manipulation such as +# pygtk.require(). +#init-hook= + +# Use multiple processes to speed up Pylint. Specifying 0 will auto-detect the +# number of processors available to use. +jobs=1 + +# Control the amount of potential inferred values when inferring a single +# object. This can help the performance when dealing with large functions or +# complex, nested conditions. +limit-inference-results=100 + +# List of plugins (as comma separated values of python modules names) to load, +# usually to register additional checkers. +load-plugins= + +# Pickle collected data for later comparisons. +persistent=yes + +# Specify a configuration file. +#rcfile= + +# When enabled, pylint would attempt to guess common misconfiguration and emit +# user-friendly hints instead of false-positive error messages. +suggestion-mode=yes + +# Allow loading of arbitrary C extensions. Extensions are imported into the +# active Python interpreter and may run arbitrary code. +unsafe-load-any-extension=no + + +[MESSAGES CONTROL] + +# Only show warnings with the listed confidence levels. Leave empty to show +# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED. +confidence= + +# Disable the message, report, category or checker with the given id(s). You +# can either give multiple identifiers separated by comma (,) or put this +# option multiple times (only on the command line, not in the configuration +# file where it should appear only once). You can also use "--disable=all" to +# disable everything first and then reenable specific checks. For example, if +# you want to run only the similarities checker, you can use "--disable=all +# --enable=similarities". If you want to run only the classes checker, but have +# no Warning level messages displayed, use "--disable=all --enable=classes +# --disable=W". +disable=print-statement, + parameter-unpacking, + unpacking-in-except, + old-raise-syntax, + backtick, + long-suffix, + old-ne-operator, + old-octal-literal, + import-star-module-level, + non-ascii-bytes-literal, + raw-checker-failed, + bad-inline-option, + locally-disabled, + file-ignored, + suppressed-message, + useless-suppression, + deprecated-pragma, + use-symbolic-message-instead, + apply-builtin, + basestring-builtin, + buffer-builtin, + cmp-builtin, + coerce-builtin, + execfile-builtin, + file-builtin, + long-builtin, + raw_input-builtin, + reduce-builtin, + standarderror-builtin, + unicode-builtin, + xrange-builtin, + coerce-method, + delslice-method, + getslice-method, + setslice-method, + no-absolute-import, + old-division, + dict-iter-method, + dict-view-method, + next-method-called, + metaclass-assignment, + indexing-exception, + raising-string, + reload-builtin, + oct-method, + hex-method, + nonzero-method, + cmp-method, + input-builtin, + round-builtin, + intern-builtin, + unichr-builtin, + map-builtin-not-iterating, + zip-builtin-not-iterating, + range-builtin-not-iterating, + filter-builtin-not-iterating, + using-cmp-argument, + eq-without-hash, + div-method, + idiv-method, + rdiv-method, + exception-message-attribute, + invalid-str-codec, + sys-max-int, + bad-python3-import, + deprecated-string-function, + deprecated-str-translate-call, + deprecated-itertools-function, + deprecated-types-field, + next-method-defined, + dict-items-not-iterating, + dict-keys-not-iterating, + dict-values-not-iterating, + deprecated-operator-function, + deprecated-urllib-function, + xreadlines-attribute, + deprecated-sys-function, + exception-escape, + comprehension-escape, +## +## Chris +## + bad-whitespace, # C0326 + trailing-newlines, # Trailing newlines *are* required for C/C++ compilation units... + no-else-return + + +# Enable the message, report, category or checker with the given id(s). You can +# either give multiple identifier separated by comma (,) or put this option +# multiple time (only on the command line, not in the configuration file where +# it should appear only once). See also the "--disable" option for examples. +enable=c-extension-no-member + + +[REPORTS] + +# Python expression which should return a note less than 10 (10 is the highest +# note). You have access to the variables errors warning, statement which +# respectively contain the number of errors / warnings messages and the total +# number of statements analyzed. This is used by the global evaluation report +# (RP0004). +evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) + +# Template used to display messages. This is a python new-style format string +# used to format the message information. See doc for all details. +#msg-template= + +# Set the output format. Available formats are text, parseable, colorized, json +# and msvs (visual studio). You can also give a reporter class, e.g. +# mypackage.mymodule.MyReporterClass. +output-format=text + +# Tells whether to display a full report or only the messages. +reports=no + +# Activate the evaluation score. +score=yes + + +[REFACTORING] + +# Maximum number of nested blocks for function / method body +max-nested-blocks=5 + +# Complete name of functions that never returns. When checking for +# inconsistent-return-statements if a never returning function is called then +# it will be considered as an explicit return statement and no message will be +# printed. +never-returning-functions=sys.exit + + +[BASIC] + +# Naming style matching correct argument names. +#argument-naming-style=snake_case +argument-naming-style=camelCase + +# Regular expression matching correct argument names. Overrides argument- +# naming-style. +#argument-rgx= +argument-rgx=[a-z][a-zA-Z0-9]*$ + +# Naming style matching correct attribute names. +attr-naming-style=snake_case + +# Regular expression matching correct attribute names. Overrides attr-naming- +# style. +#attr-rgx= +attr-rgx=[a-z][a-zA-Z0-9]*$ + +# Bad variable names which should always be refused, separated by a comma. +bad-names=foo, + bar, + baz, + toto, + tutu, + tata + +# Naming style matching correct class attribute names. +class-attribute-naming-style=any + +# Regular expression matching correct class attribute names. Overrides class- +# attribute-naming-style. +#class-attribute-rgx= + +# Naming style matching correct class names. +class-naming-style=PascalCase + +# Regular expression matching correct class names. Overrides class-naming- +# style. +#class-rgx= +class-rgx=[A-Z][a-zA-Z0-9]+$ + +# Naming style matching correct constant names. +const-naming-style=UPPER_CASE + +# Regular expression matching correct constant names. Overrides const-naming- +# style. +#const-rgx= + +# Minimum line length for functions/classes that require docstrings, shorter +# ones are exempt. +docstring-min-length=-1 + +# Naming style matching correct function names. +function-naming-style=snake_case + +# Regular expression matching correct function names. Overrides function- +# naming-style. +#function-rgx= +function-rgx=[a-z_][a-zA-Z0-9]*$ + + +# Good variable names which should always be accepted, separated by a comma. +good-names=i, + j, + k, + ex, + Run, + _ + +# Include a hint for the correct naming format with invalid-name. +include-naming-hint=no + +# Naming style matching correct inline iteration names. +inlinevar-naming-style=any + +# Regular expression matching correct inline iteration names. Overrides +# inlinevar-naming-style. +#inlinevar-rgx= + +# Naming style matching correct method names. +method-naming-style=snake_case + +# Regular expression matching correct method names. Overrides method-naming- +# style. +#method-rgx= +method-rgx=[a-z_][a-zA-Z0-9]*$ + + +# Naming style matching correct module names. +module-naming-style=snake_case + +# Regular expression matching correct module names. Overrides module-naming- +# style. +#module-rgx= +module-rgx=(([a-z][a-z0-9]*)|([A-Z][a-zA-Z0-9]+))$ + + +# Colon-delimited sets of names that determine each other's naming style when +# the name regexes allow several styles. +name-group= + +# Regular expression which should only match function or class names that do +# not require a docstring. +no-docstring-rgx=^_ + +# List of decorators that produce properties, such as abc.abstractproperty. Add +# to this list to register other decorators that produce valid properties. +# These decorators are taken in consideration only for invalid-name. +property-classes=abc.abstractproperty + +# Naming style matching correct variable names. +variable-naming-style=snake_case + +# Regular expression matching correct variable names. Overrides variable- +# naming-style. +#variable-rgx= +variable-rgx=[a-z][a-zA-Z0-9]*$ + +[FORMAT] + +# Expected format of line ending, e.g. empty (any line ending), LF or CRLF. +expected-line-ending-format= + +# Regexp for a line that is allowed to be longer than the limit. +ignore-long-lines=^\s*(# )??$ + +# Number of spaces of indent required inside a hanging or continued line. +indent-after-paren=4 + +# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 +# tab). +indent-string=' ' + +# Maximum number of characters on a single line. +max-line-length=132 + +# Maximum number of lines in a module. +max-module-lines=1000 + +# List of optional constructs for which whitespace checking is disabled. `dict- +# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}. +# `trailing-comma` allows a space between comma and closing bracket: (a, ). +# `empty-line` allows space-only lines. +no-space-check=trailing-comma, + dict-separator + +# Allow the body of a class to be on the same line as the declaration if body +# contains single statement. +single-line-class-stmt=no + +# Allow the body of an if to be on the same line as the test if there is no +# else. +single-line-if-stmt=no + + +[LOGGING] + +# Format style used to check logging format string. `old` means using % +# formatting, while `new` is for `{}` formatting. +logging-format-style=old + +# Logging modules to check that the string format arguments are in logging +# function parameter format. +logging-modules=logging + + +[MISCELLANEOUS] + +# List of note tags to take in consideration, separated by a comma. +notes=FIXME, + XXX, + TODO + + +[SIMILARITIES] + +# Ignore comments when computing similarities. +ignore-comments=yes + +# Ignore docstrings when computing similarities. +ignore-docstrings=yes + +# Ignore imports when computing similarities. +ignore-imports=no + +# Minimum lines number of a similarity. +min-similarity-lines=4 + + +[SPELLING] + +# Limits count of emitted suggestions for spelling mistakes. +max-spelling-suggestions=4 + +# Spelling dictionary name. Available dictionaries: none. To make it working +# install python-enchant package.. +spelling-dict= + +# List of comma separated words that should not be checked. +spelling-ignore-words= + +# A path to a file that contains private dictionary; one word per line. +spelling-private-dict-file= + +# Tells whether to store unknown words to indicated private dictionary in +# --spelling-private-dict-file option instead of raising a message. +spelling-store-unknown-words=no + + +[TYPECHECK] + +# List of decorators that produce context managers, such as +# contextlib.contextmanager. Add to this list to register other decorators that +# produce valid context managers. +contextmanager-decorators=contextlib.contextmanager + +# List of members which are set dynamically and missed by pylint inference +# system, and so shouldn't trigger E1101 when accessed. Python regular +# expressions are accepted. +generated-members= + +# Tells whether missing members accessed in mixin class should be ignored. A +# mixin class is detected if its name ends with "mixin" (case insensitive). +ignore-mixin-members=yes + +# Tells whether to warn about missing members when the owner of the attribute +# is inferred to be None. +ignore-none=yes + +# This flag controls whether pylint should warn about no-member and similar +# checks whenever an opaque object is returned when inferring. The inference +# can return multiple potential results while evaluating a Python object, but +# some branches might not be evaluated, which results in partial inference. In +# that case, it might be useful to still emit no-member and other checks for +# the rest of the inferred objects. +ignore-on-opaque-inference=yes + +# List of class names for which member attributes should not be checked (useful +# for classes with dynamically set attributes). This supports the use of +# qualified names. +ignored-classes=optparse.Values,thread._local,_thread._local + +# List of module names for which member attributes should not be checked +# (useful for modules/projects where namespaces are manipulated during runtime +# and thus existing member attributes cannot be deduced by static analysis. It +# supports qualified module names, as well as Unix pattern matching. +ignored-modules= + +# Show a hint with possible names when a member name was not found. The aspect +# of finding the hint is based on edit distance. +missing-member-hint=yes + +# The minimum edit distance a name should have in order to be considered a +# similar match for a missing member name. +missing-member-hint-distance=1 + +# The total number of similar names that should be taken in consideration when +# showing a hint for a missing member. +missing-member-max-choices=1 + + +[VARIABLES] + +# List of additional names supposed to be defined in builtins. Remember that +# you should avoid defining new builtins when possible. +additional-builtins= + +# Tells whether unused global variables should be treated as a violation. +allow-global-unused-variables=yes + +# List of strings which can identify a callback function by name. A callback +# name must start or end with one of those strings. +callbacks=cb_, + _cb + +# A regular expression matching the name of dummy variables (i.e. expected to +# not be used). +dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_ + +# Argument names that match this expression will be ignored. Default to name +# with leading underscore. +ignored-argument-names=_.*|^ignored_|^unused_ + +# Tells whether we should check for unused import in __init__ files. +init-import=no + +# List of qualified module names which can have objects that can redefine +# builtins. +redefining-builtins-modules=six.moves,past.builtins,future.builtins,builtins,io + + +[CLASSES] + +# List of method names used to declare (i.e. assign) instance attributes. +defining-attr-methods=__init__, + __new__, + setUp + +# List of member names, which should be excluded from the protected access +# warning. +exclude-protected=_asdict, + _fields, + _replace, + _source, + _make + +# List of valid names for the first argument in a class method. +valid-classmethod-first-arg=cls + +# List of valid names for the first argument in a metaclass class method. +valid-metaclass-classmethod-first-arg=cls + + +[DESIGN] + +# Maximum number of arguments for function / method. +max-args=6 + +# Maximum number of attributes for a class (see R0902). +max-attributes=12 + +# Maximum number of boolean expressions in an if statement. +max-bool-expr=5 + +# Maximum number of branch for function / method body. +max-branches=12 + +# Maximum number of locals for function / method body. +max-locals=15 + +# Maximum number of parents for a class (see R0901). +max-parents=7 + +# Maximum number of public methods for a class (see R0904). +max-public-methods=50 + +# Maximum number of return / yield for function / method body. +max-returns=6 + +# Maximum number of statements in function / method body. +max-statements=50 + +# Minimum number of public methods for a class (see R0903). +min-public-methods=2 + + +[IMPORTS] + +# Allow wildcard imports from modules that define __all__. +allow-wildcard-with-all=no + +# Analyse import fallback blocks. This can be used to support both Python 2 and +# 3 compatible code, which means that the block might have code that exists +# only in one or another interpreter, leading to false positives when analysed. +analyse-fallback-blocks=no + +# Deprecated modules which should not be used, separated by a comma. +deprecated-modules=optparse + +# Create a graph of external dependencies in the given file (report RP0402 must +# not be disabled). +ext-import-graph= + +# Create a graph of every (i.e. internal and external) dependencies in the +# given file (report RP0402 must not be disabled). +import-graph= + +# Create a graph of internal dependencies in the given file (report RP0402 must +# not be disabled). +int-import-graph= + +# Force import order to recognize a module as part of the standard +# compatibility libraries. +known-standard-library= + +# Force import order to recognize a module as part of a third party library. +known-third-party=enchant + + +[EXCEPTIONS] + +# Exceptions that will emit a warning when being caught. Defaults to +# "Exception". +overgeneral-exceptions=Exception diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 7478dd3..d12b866 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -1 +1 @@ -Christoph Schueler +Christoph Schueler diff --git a/docs/conf.py b/docs/conf.py index 844ec37..8e014ac 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,205 +1,205 @@ -# -# Configuration file for the Sphinx documentation builder. -# -# This file does only contain a selection of the most common options. For a -# full list see the documentation: -# http://www.sphinx-doc.org/en/stable/config -# -- Path setup -------------------------------------------------------------- -# If extensions (or modules to document with autodoc) are in another directory, -# add these directories to sys.path here. If the directory is relative to the -# documentation root, use os.path.abspath to make it absolute, like shown here. -# -import os -import sys - - -def get_version(): - import re - from pathlib import Path - - VERSION = re.compile(r'version\s*=\s*"(?P\d+\.\d+(\.\d+)?)\s*"', re.M) - - try: - cfg = Path(r"../pyproject.toml") - data = cfg.open().read() - except Exception: - return "0.1" - else: - match = VERSION.search(data) - if match: - gd = match.groupdict() - version = gd.get("version") - if version: - return version - return "0.1" - - -sys.path.insert(0, os.path.abspath("../objutils")) - - -# -- Project information ----------------------------------------------------- - -project = "objutils" -copyright = "2025, Christoph Schueler" -author = "Christoph Schueler" - -# The short X.Y version -version = "" -# The full version, including alpha/beta/rc tags -release = get_version() - - -# -- General configuration --------------------------------------------------- - -# If your documentation needs a minimal Sphinx version, state it here. -# -# needs_sphinx = '1.0' - -# Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom -# ones. -extensions = [ - "sphinx.ext.autodoc", - "numpydoc", - "sphinx.ext.doctest", - "sphinx.ext.autosummary", - "sphinx_copybutton", - "sphinx.ext.intersphinx", - "sphinx.ext.viewcode", - "sphinx.ext.autosectionlabel", -] - -# Add any paths that contain templates here, relative to this directory. -templates_path = ["_templates"] - -# The suffix(es) of source filenames. -# You can specify multiple suffix as a list of string: -# -source_suffix = {".rst": "restructuredtext"} - -# The master toctree document. -master_doc = "index" - -# The language for content autogenerated by Sphinx. Refer to documentation -# for a list of supported languages. -# -# This is also used if you do content translation via gettext catalogs. -# Usually you set "language" from the command line for these cases. -language = "en" - -# List of patterns, relative to source directory, that match files and -# directories to ignore when looking for source files. -# This pattern also affects html_static_path and html_extra_path . -exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] - -# The name of the Pygments (syntax highlighting) style to use. -pygments_style = "sphinx" - - -# -- Options for HTML output ------------------------------------------------- - -# The theme to use for HTML and HTML Help pages. See the documentation for -# a list of builtin themes. -# -html_theme = "pydata_sphinx_theme" - -# Theme options are theme-specific and customize the look and feel of a theme -# further. For a list of options available for each theme, see the -# documentation. -# -# html_theme_options = {} - -# Add any paths that contain custom static files (such as style sheets) here, -# relative to this directory. They are copied after the builtin static files, -# so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ["_static"] - -# Custom sidebar templates, must be a dictionary that maps document names -# to template names. -# -# The default sidebars (for documents that don't match any pattern) are -# defined by theme itself. Builtin themes are using these templates by -# default: ``['localtoc.html', 'relations.html', 'sourcelink.html', -# 'searchbox.html']``. -# -# html_sidebars = {} - - -# -- Options for HTMLHelp output --------------------------------------------- - -# Output file base name for HTML help builder. -htmlhelp_basename = "objutilsdoc" - - -# -- Options for LaTeX output ------------------------------------------------ - -latex_elements = { - # The paper size ('letterpaper' or 'a4paper'). - # - # 'papersize': 'letterpaper', - # The font size ('10pt', '11pt' or '12pt'). - # - # 'pointsize': '10pt', - # Additional stuff for the LaTeX preamble. - # - # 'preamble': '', - # Latex figure (float) alignment - # - # 'figure_align': 'htbp', -} - -# Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, -# author, documentclass [howto, manual, or own class]). -latex_documents = [ - ( - master_doc, - "objutils.tex", - "objutils Documentation", - "Christoph Schueler", - "manual", - ), -] - - -# -- Options for manual page output ------------------------------------------ - -# One entry per manual page. List of tuples -# (source start file, name, description, authors, manual section). -man_pages = [(master_doc, "objutils", "objutils Documentation", [author], 1)] - - -# -- Options for Texinfo output ---------------------------------------------- - -# Grouping the document tree into Texinfo files. List of tuples -# (source start file, target name, title, author, -# dir menu entry, description, category) -texinfo_documents = [ - ( - master_doc, - "objutils", - "objutils Documentation", - author, - "objutils", - "One line description of project.", - "Miscellaneous", - ), -] - -# -- Extension configuration ------------------------------------------------- - -# -- Options for todo extension ---------------------------------------------- - -# If true, `todo` and `todoList` produce output, else they produce nothing. -todo_include_todos = True - -numpydoc_show_class_members = False -autosummary_generate = True -autosummary_imported_members = True - -autodoc_default_options = { - "member_order": "bysource", - "private-members": True, - "undoc-members": True, - "show-inheritance": True, -} +# +# Configuration file for the Sphinx documentation builder. +# +# This file does only contain a selection of the most common options. For a +# full list see the documentation: +# http://www.sphinx-doc.org/en/stable/config +# -- Path setup -------------------------------------------------------------- +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +# +import os +import sys + + +def get_version(): + import re + from pathlib import Path + + VERSION = re.compile(r'version\s*=\s*"(?P\d+\.\d+(\.\d+)?)\s*"', re.M) + + try: + cfg = Path(r"../pyproject.toml") + data = cfg.open().read() + except Exception: + return "0.1" + else: + match = VERSION.search(data) + if match: + gd = match.groupdict() + version = gd.get("version") + if version: + return version + return "0.1" + + +sys.path.insert(0, os.path.abspath("../objutils")) + + +# -- Project information ----------------------------------------------------- + +project = "objutils" +copyright = "2025, Christoph Schueler" +author = "Christoph Schueler" + +# The short X.Y version +version = "" +# The full version, including alpha/beta/rc tags +release = get_version() + + +# -- General configuration --------------------------------------------------- + +# If your documentation needs a minimal Sphinx version, state it here. +# +# needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ + "sphinx.ext.autodoc", + "numpydoc", + "sphinx.ext.doctest", + "sphinx.ext.autosummary", + "sphinx_copybutton", + "sphinx.ext.intersphinx", + "sphinx.ext.viewcode", + "sphinx.ext.autosectionlabel", +] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ["_templates"] + +# The suffix(es) of source filenames. +# You can specify multiple suffix as a list of string: +# +source_suffix = {".rst": "restructuredtext"} + +# The master toctree document. +master_doc = "index" + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# +# This is also used if you do content translation via gettext catalogs. +# Usually you set "language" from the command line for these cases. +language = "en" + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +# This pattern also affects html_static_path and html_extra_path . +exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = "sphinx" + + +# -- Options for HTML output ------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +# +html_theme = "pydata_sphinx_theme" + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +# +# html_theme_options = {} + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ["_static"] + +# Custom sidebar templates, must be a dictionary that maps document names +# to template names. +# +# The default sidebars (for documents that don't match any pattern) are +# defined by theme itself. Builtin themes are using these templates by +# default: ``['localtoc.html', 'relations.html', 'sourcelink.html', +# 'searchbox.html']``. +# +# html_sidebars = {} + + +# -- Options for HTMLHelp output --------------------------------------------- + +# Output file base name for HTML help builder. +htmlhelp_basename = "objutilsdoc" + + +# -- Options for LaTeX output ------------------------------------------------ + +latex_elements = { + # The paper size ('letterpaper' or 'a4paper'). + # + # 'papersize': 'letterpaper', + # The font size ('10pt', '11pt' or '12pt'). + # + # 'pointsize': '10pt', + # Additional stuff for the LaTeX preamble. + # + # 'preamble': '', + # Latex figure (float) alignment + # + # 'figure_align': 'htbp', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, +# author, documentclass [howto, manual, or own class]). +latex_documents = [ + ( + master_doc, + "objutils.tex", + "objutils Documentation", + "Christoph Schueler", + "manual", + ), +] + + +# -- Options for manual page output ------------------------------------------ + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [(master_doc, "objutils", "objutils Documentation", [author], 1)] + + +# -- Options for Texinfo output ---------------------------------------------- + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + ( + master_doc, + "objutils", + "objutils Documentation", + author, + "objutils", + "One line description of project.", + "Miscellaneous", + ), +] + +# -- Extension configuration ------------------------------------------------- + +# -- Options for todo extension ---------------------------------------------- + +# If true, `todo` and `todoList` produce output, else they produce nothing. +todo_include_todos = True + +numpydoc_show_class_members = False +autosummary_generate = True +autosummary_imported_members = True + +autodoc_default_options = { + "member_order": "bysource", + "private-members": True, + "undoc-members": True, + "show-inheritance": True, +} diff --git a/docs/index.rst b/docs/index.rst index 5fed3bb..d51808b 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,28 +1,28 @@ - -Welcome to objutils -=================== - -.. image:: objutils_dark.jpg - :align: center - :scale: 25% - -objutils provides Python APIs and CLI tools to work with object files and classic HEX/record formats used in embedded firmware workflows. Start with the tutorial and scripts, or jump to the full API reference. - - -.. toctree:: - :maxdepth: 2 - :caption: Contents: - - README - installation - tutorial - howto - scripts - modules - -Indices and tables -================== - -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` + +Welcome to objutils +=================== + +.. image:: objutils_dark.jpg + :align: center + :scale: 25% + +objutils provides Python APIs and CLI tools to work with object files and classic HEX/record formats used in embedded firmware workflows. Start with the tutorial and scripts, or jump to the full API reference. + + +.. toctree:: + :maxdepth: 2 + :caption: Contents: + + README + installation + tutorial + howto + scripts + modules + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` diff --git a/docs/installation.rst b/docs/installation.rst index 32677a1..a12e19a 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -1,43 +1,43 @@ -Installation and Getting Started -================================ - -Supported Python and platforms ------------------------------- - -- Python >= 3.4 (CPython; PyPy not tested) -- Cross-platform; no OS-specific restrictions - -Install -------- - -From PyPI: - -.. code-block:: shell - - pip install objutils - -For development (editable install): - -.. code-block:: shell - - python setup.py develop - -Quick verification ------------------- - -Open a Python REPL and run: - -.. code-block:: python - - from objutils import Image, Section, dump - img = Image([Section(0x1000, b"hi")]) - dump("srec", "verify.srec", img) - print("Wrote verify.srec") - -Next steps ----------- - -- Read the Tutorial for a guided introduction. -- See HOW-TOs for task-oriented examples. -- Check Scripts for CLI utilities. -- Full docs: `latest on Read the Docs `_. +Installation and Getting Started +================================ + +Supported Python and platforms +------------------------------ + +- Python >= 3.4 (CPython; PyPy not tested) +- Cross-platform; no OS-specific restrictions + +Install +------- + +From PyPI: + +.. code-block:: shell + + pip install objutils + +For development (editable install): + +.. code-block:: shell + + python setup.py develop + +Quick verification +------------------ + +Open a Python REPL and run: + +.. code-block:: python + + from objutils import Image, Section, dump + img = Image([Section(0x1000, b"hi")]) + dump("srec", "verify.srec", img) + print("Wrote verify.srec") + +Next steps +---------- + +- Read the Tutorial for a guided introduction. +- See HOW-TOs for task-oriented examples. +- Check Scripts for CLI utilities. +- Full docs: `latest on Read the Docs `_. diff --git a/docs/make.bat b/docs/make.bat index a025acb..77185b9 100644 --- a/docs/make.bat +++ b/docs/make.bat @@ -1,36 +1,36 @@ -@ECHO OFF - -pushd %~dp0 - -REM Command file for Sphinx documentation - -if "%SPHINXBUILD%" == "" ( - set SPHINXBUILD=sphinx-build -) -set SOURCEDIR=. -set BUILDDIR=_build -set SPHINXPROJ=pyXCP - -if "%1" == "" goto help - -%SPHINXBUILD% >NUL 2>NUL -if errorlevel 9009 ( - echo. - echo.The 'sphinx-build' command was not found. Make sure you have Sphinx - echo.installed, then set the SPHINXBUILD environment variable to point - echo.to the full path of the 'sphinx-build' executable. Alternatively you - echo.may add the Sphinx directory to PATH. - echo. - echo.If you don't have Sphinx installed, grab it from - echo.http://sphinx-doc.org/ - exit /b 1 -) - -%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% -goto end - -:help -%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% - -:end -popd +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=. +set BUILDDIR=_build +set SPHINXPROJ=pyXCP + +if "%1" == "" goto help + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.http://sphinx-doc.org/ + exit /b 1 +) + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% + +:end +popd diff --git a/docs/modules.rst b/docs/modules.rst index 6ac5723..8168543 100644 --- a/docs/modules.rst +++ b/docs/modules.rst @@ -1,7 +1,7 @@ -objutils -======== - -.. toctree:: - :maxdepth: 4 - - objutils +objutils +======== + +.. toctree:: + :maxdepth: 4 + + objutils diff --git a/docs/objutils.elf.rst b/docs/objutils.elf.rst index 9ee74e8..0f2f69f 100644 --- a/docs/objutils.elf.rst +++ b/docs/objutils.elf.rst @@ -1,61 +1,61 @@ -objutils.elf package -==================== - -Subpackages ------------ - -.. toctree:: - - objutils.elf.visual - -Submodules ----------- - -objutils.elf.attributes module ------------------------------- - -.. automodule:: objutils.elf.attributes - :members: - :undoc-members: - :show-inheritance: - -objutils.elf.defs module ------------------------- - -.. automodule:: objutils.elf.defs - :members: - :undoc-members: - :show-inheritance: - -objutils.elf.elfcons module ---------------------------- - -.. automodule:: objutils.elf.elfcons - :members: - :undoc-members: - :show-inheritance: - -objutils.elf.relocs module --------------------------- - -.. automodule:: objutils.elf.relocs - :members: - :undoc-members: - :show-inheritance: - -objutils.elf.testblocks module ------------------------------- - -.. automodule:: objutils.elf.testblocks - :members: - :undoc-members: - :show-inheritance: - - -Module contents ---------------- - -.. automodule:: objutils.elf - :members: - :undoc-members: - :show-inheritance: +objutils.elf package +==================== + +Subpackages +----------- + +.. toctree:: + + objutils.elf.visual + +Submodules +---------- + +objutils.elf.attributes module +------------------------------ + +.. automodule:: objutils.elf.attributes + :members: + :undoc-members: + :show-inheritance: + +objutils.elf.defs module +------------------------ + +.. automodule:: objutils.elf.defs + :members: + :undoc-members: + :show-inheritance: + +objutils.elf.elfcons module +--------------------------- + +.. automodule:: objutils.elf.elfcons + :members: + :undoc-members: + :show-inheritance: + +objutils.elf.relocs module +-------------------------- + +.. automodule:: objutils.elf.relocs + :members: + :undoc-members: + :show-inheritance: + +objutils.elf.testblocks module +------------------------------ + +.. automodule:: objutils.elf.testblocks + :members: + :undoc-members: + :show-inheritance: + + +Module contents +--------------- + +.. automodule:: objutils.elf + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/objutils.rst b/docs/objutils.rst index 4b6ff99..115de7d 100644 --- a/docs/objutils.rst +++ b/docs/objutils.rst @@ -1,236 +1,236 @@ -objutils package -================ - -Subpackages ------------ - -.. toctree:: - - objutils.coff - objutils.dwarf - objutils.elf - objutils.tests - -Submodules ----------- - - -objutils.ash module -------------------- - -.. automodule:: objutils.ash - :members: - :undoc-members: - :show-inheritance: - -objutils.binfile module ------------------------ - -.. automodule:: objutils.binfile - :members: - :undoc-members: - :show-inheritance: - - -objutils.cc2vmc module ----------------------- - -.. automodule:: objutils.cc2vmc - :members: - :undoc-members: - :show-inheritance: - -objutils.checksums module -------------------------- - -.. automodule:: objutils.checksums - :members: - :undoc-members: - :show-inheritance: - -objutils.cosmac module ----------------------- - -.. automodule:: objutils.cosmac - :members: - :undoc-members: - :show-inheritance: - -objutils.emon52 module ----------------------- - -.. automodule:: objutils.emon52 - :members: - :undoc-members: - :show-inheritance: - -objutils.etek module --------------------- - -.. automodule:: objutils.etek - :members: - :undoc-members: - :show-inheritance: - -objutils.exceptions module --------------------------- - -.. automodule:: objutils.exceptions - :members: - :undoc-members: - :show-inheritance: - -objutils.fpc module -------------------- - -.. automodule:: objutils.fpc - :members: - :undoc-members: - :show-inheritance: - -objutils.hexdiff module ------------------------ - -.. automodule:: objutils.hexdiff - :members: - :undoc-members: - :show-inheritance: - -objutils.hexdump module ------------------------ - -.. automodule:: objutils.hexdump - :members: - :undoc-members: - :show-inheritance: - -objutils.hexfile module ------------------------ - -.. automodule:: objutils.hexfile - :members: - :undoc-members: - :show-inheritance: - -objutils.ihex module --------------------- - -.. automodule:: objutils.ihex - :members: - :undoc-members: - :show-inheritance: - -objutils.image module ---------------------- - -.. automodule:: objutils.image - :members: - :undoc-members: - :show-inheritance: - -objutils.logger module ----------------------- - -.. automodule:: objutils.logger - :members: - :undoc-members: - :show-inheritance: - -objutils.mostec module ----------------------- - -.. automodule:: objutils.mostec - :members: - :undoc-members: - :show-inheritance: - - -objutils.pickleif module ------------------------- - -.. automodule:: objutils.pickleif - :members: - :undoc-members: - :show-inheritance: - -objutils.rca module -------------------- - -.. automodule:: objutils.rca - :members: - :undoc-members: - :show-inheritance: - -objutils.readers module ------------------------ - -.. automodule:: objutils.readers - :members: - :undoc-members: - :show-inheritance: - -objutils.registry module ------------------------- - -.. automodule:: objutils.registry - :members: - :undoc-members: - :show-inheritance: - -objutils.section module ------------------------ - -.. automodule:: objutils.section - :members: - :undoc-members: - :show-inheritance: - -objutils.sig module -------------------- - -.. automodule:: objutils.sig - :members: - :undoc-members: - :show-inheritance: - -objutils.srec module --------------------- - -.. automodule:: objutils.srec - :members: - :undoc-members: - :show-inheritance: - -objutils.tek module -------------------- - -.. automodule:: objutils.tek - :members: - :undoc-members: - :show-inheritance: - - -objutils.titxt module ---------------------- - -.. automodule:: objutils.titxt - :members: - :undoc-members: - :show-inheritance: - -objutils.utils module ---------------------- - -.. automodule:: objutils.utils - :members: - :undoc-members: - :show-inheritance: - - -Module contents ---------------- - -.. automodule:: objutils - :members: - :undoc-members: - :show-inheritance: +objutils package +================ + +Subpackages +----------- + +.. toctree:: + + objutils.coff + objutils.dwarf + objutils.elf + objutils.tests + +Submodules +---------- + + +objutils.ash module +------------------- + +.. automodule:: objutils.ash + :members: + :undoc-members: + :show-inheritance: + +objutils.binfile module +----------------------- + +.. automodule:: objutils.binfile + :members: + :undoc-members: + :show-inheritance: + + +objutils.cc2vmc module +---------------------- + +.. automodule:: objutils.cc2vmc + :members: + :undoc-members: + :show-inheritance: + +objutils.checksums module +------------------------- + +.. automodule:: objutils.checksums + :members: + :undoc-members: + :show-inheritance: + +objutils.cosmac module +---------------------- + +.. automodule:: objutils.cosmac + :members: + :undoc-members: + :show-inheritance: + +objutils.emon52 module +---------------------- + +.. automodule:: objutils.emon52 + :members: + :undoc-members: + :show-inheritance: + +objutils.etek module +-------------------- + +.. automodule:: objutils.etek + :members: + :undoc-members: + :show-inheritance: + +objutils.exceptions module +-------------------------- + +.. automodule:: objutils.exceptions + :members: + :undoc-members: + :show-inheritance: + +objutils.fpc module +------------------- + +.. automodule:: objutils.fpc + :members: + :undoc-members: + :show-inheritance: + +objutils.hexdiff module +----------------------- + +.. automodule:: objutils.hexdiff + :members: + :undoc-members: + :show-inheritance: + +objutils.hexdump module +----------------------- + +.. automodule:: objutils.hexdump + :members: + :undoc-members: + :show-inheritance: + +objutils.hexfile module +----------------------- + +.. automodule:: objutils.hexfile + :members: + :undoc-members: + :show-inheritance: + +objutils.ihex module +-------------------- + +.. automodule:: objutils.ihex + :members: + :undoc-members: + :show-inheritance: + +objutils.image module +--------------------- + +.. automodule:: objutils.image + :members: + :undoc-members: + :show-inheritance: + +objutils.logger module +---------------------- + +.. automodule:: objutils.logger + :members: + :undoc-members: + :show-inheritance: + +objutils.mostec module +---------------------- + +.. automodule:: objutils.mostec + :members: + :undoc-members: + :show-inheritance: + + +objutils.pickleif module +------------------------ + +.. automodule:: objutils.pickleif + :members: + :undoc-members: + :show-inheritance: + +objutils.rca module +------------------- + +.. automodule:: objutils.rca + :members: + :undoc-members: + :show-inheritance: + +objutils.readers module +----------------------- + +.. automodule:: objutils.readers + :members: + :undoc-members: + :show-inheritance: + +objutils.registry module +------------------------ + +.. automodule:: objutils.registry + :members: + :undoc-members: + :show-inheritance: + +objutils.section module +----------------------- + +.. automodule:: objutils.section + :members: + :undoc-members: + :show-inheritance: + +objutils.sig module +------------------- + +.. automodule:: objutils.sig + :members: + :undoc-members: + :show-inheritance: + +objutils.srec module +-------------------- + +.. automodule:: objutils.srec + :members: + :undoc-members: + :show-inheritance: + +objutils.tek module +------------------- + +.. automodule:: objutils.tek + :members: + :undoc-members: + :show-inheritance: + + +objutils.titxt module +--------------------- + +.. automodule:: objutils.titxt + :members: + :undoc-members: + :show-inheritance: + +objutils.utils module +--------------------- + +.. automodule:: objutils.utils + :members: + :undoc-members: + :show-inheritance: + + +Module contents +--------------- + +.. automodule:: objutils + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/requirements.txt b/docs/requirements.txt index 4c3b7d4..c40c911 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,7 +1,7 @@ -sphinx>=4.3.2 -sphinx-rtd-theme -sphinx-autobuild -sphinx-autodoc-typehints -pydata_sphinx_theme -sphinx-copybutton +sphinx>=4.3.2 +sphinx-rtd-theme +sphinx-autobuild +sphinx-autodoc-typehints +pydata_sphinx_theme +sphinx-copybutton numpydoc diff --git a/docs/scripts.rst b/docs/scripts.rst index 64adbb2..9488194 100644 --- a/docs/scripts.rst +++ b/docs/scripts.rst @@ -1,303 +1,303 @@ -Scripts provided by objutils -============================ - -``objutils`` contains some more or less useful scripts... - -oj_elf_arm_attrs ----------------- - -.. code-block:: shell - - usage: oj-elf-arm-attrs [-h] elf_file - - Dump '.ARM.attributes' section. - - positional arguments: - elf_file .elf file - - optional arguments: - -h, --help show this help message and exit - -You may run the following on your RaspberryPI: - -.. code-block:: shell - - $ oj-elf-arm-attrs /usr/bin/gcc - - - ===== - aeabi - ===== - - Name Value - Description - ------------------------------------------------------------------------------- - Tag_CPU_name 6 - 6 - - Tag_CPU_arch 6 - ARM v6 - - Tag_ARM_ISA_use 1 - The user intended that this entity could use ARM instructions - - Tag_THUMB_ISA_use 1 - The user permitted this entity to use 16-bit Thumb instructions (including BL) - - Tag_FP_arch 2 - Use of the v2 FP ISA was permitted (implies use of the v1 FP ISA) - - Tag_ABI_PCS_wchar_t 4 - The user intended the size of wchar_t to be 4 - - Tag_ABI_FP_rounding 1 - The user permitted this code to choose the IEEE 754 rounding mode at run time - - Tag_ABI_FP_denormal 1 - The user permitted this code to choose the IEEE 754 rounding mode at run time - - Tag_ABI_FP_exceptions 1 - The user permitted this code to check the IEEE 754 inexact exception - - Tag_ABI_FP_number_model 3 - The user permitted this code to use all the IEEE 754-defined FP encodings - - Tag_ABI_align_needed 1 - Code was permitted to depend on the 8-byte alignment of 8-byte data items - - Tag_ABI_align8_preserved 1 - Code was required to preserve 8-byte alignment of 8-byte data objects - - Tag_ABI_enum_size 2 - The user intended Enum containers to be 32-bit - - Tag_ABI_VFP_args 1 - The user intended FP parameter/result passing to conform to AAPCS, VFP variant - - Tag_CPU_unaligned_access 1 - The user intended that this entity might make v6-style unaligned data accesses - - -oj_elf_extract --------------- - -Extract sections from *ELF* suitible for flashing; - -.. code-block:: shell - - Extract sections contributing to program image, e.g. for flash programming - applications. - - positional arguments: - elf_file ELF file - output_file_name Output filename. - - optional arguments: - -h, --help show this help message and exit - -j, --join Try to make continuous sections (merge adjacent ranges) - -t {ihex,shf,srec,titxt}, --file-type {ihex,shf,srec,titxt} - Type of output HEX file (default: ihex) - -e EXCLUDE, --exclude_pattern EXCLUDE - Exclude sections matching a Python regex - -i INCLUDE, --include_pattern INCLUDE - Include only sections matching a Python regex - -For example: - -.. code-block:: shell - - $ oj-elf-extract sample_proj.elf sample_proj.srec -t srec - - Extracting from... - - Section Address Length - --------------------------------------------- - .text 0x00000000 46652 - .rodata 0x0000b640 2328 - .data 0x40002000 1996 - .sdata 0x400027cc 16 - .eh_frame 0x400027dc 92 - --------------------------------------------- - HEX image written to: 'sample_proj.srec' [51084 total bytes] - - - -oj_elf_info ------------ - -.. code-block:: shell - - usage: oj-elf-info [-h] [-k] [-l LOGLEVEL] [-S] [-u] elf_file - - Display informations about ELF files. - - positional arguments: - elf_file ELF file - - optional arguments: - -h, --help show this help message and exit - -k keep directory; otherwise create db in current directory - -l LOGLEVEL loglevel [warn | info | error | debug] - -S, --sections, --section-headers - Display the sections' headers. - -u Generate UTF-8 encoded output (otherwise Latin-1). - -Example: - -.. code-block:: shell - - oj-elf-info build/app.elf - -This prints ELF class, type, machine, byte-order, OS/ABI, followed by a sections table and common notes/comments when present. - -oj_elf_syms ------------ - -.. code-block:: shell - - usage: oj-elf-syms [-h] [-s SECTIONS] [-p PATTERN] [-t TYPES] - [-a ACCESS] [-b BINDINGS] [-o {N,V}] elf_file - - Display ELF symbols. - - positional arguments: - elf_file ELF file - - optional arguments: - -h, --help show this help message and exit - -s SECTIONS, --sections SECTIONS - Use only symbols from listed sections (comma-separated) - -p PATTERN, --pattern PATTERN - Only display symbols matching a (Python) regex - -t TYPES, --types TYPES - Use only symbols with listed types (comma-separated) - -a ACCESS, --access ACCESS - Filter by access flags: A (allocate), W (write), X (execute) - -b BINDINGS, --bindings BINDINGS - Use only symbols with listed bindings (comma-separated) - -o {N,V}, --order-by {N,V} - Order symbols by Name or Value (default: V) - -Examples: - -.. code-block:: shell - - # All symbols ordered by address - oj-elf-syms build/app.elf -o V - - # Only functions from .text, ordered by name - oj-elf-syms build/app.elf -s .text -t FUNC -o N - - # Filter by regex and show only GLOBAL bindings that are executable - oj-elf-syms build/app.elf -p '^(reset|_?start)$' -b GLOBAL -a X - -oj_hex_info ------------ - -.. code-block:: shell - - usage: oj-hex-info [-h] [-d] - {ash,cosmac,emon52,etek,fpc,ihex,mostec,rca,shf,sig,srec,tek,titxt} - hex_file - - Displays informations about HEX files. - - positional arguments: - {ash,cosmac,emon52,etek,fpc,ihex,mostec,rca,shf,sig,srec,tek,titxt} - file type - hex_file HEX file - - optional arguments: - -h, --help show this help message and exit - -d, --dump hexdump contents - -Filetype is a required argument (no auto-probing yet). - -Run it as follows: - -Without any optional arguments just the addresses and lengths of the contained sections are shown: - -.. code-block:: shell - - $ oj_hex_info srec sample.srec - - -------- - - Num Address Length - ------------------------------------------------------------------------------- - 000 0x00001000 16 - 001 0x00002000 16 - ------------------------------------------------------------------------------- - 32 total bytes - -If you also want to see the contents, add *-d* option: - -.. code-block:: shell - - $ oj_hex_info srec sample.srec -d - - Sections - -------- - - Num Address Length - ------------------------------------------------------------------------------- - 000 0x00001000 16 - 001 0x00002000 16 - ------------------------------------------------------------------------------- - 32 total bytes - - Section #0000 - ------------- - 00001000 48 65 6c 6c 6f 20 48 45 58 20 77 6f 72 6c 64 21 |Hello HEX world!| - --------------- - 16 bytes - --------------- - - Section #0001 - ------------- - 00002000 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 |................| - --------------- - 16 bytes - --------------- - -arduino_build_artifacts ------------------------ - -Locate Arduino build artifacts (ELF/HEX/EEP/MAP) produced by the Arduino IDE for a given sketch. -You can pass either the path to a .ino file or the sketch directory. - -.. code-block:: shell - - usage: arduino-build-artifacts [-h] [--only {DIRECTORY,ELF,HEX,EEP,MAP} ...] - [--as-paths] [--missing-ok] [--quiet] - sketch - - positional arguments: - sketch Path to the sketch directory or .ino file - - options: - -h, --help show this help message and exit - --only {DIRECTORY,ELF,HEX,EEP,MAP} ... - Limit output to specific artifact types (may be given multiple times) - --as-paths Print only paths (one per line) without labels - --missing-ok Do not treat missing artifacts as an error; just omit them from output - -q, --quiet Suppress non-error output - -Examples: - -.. code-block:: shell - - # Show all available artifacts with labels - $ arduino-build-artifacts MySketch/MySketch.ino - DIRECTORY: C:\\Users\\\\AppData\\Local\\arduino\\sketches\\ABCD1234... - ELF : C:\\...\\MySketch.ino.elf - HEX : C:\\...\\MySketch.ino.hex - MAP : C:\\...\\MySketch.ino.map - - # Print only the ELF and HEX paths, one per line - $ arduino-build-artifacts MySketch --only ELF HEX --as-paths - C:\\...\\MySketch.ino.elf - C:\\...\\MySketch.ino.hex - - # Ignore missing artifacts (e.g., no EEP generated) - $ arduino-build-artifacts MySketch --only ELF EEP --missing-ok +Scripts provided by objutils +============================ + +``objutils`` contains some more or less useful scripts... + +oj_elf_arm_attrs +---------------- + +.. code-block:: shell + + usage: oj-elf-arm-attrs [-h] elf_file + + Dump '.ARM.attributes' section. + + positional arguments: + elf_file .elf file + + optional arguments: + -h, --help show this help message and exit + +You may run the following on your RaspberryPI: + +.. code-block:: shell + + $ oj-elf-arm-attrs /usr/bin/gcc + + + ===== + aeabi + ===== + + Name Value + Description + ------------------------------------------------------------------------------- + Tag_CPU_name 6 + 6 + + Tag_CPU_arch 6 + ARM v6 + + Tag_ARM_ISA_use 1 + The user intended that this entity could use ARM instructions + + Tag_THUMB_ISA_use 1 + The user permitted this entity to use 16-bit Thumb instructions (including BL) + + Tag_FP_arch 2 + Use of the v2 FP ISA was permitted (implies use of the v1 FP ISA) + + Tag_ABI_PCS_wchar_t 4 + The user intended the size of wchar_t to be 4 + + Tag_ABI_FP_rounding 1 + The user permitted this code to choose the IEEE 754 rounding mode at run time + + Tag_ABI_FP_denormal 1 + The user permitted this code to choose the IEEE 754 rounding mode at run time + + Tag_ABI_FP_exceptions 1 + The user permitted this code to check the IEEE 754 inexact exception + + Tag_ABI_FP_number_model 3 + The user permitted this code to use all the IEEE 754-defined FP encodings + + Tag_ABI_align_needed 1 + Code was permitted to depend on the 8-byte alignment of 8-byte data items + + Tag_ABI_align8_preserved 1 + Code was required to preserve 8-byte alignment of 8-byte data objects + + Tag_ABI_enum_size 2 + The user intended Enum containers to be 32-bit + + Tag_ABI_VFP_args 1 + The user intended FP parameter/result passing to conform to AAPCS, VFP variant + + Tag_CPU_unaligned_access 1 + The user intended that this entity might make v6-style unaligned data accesses + + +oj_elf_extract +-------------- + +Extract sections from *ELF* suitible for flashing; + +.. code-block:: shell + + Extract sections contributing to program image, e.g. for flash programming + applications. + + positional arguments: + elf_file ELF file + output_file_name Output filename. + + optional arguments: + -h, --help show this help message and exit + -j, --join Try to make continuous sections (merge adjacent ranges) + -t {ihex,shf,srec,titxt}, --file-type {ihex,shf,srec,titxt} + Type of output HEX file (default: ihex) + -e EXCLUDE, --exclude_pattern EXCLUDE + Exclude sections matching a Python regex + -i INCLUDE, --include_pattern INCLUDE + Include only sections matching a Python regex + +For example: + +.. code-block:: shell + + $ oj-elf-extract sample_proj.elf sample_proj.srec -t srec + + Extracting from... + + Section Address Length + --------------------------------------------- + .text 0x00000000 46652 + .rodata 0x0000b640 2328 + .data 0x40002000 1996 + .sdata 0x400027cc 16 + .eh_frame 0x400027dc 92 + --------------------------------------------- + HEX image written to: 'sample_proj.srec' [51084 total bytes] + + + +oj_elf_info +----------- + +.. code-block:: shell + + usage: oj-elf-info [-h] [-k] [-l LOGLEVEL] [-S] [-u] elf_file + + Display informations about ELF files. + + positional arguments: + elf_file ELF file + + optional arguments: + -h, --help show this help message and exit + -k keep directory; otherwise create db in current directory + -l LOGLEVEL loglevel [warn | info | error | debug] + -S, --sections, --section-headers + Display the sections' headers. + -u Generate UTF-8 encoded output (otherwise Latin-1). + +Example: + +.. code-block:: shell + + oj-elf-info build/app.elf + +This prints ELF class, type, machine, byte-order, OS/ABI, followed by a sections table and common notes/comments when present. + +oj_elf_syms +----------- + +.. code-block:: shell + + usage: oj-elf-syms [-h] [-s SECTIONS] [-p PATTERN] [-t TYPES] + [-a ACCESS] [-b BINDINGS] [-o {N,V}] elf_file + + Display ELF symbols. + + positional arguments: + elf_file ELF file + + optional arguments: + -h, --help show this help message and exit + -s SECTIONS, --sections SECTIONS + Use only symbols from listed sections (comma-separated) + -p PATTERN, --pattern PATTERN + Only display symbols matching a (Python) regex + -t TYPES, --types TYPES + Use only symbols with listed types (comma-separated) + -a ACCESS, --access ACCESS + Filter by access flags: A (allocate), W (write), X (execute) + -b BINDINGS, --bindings BINDINGS + Use only symbols with listed bindings (comma-separated) + -o {N,V}, --order-by {N,V} + Order symbols by Name or Value (default: V) + +Examples: + +.. code-block:: shell + + # All symbols ordered by address + oj-elf-syms build/app.elf -o V + + # Only functions from .text, ordered by name + oj-elf-syms build/app.elf -s .text -t FUNC -o N + + # Filter by regex and show only GLOBAL bindings that are executable + oj-elf-syms build/app.elf -p '^(reset|_?start)$' -b GLOBAL -a X + +oj_hex_info +----------- + +.. code-block:: shell + + usage: oj-hex-info [-h] [-d] + {ash,cosmac,emon52,etek,fpc,ihex,mostec,rca,shf,sig,srec,tek,titxt} + hex_file + + Displays informations about HEX files. + + positional arguments: + {ash,cosmac,emon52,etek,fpc,ihex,mostec,rca,shf,sig,srec,tek,titxt} + file type + hex_file HEX file + + optional arguments: + -h, --help show this help message and exit + -d, --dump hexdump contents + +Filetype is a required argument (no auto-probing yet). + +Run it as follows: + +Without any optional arguments just the addresses and lengths of the contained sections are shown: + +.. code-block:: shell + + $ oj_hex_info srec sample.srec + + -------- + + Num Address Length + ------------------------------------------------------------------------------- + 000 0x00001000 16 + 001 0x00002000 16 + ------------------------------------------------------------------------------- + 32 total bytes + +If you also want to see the contents, add *-d* option: + +.. code-block:: shell + + $ oj_hex_info srec sample.srec -d + + Sections + -------- + + Num Address Length + ------------------------------------------------------------------------------- + 000 0x00001000 16 + 001 0x00002000 16 + ------------------------------------------------------------------------------- + 32 total bytes + + Section #0000 + ------------- + 00001000 48 65 6c 6c 6f 20 48 45 58 20 77 6f 72 6c 64 21 |Hello HEX world!| + --------------- + 16 bytes + --------------- + + Section #0001 + ------------- + 00002000 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 |................| + --------------- + 16 bytes + --------------- + +arduino_build_artifacts +----------------------- + +Locate Arduino build artifacts (ELF/HEX/EEP/MAP) produced by the Arduino IDE for a given sketch. +You can pass either the path to a .ino file or the sketch directory. + +.. code-block:: shell + + usage: arduino-build-artifacts [-h] [--only {DIRECTORY,ELF,HEX,EEP,MAP} ...] + [--as-paths] [--missing-ok] [--quiet] + sketch + + positional arguments: + sketch Path to the sketch directory or .ino file + + options: + -h, --help show this help message and exit + --only {DIRECTORY,ELF,HEX,EEP,MAP} ... + Limit output to specific artifact types (may be given multiple times) + --as-paths Print only paths (one per line) without labels + --missing-ok Do not treat missing artifacts as an error; just omit them from output + -q, --quiet Suppress non-error output + +Examples: + +.. code-block:: shell + + # Show all available artifacts with labels + $ arduino-build-artifacts MySketch/MySketch.ino + DIRECTORY: C:\\Users\\\\AppData\\Local\\arduino\\sketches\\ABCD1234... + ELF : C:\\...\\MySketch.ino.elf + HEX : C:\\...\\MySketch.ino.hex + MAP : C:\\...\\MySketch.ino.map + + # Print only the ELF and HEX paths, one per line + $ arduino-build-artifacts MySketch --only ELF HEX --as-paths + C:\\...\\MySketch.ino.elf + C:\\...\\MySketch.ino.hex + + # Ignore missing artifacts (e.g., no EEP generated) + $ arduino-build-artifacts MySketch --only ELF EEP --missing-ok diff --git a/docs/tutorial.rst b/docs/tutorial.rst index 6a50954..c85a3a6 100644 --- a/docs/tutorial.rst +++ b/docs/tutorial.rst @@ -1,109 +1,109 @@ -Tutorial -======== - -This tutorial walks you through the basics of working with objutils: creating sections and images, -converting between HEX formats, controlling join behavior, and using typed access helpers. - -If you prefer a notebook, also see tutorial1.ipynb in the repository root (can be viewed on GitHub). - -Prerequisites -------------- - -- Install the package: ``pip install objutils`` -- Basic familiarity with Python byte sequences - -Hello, HEX world ----------------- - -Start by importing the primary entry points: - -.. code-block:: python - - from objutils import Image, Section, dump, load, dumps, loads - -Create two sections and inspect them: - -.. code-block:: python - - sec0 = Section(start_address=0x1000, data=b"Hello HEX world!") - sec1 = Section(0x2000, range(1, 17)) - - img = Image([sec0, sec1]) - img.hexdump() - -Persist as S‑Records and read back as Intel HEX: - -.. code-block:: python - - dump("srec", "example.srec", img) - img2 = load("srec", "example.srec") - dump("ihex", "example.hex", img2) - -Join vs. no-join ----------------- - -By default, consecutive sections are joined into a single section when possible. You can disable this: - -.. code-block:: python - - s0 = Section(0x100, range(1, 9)) - s1 = Section(0x108, range(9, 17)) - - img_joined = Image([s0, s1]) # default join=True - img_nojoin = Image([s0, s1], join=False) - - img_joined.hexdump() - img_nojoin.hexdump() - -Typed access (strings, numbers, arrays) ---------------------------------------- - -Use the typed helpers to read/write structured binary data with explicit endianness. - -.. code-block:: python - - img = Image([Section(0x1000, bytes(64))]) - - # Strings (C-style NUL-terminated) - img.write_string(0x1000, "Hello HEX world!") - - # Scalars with endianness - img.write_numeric(0x1010, 0x10203040, "uint32_be") - img.write_numeric(0x1014, 0x50607080, "uint32_le") - - # Arrays - img.write_numeric_array(0x1018, [0x1000, 0x2000, 0x3000], "uint16_le") - - img.hexdump() - -Supported scalar types: - -- uint8, int8 -- uint16, int16 -- uint32, int32 -- uint64, int64 -- float32, float64 - -An endianness suffix (``_be`` or ``_le``) is required. - -CLI companions --------------- - -The library ships with handy command-line tools. A few favorites: - -- ``oj-hex-info``: inspect HEX files, optionally with a hexdump (``-d``) -- ``oj-elf-extract``: extract loadable sections from an ELF to HEX (ihex/shf/srec) -- ``oj-elf-arm-attrs``: dump ``.ARM.attributes`` from an ELF - -Examples: - -.. code-block:: shell - - oj-hex-info srec example.srec -d - oj-elf-extract build/app.elf app.srec -t srec - -What next? ----------- - -- See HOW-TOs for short, task-oriented recipes. -- Explore the full API reference in the modules section. +Tutorial +======== + +This tutorial walks you through the basics of working with objutils: creating sections and images, +converting between HEX formats, controlling join behavior, and using typed access helpers. + +If you prefer a notebook, also see tutorial1.ipynb in the repository root (can be viewed on GitHub). + +Prerequisites +------------- + +- Install the package: ``pip install objutils`` +- Basic familiarity with Python byte sequences + +Hello, HEX world +---------------- + +Start by importing the primary entry points: + +.. code-block:: python + + from objutils import Image, Section, dump, load, dumps, loads + +Create two sections and inspect them: + +.. code-block:: python + + sec0 = Section(start_address=0x1000, data=b"Hello HEX world!") + sec1 = Section(0x2000, range(1, 17)) + + img = Image([sec0, sec1]) + img.hexdump() + +Persist as S‑Records and read back as Intel HEX: + +.. code-block:: python + + dump("srec", "example.srec", img) + img2 = load("srec", "example.srec") + dump("ihex", "example.hex", img2) + +Join vs. no-join +---------------- + +By default, consecutive sections are joined into a single section when possible. You can disable this: + +.. code-block:: python + + s0 = Section(0x100, range(1, 9)) + s1 = Section(0x108, range(9, 17)) + + img_joined = Image([s0, s1]) # default join=True + img_nojoin = Image([s0, s1], join=False) + + img_joined.hexdump() + img_nojoin.hexdump() + +Typed access (strings, numbers, arrays) +--------------------------------------- + +Use the typed helpers to read/write structured binary data with explicit endianness. + +.. code-block:: python + + img = Image([Section(0x1000, bytes(64))]) + + # Strings (C-style NUL-terminated) + img.write_string(0x1000, "Hello HEX world!") + + # Scalars with endianness + img.write_numeric(0x1010, 0x10203040, "uint32_be") + img.write_numeric(0x1014, 0x50607080, "uint32_le") + + # Arrays + img.write_numeric_array(0x1018, [0x1000, 0x2000, 0x3000], "uint16_le") + + img.hexdump() + +Supported scalar types: + +- uint8, int8 +- uint16, int16 +- uint32, int32 +- uint64, int64 +- float32, float64 + +An endianness suffix (``_be`` or ``_le``) is required. + +CLI companions +-------------- + +The library ships with handy command-line tools. A few favorites: + +- ``oj-hex-info``: inspect HEX files, optionally with a hexdump (``-d``) +- ``oj-elf-extract``: extract loadable sections from an ELF to HEX (ihex/shf/srec) +- ``oj-elf-arm-attrs``: dump ``.ARM.attributes`` from an ELF + +Examples: + +.. code-block:: shell + + oj-hex-info srec example.srec -d + oj-elf-extract build/app.elf app.srec -t srec + +What next? +---------- + +- See HOW-TOs for short, task-oriented recipes. +- Explore the full API reference in the modules section. diff --git a/docs/tutorial1.ipynb b/docs/tutorial1.ipynb index 147f8d3..23efe61 100644 --- a/docs/tutorial1.ipynb +++ b/docs/tutorial1.ipynb @@ -106,7 +106,7 @@ "metadata": {}, "outputs": [], "source": [ - "from objutils import Image, Section, dump, dumps, load, loads" + "from objutils import Image, Section, dump, load" ] }, { @@ -286,86 +286,86 @@ { "cell_type": "code", "execution_count": null, - "outputs": [], - "source": [], "metadata": { "collapsed": false, "pycharm": { "name": "#%%\n" } - } + }, + "outputs": [], + "source": [] }, { "cell_type": "code", "execution_count": null, - "outputs": [], - "source": [], "metadata": { "collapsed": false, "pycharm": { "name": "#%%\n" } - } + }, + "outputs": [], + "source": [] }, { "cell_type": "code", "execution_count": null, - "outputs": [], - "source": [], "metadata": { "collapsed": false, "pycharm": { "name": "#%%\n" } - } + }, + "outputs": [], + "source": [] }, { "cell_type": "code", "execution_count": null, - "outputs": [], - "source": [], "metadata": { "collapsed": false, "pycharm": { "name": "#%%\n" } - } + }, + "outputs": [], + "source": [] }, { "cell_type": "code", "execution_count": null, - "outputs": [], - "source": [], "metadata": { "collapsed": false, "pycharm": { "name": "#%%\n" } - } + }, + "outputs": [], + "source": [] }, { "cell_type": "code", "execution_count": null, - "outputs": [], - "source": [], "metadata": { "collapsed": false, "pycharm": { "name": "#%%\n" } - } + }, + "outputs": [], + "source": [] }, { "cell_type": "code", "execution_count": null, - "outputs": [], - "source": [], "metadata": { "collapsed": false, "pycharm": { "name": "#%%\n" } - } + }, + "outputs": [], + "source": [] }, { "cell_type": "code", diff --git a/objutils/binfile.py b/objutils/binfile.py index 3e06901..50a82e5 100644 --- a/objutils/binfile.py +++ b/objutils/binfile.py @@ -1,6 +1,5 @@ #!/usr/bin/env python -"""Reader/Writer for plain binfiles. -""" +"""Reader/Writer for plain binfiles.""" __version__ = "0.1.1" diff --git a/objutils/dwarf/__init__.py b/objutils/dwarf/__init__.py index e86b78c..ef6c0cf 100644 --- a/objutils/dwarf/__init__.py +++ b/objutils/dwarf/__init__.py @@ -1,6 +1,5 @@ #!/usr/bin/env python -"""DWARF4 Parser. -""" +"""DWARF4 Parser.""" __version__ = "0.1.0" __copyright__ = """ diff --git a/objutils/dwarf/sm.py b/objutils/dwarf/sm.py index b11ece5..cb02cca 100644 --- a/objutils/dwarf/sm.py +++ b/objutils/dwarf/sm.py @@ -30,7 +30,7 @@ import io from dataclasses import dataclass -from typing import Any, List +from typing import Any from construct import Array diff --git a/objutils/elf/__init__.py b/objutils/elf/__init__.py index 95fd77b..1b20fcf 100644 --- a/objutils/elf/__init__.py +++ b/objutils/elf/__init__.py @@ -1,6 +1,5 @@ #!/usr/bin/env python -"""Parser for ELF files. -""" +"""Parser for ELF files.""" __copyright__ = """ objutils - Object file library for Python. diff --git a/objutils/hexdump.py b/objutils/hexdump.py index edd7a92..30957b8 100644 --- a/objutils/hexdump.py +++ b/objutils/hexdump.py @@ -30,8 +30,9 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. """ -from typing import BinaryIO, Iterable, Sequence, TextIO import sys +from typing import TextIO +from collections.abc import Sequence def isprintable(ch: int) -> bool: diff --git a/objutils/hexfile.py b/objutils/hexfile.py index 6cf7866..cd8a51b 100644 --- a/objutils/hexfile.py +++ b/objutils/hexfile.py @@ -31,7 +31,8 @@ from dataclasses import dataclass, field from functools import partial from operator import itemgetter -from typing import Any, Dict, Iterable, Iterator, List, Mapping, MutableMapping, Optional, Sequence, Tuple, Union +from typing import Any, Dict, List, Optional, Tuple, Union +from collections.abc import Mapping, Sequence from objutils.image import Image from objutils.logger import Logger @@ -122,7 +123,7 @@ class MetaRecord: class FormatParser: def __init__(self, fmt: str, data_separator: Optional[str] = None): self.fmt: str = fmt - self.translated_format: List[Tuple[int, int, str]] = [] + self.translated_format: list[tuple[int, int, str]] = [] self.data_separator: Optional[str] = data_separator def parse(self) -> re.Pattern[str]: @@ -168,7 +169,7 @@ def translateFormat(self, group: str) -> None: class Container: def __init__(self) -> None: - self.processing_instructions: List[Any] = [] + self.processing_instructions: list[Any] = [] def add_processing_instruction(self, pi: Any) -> None: self.processing_instructions.append(pi) @@ -202,7 +203,7 @@ def __init__(self) -> None: self.stats = Statistics() # formats is a list of (format_type, compiled_pattern) if isinstance(self.FORMAT_SPEC, str): - self.formats: List[Tuple[int, re.Pattern[str]]] = [(0, FormatParser(self.FORMAT_SPEC, self.DATA_SEPARATOR).parse())] + self.formats: list[tuple[int, re.Pattern[str]]] = [(0, FormatParser(self.FORMAT_SPEC, self.DATA_SEPARATOR).parse())] elif isinstance(self.FORMAT_SPEC, (list, tuple)): self.formats = [] for format_type, format in self.FORMAT_SPEC: @@ -417,7 +418,7 @@ def dump(self, fp: Union[str, Any], image: Image, row_length: int = 16, **kws: A fp.close() def dumps(self, image: Image, row_length: int = 16, **kws: Any) -> bytes: - result: List[str] = [] + result: list[str] = [] self.row_length = row_length if hasattr(image, "sections") and not image.sections: return b"" @@ -457,7 +458,7 @@ def pre_processing(self, image: Image) -> None: pass def set_parameters(self, **kws: Any) -> None: - params: Dict[str, Any] = {} + params: dict[str, Any] = {} for k, v in kws.items(): try: params[k] = getattr(self, k) @@ -475,7 +476,7 @@ def compose_header(self, meta: Mapping[str, Any]) -> Optional[str]: def compose_footer(self, meta: Mapping[str, Any]) -> Optional[str]: return None - def word_to_bytes(self, word: int) -> Tuple[int, int]: + def word_to_bytes(self, word: int) -> tuple[int, int]: word = int(word) hi = (word & 0xFF00) >> 8 lo = word & 0x00FF @@ -496,12 +497,12 @@ def __init__(self, address_pattern: str, data_pattern: str, etx_pattern: str, se self.ADDRESS_PATTERN: re.Pattern[str] = re.compile(address_pattern, re.DOTALL | re.MULTILINE) self.ETX_PATTERN: re.Pattern[str] = re.compile(etx_pattern, re.DOTALL | re.MULTILINE) self.SPLITTER = re.compile(f"[{separators}]") - self.patterns: Sequence[Tuple[re.Pattern[str], Any]] = ( + self.patterns: Sequence[tuple[re.Pattern[str], Any]] = ( (self.ADDRESS_PATTERN, self.getAddress), (self.DATA_PATTERN, self.parse_line), (self.ETX_PATTERN, self.nop), ) - self.formats: List[Tuple[int, re.Pattern[str]]] = [ + self.formats: list[tuple[int, re.Pattern[str]]] = [ (0, self.ADDRESS_PATTERN), (1, self.DATA_PATTERN), (2, self.ETX_PATTERN), @@ -527,7 +528,7 @@ def parse_line(self, line: str, match: re.Match[str]) -> bool: def read(self, fp: Any) -> Image: lines = fp.read().decode() - self.sections: List[Section] = [] + self.sections: list[Section] = [] self.address = 0 breakRequest = False for line in lines.splitlines(): diff --git a/objutils/image.py b/objutils/image.py index 503dfb3..f663fd2 100644 --- a/objutils/image.py +++ b/objutils/image.py @@ -1,7 +1,5 @@ #!/usr/bin/env python -""" - -""" +""" """ __version__ = "0.1.0" diff --git a/objutils/registry.py b/objutils/registry.py index 4f3828e..abb3f50 100644 --- a/objutils/registry.py +++ b/objutils/registry.py @@ -24,8 +24,9 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. """ -from collections import OrderedDict, namedtuple -from typing import Iterator, MutableMapping, Any, Type, NamedTuple +from collections import OrderedDict +from typing import Any, NamedTuple, Type +from collections.abc import Iterator from objutils.utils import SingletonBase @@ -39,8 +40,8 @@ class CodecAlreadyExistError(Exception): class Codec(NamedTuple): - Reader: Type[Any] - Writer: Type[Any] + Reader: type[Any] + Writer: type[Any] description: str @@ -63,7 +64,7 @@ def get(self, name: str) -> Codec: raise CodecDoesNotExistError(name) return codec - def register(self, name: str, readerClass: Type[Any], writerClass: Type[Any], description: str = "") -> None: + def register(self, name: str, readerClass: type[Any], writerClass: type[Any], description: str = "") -> None: if name in self.codecs: raise CodecAlreadyExistError(name) self._codecs[name] = Codec(readerClass, writerClass, description) diff --git a/objutils/scripts/oj_elf_arm_attrs.py b/objutils/scripts/oj_elf_arm_attrs.py index b432f48..8eeb0e6 100644 --- a/objutils/scripts/oj_elf_arm_attrs.py +++ b/objutils/scripts/oj_elf_arm_attrs.py @@ -1,6 +1,5 @@ #!/usr/bin/env python -""" Dumps '.ARM.attributes' section in an ELF file. -""" +"""Dumps '.ARM.attributes' section in an ELF file.""" __version__ = "0.1.0" diff --git a/objutils/scripts/oj_elf_extract.py b/objutils/scripts/oj_elf_extract.py index a66f6ba..afec683 100644 --- a/objutils/scripts/oj_elf_extract.py +++ b/objutils/scripts/oj_elf_extract.py @@ -1,6 +1,5 @@ #!/usr/bin/env python -"""Extract sections contributing to program image, e.g. for flash programming applications. -""" +"""Extract sections contributing to program image, e.g. for flash programming applications.""" __copyright__ = """ objutils - Object file library for Python. diff --git a/objutils/scripts/oj_elf_import.py b/objutils/scripts/oj_elf_import.py index 6d9971f..46b3f44 100644 --- a/objutils/scripts/oj_elf_import.py +++ b/objutils/scripts/oj_elf_import.py @@ -21,7 +21,6 @@ import argparse import shutil from pathlib import Path -from typing import Optional from objutils.dwarf import DwarfProcessor from objutils.elf import ElfParser diff --git a/objutils/scripts/oj_elf_info.py b/objutils/scripts/oj_elf_info.py index ca870ab..a59627e 100644 --- a/objutils/scripts/oj_elf_info.py +++ b/objutils/scripts/oj_elf_info.py @@ -1,6 +1,5 @@ #!/usr/bin/env python -"""while the basic option are the same it is currently not intended to be another readelf clone. -""" +"""while the basic option are the same it is currently not intended to be another readelf clone.""" __version__ = "0.1.0" diff --git a/objutils/scripts/oj_elf_syms.py b/objutils/scripts/oj_elf_syms.py index c63e252..761af11 100644 --- a/objutils/scripts/oj_elf_syms.py +++ b/objutils/scripts/oj_elf_syms.py @@ -1,6 +1,5 @@ #!/usr/bin/env python -"""List symbols contained in an ELF file (but not DWARF symbols!). -""" +"""List symbols contained in an ELF file (but not DWARF symbols!).""" __copyright__ = """ objutils - Object file library for Python. diff --git a/objutils/scripts/oj_hex_info.py b/objutils/scripts/oj_hex_info.py index c053cc9..93212c8 100644 --- a/objutils/scripts/oj_hex_info.py +++ b/objutils/scripts/oj_hex_info.py @@ -1,6 +1,5 @@ #!/usr/bin/env python -"""Displays informations about HEX files. -""" +"""Displays informations about HEX files.""" __version__ = "0.1.0" diff --git a/objutils/section.py b/objutils/section.py index 3b13697..648c5d9 100644 --- a/objutils/section.py +++ b/objutils/section.py @@ -1,6 +1,5 @@ #!/usr/bin/env python -""" -""" +""" """ __version__ = "0.1.0" @@ -243,7 +242,7 @@ def hexdump(self, fp=sys.stdout): def tobytes(self) -> bytes: return array("B", self.data).tobytes() - def tolist(self) -> List[int]: + def tolist(self) -> list[int]: return array("B", self.data).tolist() def _verify_dtype(self, dtype: str) -> str: @@ -339,7 +338,7 @@ def write_numeric(self, addr: int, value: Union[int, float], dtype: str, **kws) self.data[offset : offset + data_size] = struct.pack(fmt, value) - def read_numeric_array(self, addr: int, length: int, dtype: str, **kws) -> Union[List[int], List[float]]: + def read_numeric_array(self, addr: int, length: int, dtype: str, **kws) -> Union[list[int], list[float]]: offset = addr - self.start_address if offset < 0: raise InvalidAddressError(f"read_numeric_array(0x{addr:08x}) access out of bounds.") @@ -350,7 +349,7 @@ def read_numeric_array(self, addr: int, length: int, dtype: str, **kws) -> Union data = self.data[offset : offset + data_size] return struct.unpack(fmt, data) - def write_numeric_array(self, addr: int, data: Union[List[int], List[float]], dtype: str, **kws) -> None: + def write_numeric_array(self, addr: int, data: Union[list[int], list[float]], dtype: str, **kws) -> None: if not hasattr(data, "__iter__"): raise TypeError("data must be iterable") length = len(data) @@ -447,7 +446,7 @@ def address(self) -> int: # Alias return self.start_address -def join_sections(sections: List[Section]) -> List[Section]: +def join_sections(sections: list[Section]) -> list[Section]: result_sections = [] sections.sort(key=attrgetter("start_address")) prev_section = Section() diff --git a/objutils/shf.py b/objutils/shf.py index 437c6aa..f55b8b8 100644 --- a/objutils/shf.py +++ b/objutils/shf.py @@ -1,6 +1,5 @@ #!/usr/bin/env python -"""Reader/Writer S Hexdump Format (rfc4149). -""" +"""Reader/Writer S Hexdump Format (rfc4149).""" __version__ = "0.1.1" diff --git a/objutils/srec.py b/objutils/srec.py index e662ac1..9763ebd 100644 --- a/objutils/srec.py +++ b/objutils/srec.py @@ -28,7 +28,8 @@ import re from functools import partial -from typing import Any, Mapping, Optional, Sequence +from typing import Any, Optional +from collections.abc import Mapping, Sequence import objutils.hexfile as hexfile import objutils.utils as utils