Skip to content

Commit

Permalink
add variable processing support
Browse files Browse the repository at this point in the history
  • Loading branch information
lmbsog0 committed Jul 5, 2023
1 parent 5ee1747 commit 197c503
Show file tree
Hide file tree
Showing 12 changed files with 1,520 additions and 281 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v2
- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
uses: docker/login-action@v2
with:
registry: ${{env.REGISTRY}}
username: ${{secrets.PKG_REGISTRY_USERNAME}}
password: ${{secrets.PKG_REGISTRY_RW_TOKEN}}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
uses: docker/metadata-action@v4
with:
images: ${{env.REGISTRY}}/${{env.IMAGE_NAME}}
- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
uses: docker/build-push-action@v4
with:
context: .
push: true
Expand Down Expand Up @@ -74,7 +74,7 @@ jobs:
name: test_inputs
path: tests
- name: Run pytest tests
run: python3 -m pytest $(pwd) -v --cov src/pyelf --cov-report=xml --verbose --cov-fail-under 90
run: python3 -m pytest $(pwd) -v --cov src/pyelf --cov-report=xml --verbose --cov-fail-under 80
- name: Upload code coverage to Codecov
uses: codecov/codecov-action@v2
with:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ tests/*.asm
tests/*.bin
tests/*.elf
tests/*.map
**/__pycache__/
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.1
0.1.2
20 changes: 15 additions & 5 deletions src/pyelf/cli.py → src/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
"""

import argparse
import json

from .pyelf import ElfFile
from pyelf.parser import ElfFile


def main():
parser = argparse.ArgumentParser(prog='pya2l', description='python command line utility for elf-formatted files.')
parser.add_argument('input_file', help='input file path')
parser.add_argument('output_file', type=argparse.FileType('wb'), help='output file path')
parser.add_argument('-O',
dest='output_format',
metavar='output format',
Expand All @@ -24,9 +24,19 @@ def main():
args = parser.parse_args()

elf = ElfFile(args.input_file)

if args.output_format == 'binary':
args.output_file.write(elf.binary)
result = list()
for variable in elf.variables():
# result.append(variable.to_json())
try:
result.append(variable.to_json())
except RecursionError as e:
print(f'{variable.name} | {str(e)}')
continue
with open('output2.json', 'w') as fp:
json.dump(result, fp, indent=2, sort_keys=True)

# if args.output_format == 'binary':
# args.output_file.write(elf.binary)


if __name__ == '__main__':
Expand Down
5 changes: 3 additions & 2 deletions src/pyelf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
__url__ = 'http://www.github.com/Sauci/pyelf'
__description__ = ''
__long_description__ = ''''''
import os
import sys

from .cli import main
from .pyelf import Address, ElfException, ElfFile, Symbol
sys.path.append(os.path.dirname(__file__))
Loading

0 comments on commit 197c503

Please sign in to comment.