Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Unified Diff: tools/checklicenses/checklicenses.py

Issue 311353002: Add support for JSON output to checklicenses.py (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: iterkeys Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/checklicenses/checklicenses.py
diff --git a/tools/checklicenses/checklicenses.py b/tools/checklicenses/checklicenses.py
index f037d8b2ee13fb821733f9a301692b78c043f025..c657efff9b75616f7fb4989ba3b4250f1f1e9d38 100755
--- a/tools/checklicenses/checklicenses.py
+++ b/tools/checklicenses/checklicenses.py
@@ -6,6 +6,7 @@
"""Makes sure that all files contain proper licensing information."""
+import json
import optparse
import os.path
import subprocess
@@ -422,8 +423,8 @@ def check_licenses(options, args):
return 1
used_suppressions = set()
+ errors = []
- success = True
for line in stdout.splitlines():
filename, license = line.split(':', 1)
filename = os.path.relpath(filename.strip(), options.base_directory)
@@ -452,21 +453,16 @@ def check_licenses(options, args):
used_suppressions.update(set(matched_prefixes))
continue
- print "'%s' has non-whitelisted license '%s'" % (filename, license)
- success = False
+ errors.append({'filename': filename, 'license': license})
- if success:
- print "\nSUCCESS\n"
+ if options.json:
+ with open(options.json, 'w') as f:
+ json.dump(errors, f)
- if not len(args):
- unused_suppressions = set(
- PATH_SPECIFIC_WHITELISTED_LICENSES.keys()).difference(used_suppressions)
- if unused_suppressions:
- print "\nNOTE: unused suppressions detected:\n"
- print '\n'.join(unused_suppressions)
-
- return 0
- else:
+ if errors:
+ for error in errors:
+ print "'%s' has non-whitelisted license '%s'" % (
+ error['filename'], error['license'])
print "\nFAILED\n"
print "Please read",
print "http://www.chromium.org/developers/adding-3rd-party-libraries"
@@ -481,6 +477,18 @@ def check_licenses(options, args):
return 1
+ print "\nSUCCESS\n"
+
+ if not len(args):
+ unused_suppressions = set(
+ PATH_SPECIFIC_WHITELISTED_LICENSES.iterkeys()).difference(
+ used_suppressions)
+ if unused_suppressions:
+ print "\nNOTE: unused suppressions detected:\n"
+ print '\n'.join(unused_suppressions)
+
+ return 0
+
def main():
default_root = os.path.abspath(
@@ -497,6 +505,7 @@ def main():
action='store_true',
default=False,
help='Ignore path-specific license whitelist.')
+ option_parser.add_option('--json', help='Path to JSON output file')
options, args = option_parser.parse_args()
return check_licenses(options, args)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698