Chromium Code Reviews| Index: android_webview/tools/webview_licenses.py |
| diff --git a/android_webview/tools/webview_licenses.py b/android_webview/tools/webview_licenses.py |
| index 13213c5b41b63722c745102fd9ed7ccee1f4bcaf..0017b201fdb477165977b388d8c0eeabe9f1340d 100755 |
| --- a/android_webview/tools/webview_licenses.py |
| +++ b/android_webview/tools/webview_licenses.py |
| @@ -16,6 +16,7 @@ which whitelists indicidual files which contain third-party code but which |
| aren't in a third-party directory with a README.chromium file. |
| """ |
| +import imp |
| import optparse |
| import os |
| import re |
| @@ -27,11 +28,22 @@ import textwrap |
| REPOSITORY_ROOT = os.path.abspath(os.path.join( |
| os.path.dirname(__file__), '..', '..')) |
| +# Import third_party/PRESUBMIT.py via imp to avoid importing a random |
| +# PRESUBMIT.py from $PATH, also make sure we don't generate a .pyc file. |
| +sys.dont_write_bytecode = True |
| +third_party = \ |
| + imp.load_source('PRESUBMIT', \ |
| + os.path.join(REPOSITORY_ROOT, 'third_party', 'PRESUBMIT.py')) |
| + |
| sys.path.append(os.path.join(REPOSITORY_ROOT, 'tools')) |
| import licenses |
| import known_issues |
| +class InputApi(object): |
| + def __init__(self): |
| + self.re = re |
|
mkosiba (inactive)
2014/01/31 17:47:38
could you explain why this is needed? PRESUBMIT.py
mnaganov (inactive)
2014/02/03 10:00:26
No -- in fact, PRESUBMIT scripts don't import anyt
mkosiba (inactive)
2014/02/03 10:30:55
ah, thanks for that. I got confused by the import
|
| + |
| def GetIncompatibleDirectories(): |
| """Gets a list of third-party directories which use licenses incompatible |
| with Android. This is used by the snapshot tool and the AOSP bot. |
| @@ -39,22 +51,6 @@ def GetIncompatibleDirectories(): |
| A list of directories. |
| """ |
| - whitelist = [ |
| - 'Apache( Version)? 2(\.0)?', |
| - '(New )?([23]-Clause )?BSD( [23]-Clause)?( with advertising clause)?', |
| - 'L?GPL ?v?2(\.[01])?( or later)?', |
| - 'MIT(/X11)?(-like)?', |
| - 'MPL 1\.1 ?/ ?GPL 2(\.0)? ?/ ?LGPL 2\.1', |
| - 'MPL 2(\.0)?', |
| - 'Microsoft Limited Public License', |
| - 'Microsoft Permissive License', |
| - 'Public Domain', |
| - 'Python', |
| - 'SGI Free Software License B', |
| - 'University of Illinois\/NCSA Open Source', |
| - 'X11', |
| - ] |
| - regex = '^(%s)$' % '|'.join(whitelist) |
| result = [] |
| for directory in _FindThirdPartyDirs(): |
| if directory in known_issues.KNOWN_ISSUES: |
| @@ -69,11 +65,8 @@ def GetIncompatibleDirectories(): |
| if metadata.get('License Android Compatible', 'no').upper() == 'YES': |
| continue |
| license = re.split(' [Ll]icenses?$', metadata['License'])[0] |
| - tokens = [x.strip() for x in re.split(' and |,', license) if len(x) > 0] |
| - for token in tokens: |
| - if not re.match(regex, token, re.IGNORECASE): |
| - result.append(directory) |
| - break |
| + if not third_party.LicenseIsCompatibleWithAndroid(InputApi(), license): |
| + result.append(directory) |
| return result |
| class ScanResult(object): |