The Python Files Merger is a tool that seamlessly combines multiple Python files into a single, well-organized unit while automatically handling imports, checking definition collisions, and resolving dependencies. It can be used to merge standard Python files but works especially well hadnling files designed for microcontrollers. The package supports Python, MicroPython, and CircuitPython files.
python -m pymerger src/*
or
python -m pymerger src/lorem.py src/ipsum.py
You can see shell option with python -m pymerger -h
import pymerger
pymerger.merge(["src/**"], output="merged_files.py")
The function also returns the raw string, so you could do:
import pymerger
output_string = pymerger.merge(["src/**"])
print(output_string)
Only optional parameter is "output", that lets you choose where the output should be saved.
You can download the repo and run the merger with python -m pymerger <files_to_merge>
pylint pymerger
You can click on the tests badge to check the tests status
pytest
You can clickon the coverage badge to check the code coverage
coverage run --source=pymerger -m unittest discover && coverage report
Right now, badges are generated locally and uploaded to github, we should really do this in github workflows.
To generate reports and badges:
python genbadges.py
- Update pymerger version in
pymerger/__init__.py
. - Run
python setup.py sdist
to create the dist tar which will be uploadad to pip. - Run
python -m twine upload dist/$(ls dist | tail -n 1)
to upload the most up to date tar folder in the sir directory.