Add or change license headers for all files in a directory
Likely abandoned. No release or commit for years (last release over 5 years ago).
pip install licenseheaderslicenseheaders
A Python 3 tool to update, change or add license headers to all files of any of the supported types (see below) in or below some directory.
Usage
usage: licenseheaders.py [-h] [-V] [-v] [-d DIR] [-f [FILES [FILES ...]]] [-b]
[-t TMPL] [-y YEARS] [-cy] [-o OWNER]
[-n PROJECTNAME] [-u PROJECTURL] [--enc ENCODING]
[--dry] [--safesubst] [-D] [-E [EXT [EXT ...]]]
[--additional-extensions ADDITIONAL_EXTENSIONS [ADDITIONAL_EXTENSIONS ...]]
[-x [EXCLUDE [EXCLUDE ...]]]
Python license header updater
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 1 to 3
times, default shows errors only)
-d DIR, --dir DIR The directory to recursively process (default: .).
-f [FILES [FILES ...]], --files [FILES [FILES ...]]
The list of files to process. If not empty - will
disable '--dir' option
-b Back up all files which get changed to a copy with
.bak added to the name
-t TMPL, --tmpl TMPL Template name or file to use.
-y YEARS, --years YEARS
Year or year range to use.
-cy, --current-year Use today's year.
-o OWNER, --owner OWNER
Name of copyright owner to use.
-n PROJECTNAME, --projname PROJECTNAME
Name of project to use.
-u PROJECTURL, --projurl PROJECTURL
Url of project to use.
--enc ENCODING Encoding of program files (default: utf-8)
--dry Only show what would get done, do not change any files
--safesubst Do not raise error if template variables cannot be
substituted.
-D, --debug Enable debug messages (same as -v -v -v)
-E [EXT [EXT ...]], --ext [EXT [EXT ...]]
If specified, restrict processing to the specified
extension(s) only
--additional-extensions ADDITIONAL_EXTENSIONS [ADDITIONAL_EXTENSIONS ...]
Provide a comma-separated list of additional file
extensions as value for a specified language as key,
each with a leading dot and no whitespace (default:
None).
-x [EXCLUDE [EXCLUDE ...]], --exclude [EXCLUDE [EXCLUDE ...]]
File path patterns to exclude
Known extensions: ['c:.c, .cc, .h', 'cpp:.cpp, .hpp, .cxx, .hxx, .ixx', 'csharp:.cs, .csx', 'd:.d', 'go:.go', 'groovy:.groovy', 'java:.java, .jape', 'javascript:.js, .js, .cjs, .mjs', 'kotlin:.kt, .kts, .ktm', 'objective-c:.m, .mm, .M', 'php:.php, .phtml, .php3, .php4, .php5, .php7, .phps, .php-s, .pht, .phar', 'rust:.rs', 'scala:.scala', 'swift:.swift', 'typescript:.ts, .tsx', 'script:.sh,.csh,.py,.pl', 'perl:.pl', 'python:.py', 'robot:.robot', 'xml:.xml', 'sql:.sql', 'ruby:.rb', 'vb:.vb', 'erlang:.erl,.src,.config,.schema', 'html:.html', 'css:.css,.scss,.sass', 'docker:.dockerfile', 'yaml:.yaml,.yml', 'zig:.zig']
If -t/--tmpl is specified, that header is added to (or existing header replaced for) all source files of known type
If -t/--tmpl is not specified but -y/--years is specified, all years in existing header files
are replaced with the years specified
Examples:
licenseheaders.py -t lgpl-v3 -y 2012-2014 -o ThisNiceCompany -n ProjectName -u http://the.projectname.com
licenseheaders.py -y 2012-2015
licenseheaders.py -y 2012-2015 -d /dir/where/to/start/
licenseheaders.py -y 2012-2015 -d /dir/where/to/start/ --additional-extensions python=.j2
licenseheaders.py -y 2012-2015 -d /dir/where/to/start/ --additional-extensions python=.j2,.tpl script=.txt
licenseheaders.py -t .copyright.tmpl -cy
licenseheaders.py -t .copyright.tmpl -cy -f some_file.cpp