Skip to content

Commit 81b10e6

Browse files
author
Mike Tinning
committed
Initial commit
0 parents  commit 81b10e6

12 files changed

+2570
-0
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
licensify/_version.py export-subst

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.venv
2+
*.egg-info
3+
__pycache__

LICENSE

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
licensify
2+
Copyright (C) 2019, Simmovation Ltd.
3+
4+
This program is free software; you can redistribute it and/or modify
5+
it under the terms of the GNU General Public License as published by
6+
the Free Software Foundation; either version 3 of the License, or
7+
(at your option) any later version.
8+
9+
This program is distributed in the hope that it will be useful,
10+
but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
GNU General Public License for more details.
13+
14+
You should have received a copy of the GNU General Public License
15+
along with this program; if not, write to the Free Software Foundation,
16+
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

MANIFEST.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
include versioneer.py
2+
include licensify/_version.py

licensify/__init__.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# licensify
2+
# Copyright (C) 2019, Simmovation Ltd.
3+
#
4+
# This program is free software; you can redistribute it and/or modify
5+
# it under the terms of the GNU General Public License as published by
6+
# the Free Software Foundation; either version 3 of the License, or
7+
# (at your option) any later version.
8+
#
9+
# This program is distributed in the hope that it will be useful,
10+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
# GNU General Public License for more details.
13+
#
14+
# You should have received a copy of the GNU General Public License
15+
# along with this program; if not, write to the Free Software Foundation,
16+
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17+
from .apply_license import apply_license_header
18+
from .errors import LicensesOutOfDateError
19+
from .__version__ import __version__
20+
21+
from ._version import get_versions
22+
__version__ = get_versions()['version']
23+
del get_versions

licensify/__main__.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# licensify
2+
# Copyright (C) 2019, Simmovation Ltd.
3+
#
4+
# This program is free software; you can redistribute it and/or modify
5+
# it under the terms of the GNU General Public License as published by
6+
# the Free Software Foundation; either version 3 of the License, or
7+
# (at your option) any later version.
8+
#
9+
# This program is distributed in the hope that it will be useful,
10+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
# GNU General Public License for more details.
13+
#
14+
# You should have received a copy of the GNU General Public License
15+
# along with this program; if not, write to the Free Software Foundation,
16+
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17+
from sys import stdout
18+
from os import linesep
19+
from argparse import ArgumentParser
20+
from glob import glob
21+
22+
from licensify import apply_license_header
23+
24+
def _parse_args():
25+
parser = ArgumentParser()
26+
parser.add_argument('license', help='A file containing the liense')
27+
parser.add_argument('--directory', default='.', help='The directory to apply licenses to')
28+
parser.add_argument('--files', default='*.*', help='Glob to match files')
29+
parser.add_argument('--comment', default='#', help='Comment string to prepend to header lines')
30+
parser.add_argument('--dry-run', action='store_true', default=False, help='Perform a dry run')
31+
parser.add_argument('--check', action='store_true', default=False, help='Return an error if any files need updating (implies dry run)')
32+
return parser.parse_args()
33+
34+
if __name__ == '__main__':
35+
args = _parse_args()
36+
with open(args.license) as fp:
37+
license_header = fp.read()
38+
result = apply_license_header(license_header, glob(args.directory + '/**/' + args.files), args.check, args.dry_run or args.check)
39+
if result:
40+
message = 'The following files have been changed: {}'.format(', '.join(result))
41+
else:
42+
message = 'No files changed'
43+
stdout.write(message + linesep)

0 commit comments

Comments
 (0)