Commit 95468c6e authored by mckev's avatar mckev Committed by Commit bot

Collect license version as an optional_key in licenses.py

This changes licenses.py to collect the license version information
during ParseDir, as an optional field.  This is for scripts that
import this script as a module, that may need this information.

Additionally, this removes the "Required Text" support from
licenses.py, because it was only used by SwiftShader, which no
longer needs this functionality.

BUG=424424

Review URL: https://codereview.chromium.org/660163002

Cr-Commit-Position: refs/heads/master@{#302213}
parent 592f8e1b
...@@ -69,7 +69,8 @@ def GetIncompatibleDirectories(): ...@@ -69,7 +69,8 @@ def GetIncompatibleDirectories():
continue continue
try: try:
metadata = licenses.ParseDir(directory, REPOSITORY_ROOT, metadata = licenses.ParseDir(directory, REPOSITORY_ROOT,
require_license_file=False) require_license_file=False,
optional_keys=['License Android Compatible'])
except licenses.LicenseError as e: except licenses.LicenseError as e:
print 'Got LicenseError while scanning ' + directory print 'Got LicenseError while scanning ' + directory
raise raise
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<a class="show" href="#">show license</a> <a class="show" href="#">show license</a>
<span class="homepage"><a href="{{url}}">homepage</a></span> <span class="homepage"><a href="{{url}}">homepage</a></span>
<div class="licence"> <div class="licence">
<pre>{{license}}</pre>{{license_unescaped}} <pre>{{license}}</pre>
</div> </div>
</div> </div>
...@@ -254,7 +254,7 @@ def AbsolutePath(path, filename, root): ...@@ -254,7 +254,7 @@ def AbsolutePath(path, filename, root):
return absolute_path return absolute_path
return None 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.""" """Examine a third_party/foo component and extract its metadata."""
# Parse metadata fields out of README.chromium. # Parse metadata fields out of README.chromium.
...@@ -266,9 +266,8 @@ def ParseDir(path, root, require_license_file=True): ...@@ -266,9 +266,8 @@ def ParseDir(path, root, require_license_file=True):
"License": None, # Software license. "License": None, # Software license.
} }
# Relative path to a file containing some html we're required to place in if optional_keys is None:
# about:credits. optional_keys = []
optional_keys = ["Required Text", "License Android Compatible"]
if path in SPECIAL_CASES: if path in SPECIAL_CASES:
metadata.update(SPECIAL_CASES[path]) metadata.update(SPECIAL_CASES[path])
...@@ -312,13 +311,6 @@ def ParseDir(path, root, require_license_file=True): ...@@ -312,13 +311,6 @@ def ParseDir(path, root, require_license_file=True):
"README.chromium with the appropriate path.") "README.chromium with the appropriate path.")
metadata["License File"] = license_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 return metadata
...@@ -412,7 +404,7 @@ def GenerateCredits(): ...@@ -412,7 +404,7 @@ def GenerateCredits():
"""Expand a template with variables like {{foo}} using a """Expand a template with variables like {{foo}} using a
dictionary of expansions.""" dictionary of expansions."""
for key, val in env.items(): for key, val in env.items():
if escape and not key.endswith("_unescaped"): if escape:
val = cgi.escape(val) val = cgi.escape(val)
template = template.replace('{{%s}}' % key, val) template = template.replace('{{%s}}' % key, val)
return template return template
...@@ -435,11 +427,7 @@ def GenerateCredits(): ...@@ -435,11 +427,7 @@ def GenerateCredits():
'name': metadata['Name'], 'name': metadata['Name'],
'url': metadata['URL'], 'url': metadata['URL'],
'license': open(metadata['License File'], 'rb').read(), 'license': open(metadata['License File'], 'rb').read(),
'license_unescaped': '',
} }
if 'Required Text' in metadata:
required_text = open(metadata['Required Text'], 'rb').read()
env["license_unescaped"] = required_text
entries.append(EvaluateTemplate(entry_template, env)) entries.append(EvaluateTemplate(entry_template, env))
file_template = open(os.path.join(root, 'chrome', 'browser', 'resources', file_template = open(os.path.join(root, 'chrome', 'browser', 'resources',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment