A tool to update, change or add license headers to all files of any of the supported types in or below some directory.
Currently, the following file types are supported: Java/Scala/Groovy, bash/sh/csh, ...
usage: licenseheaders.py [-h] [-v] [-V] [-d directory] [-t template] [-y years] [-b] [-a] [-c copyrightOwner] License Header Updater positional arguments: none optional arguments: -h, --help show this help message and exit -V, --version show program's version number and exit -v, --verbose increases log verbosity (can be specified multiple times) -d, --dir directory to process, all subdirectories will be included -t, --tmpl template name or file to use (if not specified, -y must be specified) -y, --years if template is specified, the year to substitute, otherwise this year or year range will replace any existing year in existing headers. Replaces variable ${years} in a template -b, --backup for each file that gets changed, create a backup of the original with the additional filename extension .bak -c, --cr copyright owner, replaces variable ${owner} in a template -a, --addonly add a header to all supported file types, ignore any existing headers. Examples: # Add a new license header or replace any existing one based on the lgpl3 template. # Process all files of supported type in or below the current directory. # Use "Eager Hacker" as the copyright owner. licenseheaders.py -t lgpl3 -c "Eager Hacker"
If licenseheaders is installed as a package (from pypi for instance), one can interact with it as a command line tool:
python -m licenseheaders -t lgpl3 -c "Eager Hacker"
Download licenseheaders.py
from http://github.com/johann-petrak/licenseheaders
or :
pip install licenseheaders
This library comes with a number of predefined templates. If a template name is specified which when matched against all predefined template names matches exactly one as a substring, then that template is used. Otherwise the name is expected to be the path of file.
If a template does not contain any variables of the form ${varname} it is used as is. Otherwise the program will try to replace the variable from one of the following sources:
- an environment variable with the same name but the prefix LICENSE_HEADERS_ added
- the command line option that can be used to set the variable (see usage)
Java: - assumed for all files with the extensions: .java, .scala, .groovy - only headers that use Java block comments are recognised as existing headers - the template text will be wrapped in block comments
Licensed under the term of MIT License. See attached file LICENSE.txt.