Index: tools/licenses.py |
diff --git a/tools/licenses.py b/tools/licenses.py |
index ccebfaeb92d8c18d6ad58aac7a4010c4ae499d27..815dde9fb25d3787bae5c30d449a48431f22aec2 100755 |
--- a/tools/licenses.py |
+++ b/tools/licenses.py |
@@ -254,7 +254,7 @@ def AbsolutePath(path, filename, root): |
return absolute_path |
return None |
-def ParseDir(path, root, require_license_file=True): |
+def ParseDir(path, root, require_license_file=True, optional_keys=None): |
"""Examine a third_party/foo component and extract its metadata.""" |
# Parse metadata fields out of README.chromium. |
@@ -266,9 +266,8 @@ def ParseDir(path, root, require_license_file=True): |
"License": None, # Software license. |
} |
- # Relative path to a file containing some html we're required to place in |
- # about:credits. |
- optional_keys = ["Required Text", "License Android Compatible"] |
+ if optional_keys is None: |
+ optional_keys = [] |
if path in SPECIAL_CASES: |
metadata.update(SPECIAL_CASES[path]) |
@@ -312,13 +311,6 @@ def ParseDir(path, root, require_license_file=True): |
"README.chromium with the appropriate path.") |
metadata["License File"] = license_path |
- if "Required Text" in metadata: |
- required_path = AbsolutePath(path, metadata["Required Text"], root) |
- if required_path is not None: |
- metadata["Required Text"] = required_path |
- else: |
- raise LicenseError("Required text file listed but not found.") |
- |
return metadata |
@@ -425,7 +417,7 @@ def GenerateCredits(): |
entries = [] |
for path in sorted(third_party_dirs): |
try: |
- metadata = ParseDir(path, root) |
+ metadata = ParseDir(path, root, optional_keys=['Required Text']) |
except LicenseError: |
# TODO(phajdan.jr): Convert to fatal error (http://crbug.com/39240). |
continue |
@@ -437,8 +429,15 @@ def GenerateCredits(): |
'license': open(metadata['License File'], 'rb').read(), |
'license_unescaped': '', |
} |
+ # 'Required Text' is a relative path to a file containing some html |
Lei Zhang
2014/10/30 09:14:11
Fun fact, nobody uses this anymore. It was added s
mckev
2014/10/30 16:45:13
Interesting. Would you advocate removing it now,
Lei Zhang
2014/10/30 19:06:13
I'd just remove it and mention it in the CL descri
mckev
2014/10/30 20:45:54
Sounds good to me!
|
+ # we're required to place in about:credits. |
if 'Required Text' in metadata: |
- required_text = open(metadata['Required Text'], 'rb').read() |
+ required_path = AbsolutePath(path, metadata["Required Text"], root) |
+ if required_path is not None: |
+ required_text = open(required_path, 'rb').read() |
+ else: |
+ # TODO(phajdan.jr): Convert to fatal error (http://crbug.com/39240). |
Lei Zhang
2014/10/30 09:14:11
BTW, 79 chars / line in general with Python. See P
mckev
2014/10/30 16:45:13
Whoops, sorry about that. I'll fix it right away.
|
+ continue |
env["license_unescaped"] = required_text |
entries.append(EvaluateTemplate(entry_template, env)) |