autocopyright
Autocopyright is a script which was designed to automatically add copyright notices at
the top of source files. It uses jinja2 templates which can be automatically filled with
values pulled from pyproject.toml and other files.
Example
To run autocopyright you must specify comment sign, directory to traverse, glob patterns of files to modify and path to license template.
autocopyright -s "#" -d autocopyright -g "*.py" -g "*.pyi" -l "./templates/MIT.md.jinja2"
Templates
Autocopyright uses Jinja2 templates to determine content of copyright header. Such template is loaded from predefined destination and rendered with few special variables available. Those variables are listed below:
-
now-datetime.datetimeobject holding current time (determined once, at the beginning of script execution) -
pyproject- dictionary-like object holding loaded content ofpyproject.tomlfile loaded from current working directory of script.
Template for LGPL-3.0 license could look like this:
Copyright {{ now.year }} {{ pyproject.tool.poetry.authors[0] }}
This file is part of {{ pyproject.tool.poetry["name"] }}.
{{ pyproject.tool.poetry.repository }}
{{ pyproject.tool.poetry["name"] }} is free software: you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at your option)
any later version.
{{ pyproject.tool.poetry["name"] }} is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General Public License
along with {{ pyproject.tool.poetry["name"] }}. If not, see <http://www.gnu.org/licenses/>.
Pre-commit hook
To add this script as pre commit hook, create .pre-commit-config.yaml file, or append
to existing one, following lines:
repos:
- repo: https://github.com/Argmaster/autocopyright
rev: "v1.1.0"
hooks:
- id: autocopyright
args:
[
-s,
"#",
-d,
<your-project-source-dir-name>,
-g,
"*.py",
-l,
<path-to-license-template>,
]
Replace <your-project-source-dir-name> with valid name of your project source
directory, for example source or src.
Replace <path-to-license-template> with path to jinja2 template file containing
license note, eg. "./templates/LGPL3.md.jinja2". See Templates section for example
of template content.
Metadata
Release files for autocopyright 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| autocopyright-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for autocopyright-1.1.0-py3-none-any.whl |
Release files / autocopyright-1.1.0-py3-none-any.whl
| Download URL | autocopyright-1.1.0-py3-none-any.whl |
|---|---|
| Size | 7.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5f8f257c29d01a7a4a9dd8c2c3d8c982d2eef3ec40d6118d8775a71966db94a1
|
|
BLAKE2b-256 checksum How to use checksums |
d052a9ed095243043fd714d3c8f0583a25ee553d2453f13b80e3467ad34e4c80
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.8
|
Security for autocopyright 1.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.