pyaddlicense
pyaddlicense adds license headers to any source file it finds that does not have one. By default it respects .gitignore and doesn't touch autogenerated files.
It is inspired by addlicense, but includes more features and can be used in environments that might not have go or docker.
Default Example:
pyaddlicense -o 'Example Company'
Installation
We reccomend installing pyaddlicense globally via pipx so that it remains in an isolated environment:
pipx install pyaddlicense
However, pip should also work if you want to include it solely in your local venv:
pip install pyaddlicense
Usage and flags
Default
By default, only the -o (or --owner) flag is required to say who the holder/owner of the license is:
pyaddlicense -o 'Example Company'
This will recursively search every file and every directory from the current one and add the default license to every file where a license is missing any the file isn't autogenerated. This will respect any .gitignore entries.
The default license is: (c) Copyright {{ .HOLDER }} {{ .YEAR }}. All rights reserved. where both {{ .HOLDER }} and {{ .YEAR }} are macros that will be replaced by the string given as -o and the current year respectively.
Check mode
If you just want to see what files are missing licenses, you can use the -c (or --check) flag:
pyaddlicense -o 'Example Company' -c
Custom Ignore
You can additional files or folders to ignore with the -i (or --ignore) flag:
pyaddlicense -o 'Example Company' -i .flake8 -i pyproject.toml
NOTE: This will be additional to .gitignore, if you want to disable .gitignore checking and completely manage the ignore rules yourself, also set --ignore-gitignore=0.
Custom license
If you want to use your own license, there are two options.
Option 1: Use the -l flag to pass the license as a string (which can also include macros, as detailed in the Default section):
pyaddlicense -o 'Example Company' -l '{{ .HOLDER }} {{ .YEAR }}. Absolutely no rights reserved and no warranty given.'
Option 2: Use the -f flag to pass the license as a file (which can also include macros, as detailed in the Default section):
pyaddlicense -o 'Example Company' -f ~/licenses/norightsreserved.tpl
Silent mode
You can disable console output via the -s (or --silent) flag. This is useful for integrating pyaddlicense into a linting/CI pipeline without warping the logs too much:
pyaddlicense -o 'Example Company' -c -s
(When running in check mode (detailed above), pyaddlicense will have a non-zero exit code if files are found that need changes)
Development
NOTE: Local development requires poetry to be installed.
Clone this repo:
git clone https://github.com/kixa/pyaddlicense
Install our dependencies:
poetry install
Testing:
Run the tests via:
poetry run pytest
Linting:
Lint any changes with:
poetry run black src/ tests/ && poetry run flake8 src/ tests/ && poetry run isort src/ tests/
Metadata
Release files for pyaddlicense 0.3.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 | |
|---|---|---|---|
| pyaddlicense-0.3.0.tar.gz | 10.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyaddlicense-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 20.1 kB
Release files / pyaddlicense-0.3.0.tar.gz
| Download URL | pyaddlicense-0.3.0.tar.gz |
|---|---|
| Size | 10.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
daa548ebe8182994b5a681ed230e08d50a9bcc6fb129e001507d42512a760553
|
|
BLAKE2b-256 checksum How to use checksums |
29deebd0dc723f238c81d2420f7f1564872411414cdd316a888e26eb1f97ddc6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.5.1 CPython/3.10.9 Darwin/22.6.0
|
Release files / pyaddlicense-0.3.0-py3-none-any.whl
| Download URL | pyaddlicense-0.3.0-py3-none-any.whl |
|---|---|
| Size | 10.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a1ec31d3422798941ba0d236e4125be78277d07a5eabd28b5e091952cefb1ccf
|
|
BLAKE2b-256 checksum How to use checksums |
dede4804e3ccf2b93278bf2b28b0d12f8eb1cb699cc979b4277c8a036d4efdb7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.5.1 CPython/3.10.9 Darwin/22.6.0
|