Skip to content

Commit f6cd42b

Browse files
authored
Merge pull request #10 from Decompollaborate/develop
2.1.2
2 parents fc1596b + d64920d commit f6cd42b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+4639427
-75
lines changed

.github/workflows/tests.yml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Tests cases
2+
3+
# Build on every branch push, tag push, and pull request change:
4+
on: [push, pull_request]
5+
6+
jobs:
7+
tests_cases:
8+
name: Tests cases
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- uses: actions/checkout@v3
13+
14+
- name: Install local mapfile_parser
15+
run: pip install .
16+
17+
- name: Update tests outputs
18+
run: python3 tests/update_outputs.py
19+
20+
- name: Check if there are any changes in the test cases
21+
id: tests_changes
22+
uses: tj-actions/verify-changed-files@v14
23+
24+
- name: tables changes
25+
if: steps.tests_changes.outputs.files_changed == 'true'
26+
run: |
27+
echo "Changed files: ${{ steps.tests_changes.outputs.changed_files }}"
28+
echo "Please install the latest changes, run \`python3 tests/update_outputs.py\`, check the changes are desirable and commit the result"
29+
exit 1

.gitignore

-3
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,3 @@ cython_debug/
165165
#
166166
.vscode/
167167

168-
169-
tests
170-

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
[project]
55
name = "mapfile_parser"
6-
version = "2.1.1"
6+
version = "2.1.2.dev1"
77
description = "Map file parser library focusing decompilation projects"
88
readme = "README.md"
99
requires-python = ">=3.7"

src/mapfile_parser/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
from __future__ import annotations
77

8-
__version_info__ = (2, 1, 1)
9-
__version__ = ".".join(map(str, __version_info__))
8+
__version_info__ = (2, 1, 2)
9+
__version__ = ".".join(map(str, __version_info__)) + ".dev1"
1010
__author__ = "Decompollaborate"
1111

1212
from . import utils as utils

src/mapfile_parser/frontends/jsonify.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
from .. import mapfile
1313

1414

15-
def doJsonify(mapPath: Path, outputPath: Path|None) -> int:
15+
def doJsonify(mapPath: Path, outputPath: Path|None, humanReadable: bool=True) -> int:
1616
mapFile = mapfile.MapFile()
1717
mapFile.readMapFile(mapPath)
1818

19-
jsonStr = json.dumps(mapFile.toJson(), indent=4)
19+
jsonStr = json.dumps(mapFile.toJson(humanReadable=humanReadable), indent=4)
2020

2121
if outputPath is None:
2222
print(jsonStr)
@@ -30,13 +30,15 @@ def doJsonify(mapPath: Path, outputPath: Path|None) -> int:
3030
def processArguments(args: argparse.Namespace):
3131
mapPath: Path = args.mapfile
3232
outputPath: Path|None = Path(args.output) if args.output is not None else None
33+
machine: bool = args.machine
3334

34-
exit(doJsonify(mapPath, outputPath))
35+
exit(doJsonify(mapPath, outputPath, humanReadable=not machine))
3536

3637
def addSubparser(subparser: argparse._SubParsersAction[argparse.ArgumentParser]):
3738
parser = subparser.add_parser("jsonify", help="Converts a mapfile into a json format.")
3839

3940
parser.add_argument("mapfile", help="Path to a map file", type=Path)
4041
parser.add_argument("-o", "--output", help="Output path of for the generated json. If omitted then stdout is used instead.")
42+
parser.add_argument("-m", "--machine", help="Emit numbers as numbers instead of outputting them as pretty strings.", action="store_true")
4143

4244
parser.set_defaults(func=processArguments)

src/mapfile_parser/frontends/symbol_sizes_csv.py

+28-8
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,44 @@
1111
from .. import mapfile
1212

1313

14-
def processArguments(args: argparse.Namespace):
14+
def doSymbolSizesCsv(mapPath: Path, outputPath: Path|None, filterSection: str|None=None, sameFolder: bool=False, symbolsSummary: bool=False, allFiles: bool=False) -> int:
1515
mapFile = mapfile.MapFile()
16-
mapFile.readMapFile(args.mapfile)
17-
if args.filter_section is not None:
18-
mapFile = mapFile.filterBySectionType(args.filter_section)
16+
mapFile.readMapFile(mapPath)
17+
18+
if filterSection is not None:
19+
mapFile = mapFile.filterBySectionType(filterSection)
1920

20-
if args.same_folder:
21+
if sameFolder:
2122
mapFile = mapFile.mixFolders()
2223

23-
if args.symbols:
24-
mapFile.printSymbolsCsv()
24+
if symbolsSummary:
25+
output = mapFile.toCsvSymbols()
26+
else:
27+
output = mapFile.toCsv(printVram=not sameFolder, skipWithoutSymbols=not allFiles)
28+
29+
if outputPath is None:
30+
print(output)
2531
else:
26-
mapFile.printAsCsv(printVram=not args.same_folder, skipWithoutSymbols=not args.all)
32+
outputPath.parent.mkdir(parents=True, exist_ok=True)
33+
outputPath.write_text(output)
34+
35+
return 0
36+
37+
def processArguments(args: argparse.Namespace):
38+
mapPath: Path = args.mapfile
39+
outputPath: Path|None = Path(args.output) if args.output is not None else None
40+
filterSection: str|None = args.filter_section
41+
sameFolder: bool = args.same_folder
42+
symbolsSummary: bool = args.symbols
43+
allFiles: bool = args.all
44+
45+
exit(doSymbolSizesCsv(mapPath, outputPath, filterSection, sameFolder, symbolsSummary, allFiles))
2746

2847
def addSubparser(subparser: argparse._SubParsersAction[argparse.ArgumentParser]):
2948
parser = subparser.add_parser("symbol_sizes_csv", help="Produces a csv summarizing the files sizes by parsing a map file.")
3049

3150
parser.add_argument("mapfile", help="Path to a map file", type=Path)
51+
parser.add_argument("-o", "--output", help="Output path of for the generated csv. If omitted then stdout is used instead.")
3252
parser.add_argument("--same-folder", help="Mix files in the same folder.", action="store_true")
3353
parser.add_argument("--symbols", help="Prints the size of every symbol instead of a summary.", action="store_true")
3454
parser.add_argument("-a", "--all", help="Don't skip files without symbols.", action="store_true")

0 commit comments

Comments
 (0)