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.
Usage
Shell example
python -m pymerger src/*
or
python -m pymerger src/lorem.py src/ipsum.py
You can see shell option with python -m pymerger -h
File example
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.
Contributing
Developing
You can download the repo and run the merger with python -m pymerger <files_to_merge>
Lint
pylint pymerger
Tests
You can click on the tests badge to check the tests status
pytest
Coverage
You can clickon the coverage badge to check the code coverage
coverage run --source=pymerger -m unittest discover && coverage report
Reports and badges
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
Upload to pip
- Update pymerger version in
pymerger/__init__.py. - Run
python setup.py sdistto 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.
Metadata
Release files for pymerger 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pymerger-1.0.0.tar.gz | 13.4 kB | Details |
Release files / pymerger-1.0.0.tar.gz
| Download URL | pymerger-1.0.0.tar.gz |
|---|---|
| Size | 13.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
311cbc6972d72d26e392f8f2740d346be4631f0d91d41b561aec8170346fdf0b
|
|
BLAKE2b-256 checksum How to use checksums |
dea4708263bc3759c72582dce4344ac702158997fb1c0e9d601db4c95bf90768
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.10
|