Index: android_webview/tools/webview_licenses.py |
diff --git a/android_webview/tools/webview_licenses.py b/android_webview/tools/webview_licenses.py |
index 05736f34bc7cd084f9bb92f2202706d84b13b5cd..d1f76292728f716e10dfa7ba72bfb694f2a22a89 100755 |
--- a/android_webview/tools/webview_licenses.py |
+++ b/android_webview/tools/webview_licenses.py |
@@ -16,7 +16,6 @@ which whitelists indicidual files which contain third-party code but which |
aren't in a third-party directory with a README.chromium file. |
""" |
-import glob |
import imp |
import json |
import multiprocessing |
@@ -57,58 +56,6 @@ class InputApiChange(object): |
def __init__(self): |
self.RepositoryRoot = lambda: REPOSITORY_ROOT |
- |
-def GetIncompatibleDirectories(): |
- """Gets a list of third-party directories which use licenses incompatible |
- with Android. This is used by the snapshot tool. |
- Returns: |
- A list of directories. |
- """ |
- |
- result = [] |
- for directory in _FindThirdPartyDirs(): |
- if directory in known_issues.KNOWN_ISSUES: |
- result.append(directory) |
- continue |
- try: |
- metadata = licenses.ParseDir(directory, REPOSITORY_ROOT, |
- require_license_file=False, |
- optional_keys=['License Android Compatible']) |
- except licenses.LicenseError as e: |
- print 'Got LicenseError while scanning ' + directory |
- raise |
- if metadata.get('License Android Compatible', 'no').upper() == 'YES': |
- continue |
- license = re.split(' [Ll]icenses?$', metadata['License'])[0] |
- if not third_party.LicenseIsCompatibleWithAndroid(InputApi(), license): |
- result.append(directory) |
- return result |
- |
-def GetUnknownIncompatibleDirectories(): |
- """Gets a list of third-party directories which use licenses incompatible |
- with Android which are not present in the known_issues.py file. |
- This is used by the AOSP bot. |
- Returns: |
- A list of directories. |
- """ |
- incompatible_directories = frozenset(GetIncompatibleDirectories()) |
- known_incompatible = [] |
- input_api = InputApi() |
- for path, exclude_list in known_issues.KNOWN_INCOMPATIBLE.iteritems(): |
- path = copyright_scanner.ForwardSlashesToOsPathSeps(input_api, path) |
- for exclude in exclude_list: |
- exclude = copyright_scanner.ForwardSlashesToOsPathSeps(input_api, exclude) |
- if glob.has_magic(exclude): |
- exclude_dirname = os.path.dirname(exclude) |
- if glob.has_magic(exclude_dirname): |
- print ('Exclude path %s contains an unexpected glob expression,' \ |
- ' skipping.' % exclude) |
- exclude = exclude_dirname |
- known_incompatible.append(os.path.normpath(os.path.join(path, exclude))) |
- known_incompatible = frozenset(known_incompatible) |
- return incompatible_directories.difference(known_incompatible) |
- |
- |
class ScanResult(object): |
Ok, Warnings, Errors = range(3) |
@@ -184,17 +131,6 @@ def _ReadFile(full_path, mode='rU'): |
return f.read() |
-def _ReadLocalFile(path, mode='rb'): |
- """Reads a file from disk. |
- Args: |
- path: The path of the file to read, relative to the root of the repository. |
- Returns: |
- The contents of the file as a string. |
- """ |
- |
- return _ReadFile(os.path.join(REPOSITORY_ROOT, path), mode) |
- |
- |
def _FindThirdPartyDirs(): |
"""Gets the list of third-party directories. |
Returns: |
@@ -345,13 +281,6 @@ def GenerateNoticeFile(generate_licenses_file_list_only=False): |
return template.render({ 'entries': entries }).encode('utf8') |
-def _ProcessIncompatibleResult(incompatible_directories): |
- if incompatible_directories: |
- print ("Incompatibly licensed directories found:\n" + |
- "\n".join(sorted(incompatible_directories))) |
- return ScanResult.Errors |
- return ScanResult.Ok |
- |
def main(): |
class FormatterWithNewLines(optparse.IndentedHelpFormatter): |
def format_description(self, description): |
@@ -369,11 +298,6 @@ def main(): |
'Android NOTICE file.\n' |
' notice [file] Generate Android NOTICE file on ' |
'stdout or into |file|.\n' |
- ' incompatible_directories Scan for incompatibly' |
- ' licensed directories.\n' |
- ' all_incompatible_directories Scan for incompatibly' |
- ' licensed directories (even those in' |
- ' known_issues.py).\n' |
' display_copyrights Display autorship on the files' |
' using names provided via stdin.\n') |
(options, args) = parser.parse_args() |
@@ -402,10 +326,6 @@ def main(): |
with open(args[1], 'w') as output_file: |
output_file.write(notice_file_contents) |
return ScanResult.Ok |
- elif args[0] == 'incompatible_directories': |
- return _ProcessIncompatibleResult(GetUnknownIncompatibleDirectories()) |
- elif args[0] == 'all_incompatible_directories': |
- return _ProcessIncompatibleResult(GetIncompatibleDirectories()) |
elif args[0] == 'display_copyrights': |
files = sys.stdin.read().splitlines() |
for f, c in \ |