diff options
-rwxr-xr-x | android_webview/tools/webview_licenses.py | 14 | ||||
-rwxr-xr-x | tools/licenses.py | 6 |
2 files changed, 10 insertions, 10 deletions
diff --git a/android_webview/tools/webview_licenses.py b/android_webview/tools/webview_licenses.py index 338a426..b432895 100755 --- a/android_webview/tools/webview_licenses.py +++ b/android_webview/tools/webview_licenses.py @@ -53,7 +53,7 @@ def GetIncompatibleDirectories(): regex = '^(%s)$' % '|'.join(whitelist) result = [] for directory in _FindThirdPartyDirs(): - metadata = licenses.ParseDir(directory) + metadata = licenses.ParseDir(directory, require_license_file=False) if metadata.get('License Android Compatible', 'no') == 'yes': continue license = re.split(' [Ll]icenses?$', metadata['License'])[0] @@ -193,10 +193,9 @@ def _Scan(): and all_licenses_valid -def _GenerateNoticeFile(print_warnings): +def GenerateNoticeFile(): """Generates the contents of an Android NOTICE file for the third-party code. - Args: - print_warnings: Whether to print warnings. + This is used by the snapshot tool. Returns: The contents of the NOTICE file. """ @@ -209,8 +208,9 @@ def _GenerateNoticeFile(print_warnings): # We provide attribution for all third-party directories. # TODO(steveblock): Limit this to only code used by the WebView binary. for directory in third_party_dirs: - license_file = licenses.ParseDir(directory)['License File'] - if license_file != licenses.NOT_SHIPPED: + metadata = licenses.ParseDir(directory, require_license_file=False) + license_file = metadata['License File'] + if license_file and license_file != licenses.NOT_SHIPPED: content.append(_ReadFile(license_file)) return '\n'.join(content) @@ -245,7 +245,7 @@ def main(): else: return 1 elif args[0] == 'notice': - print _GenerateNoticeFile(print_warnings=False) + print GenerateNoticeFile() return 0 parser.print_help() diff --git a/tools/licenses.py b/tools/licenses.py index 8feda9c..d5bd316 100755 --- a/tools/licenses.py +++ b/tools/licenses.py @@ -234,7 +234,7 @@ def AbsolutePath(path, filename): return absolute_path return None -def ParseDir(path): +def ParseDir(path, require_license_file=True): """Examine a third_party/foo component and extract its metadata.""" # Parse metadata fields out of README.chromium. @@ -282,15 +282,15 @@ def ParseDir(path): for filename in (metadata["License File"], "COPYING"): license_path = AbsolutePath(path, filename) if license_path is not None: - metadata["License File"] = license_path break - if not license_path: + if require_license_file and not license_path: raise LicenseError("License file not found. " "Either add a file named LICENSE, " "import upstream's COPYING if available, " "or add a 'License File:' line to " "README.chromium with the appropriate path.") + metadata["License File"] = license_path if "Required Text" in metadata: required_path = AbsolutePath(path, metadata["Required Text"]) |