Chromium Code Reviews| Index: tools/checklicenses/checklicenses.py |
| diff --git a/tools/checklicenses/checklicenses.py b/tools/checklicenses/checklicenses.py |
| index 22e13ee49f1480a9b889eb2714bf90484acaef9e..dfd980957ab68a4c6c208246eaa768be0274921a 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 fnmatch |
|
Paweł Hajdan Jr.
2015/04/02 09:58:24
PLease do not add fnmatch support to checklicenses
|
| import json |
| import optparse |
| import os.path |
| @@ -421,6 +422,13 @@ PATH_SPECIFIC_WHITELISTED_LICENSES = { |
| } |
| +FNMATCH_WHITELISTED_LICENSES = { |
| + 'third_party/jsoncpp/source/*.py': [ # http://crbug.com/472816 |
| + 'UNKNOWN', |
| + ], |
| +} |
| + |
| + |
| def check_licenses(options, args): |
| # Figure out which directory we have to check. |
| if len(args) == 0: |
| @@ -462,6 +470,7 @@ def check_licenses(options, args): |
| return 1 |
| used_suppressions = set() |
| + used_fnmatch_suppressions = set() |
| errors = [] |
| for line in stdout.splitlines(): |
| @@ -492,6 +501,16 @@ def check_licenses(options, args): |
| used_suppressions.update(set(matched_prefixes)) |
| continue |
| + matched_pattern = None |
| + for pattern in FNMATCH_WHITELISTED_LICENSES: |
| + if fnmatch.fnmatch(filename, pattern): |
| + matched_pattern = pattern |
| + break |
| + |
| + if matched_pattern: |
| + used_fnmatch_suppressions.add(matched_pattern) |
| + continue |
| + |
| errors.append({'filename': filename, 'license': license}) |
| if options.json: |
| @@ -526,6 +545,13 @@ def check_licenses(options, args): |
| print "\nNOTE: unused suppressions detected:\n" |
| print '\n'.join(unused_suppressions) |
| + unused_fnmatch_suppressions = set( |
| + FNMATCH_WHITELISTED_LICENSES.iterkeys()).difference( |
| + used_fnmatch_suppressions) |
| + if unused_fnmatch_suppressions: |
| + print "\nNOTE: unused fnmatch suppressions detected:\n" |
| + print '\n'.join(unused_fnmatch_suppressions) |
| + |
| return 0 |