Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Unified Diff: tools/licenses.py

Issue 9318014: Add SwiftShader copyright info and logo to about:credits. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use a "Required Text" section Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/swiftshader/required.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/licenses.py
diff --git a/tools/licenses.py b/tools/licenses.py
index fc07af7a3ff4fab1911023773b72c0445b6bf564..d724540a598e47531fef3e1ab5505339c0573f26 100755
--- a/tools/licenses.py
+++ b/tools/licenses.py
@@ -151,6 +151,18 @@ class LicenseError(Exception):
fully filled out."""
pass
+def AbsolutePath(path, filename):
+ """Convert a path in README.chromium to be absolute based on the source
+ root."""
+ if filename.startswith('/'):
+ # Absolute-looking paths are relative to the source root
+ # (which is the directory we're run from).
+ absolute_path = os.path.join(os.getcwd(), filename[1:])
+ else:
+ absolute_path = os.path.join(path, filename)
+ if os.path.exists(absolute_path):
+ return absolute_path
+ return None
def ParseDir(path):
"""Examine a third_party/foo component and extract its metadata."""
@@ -163,6 +175,10 @@ def ParseDir(path):
"URL": None, # Project home page.
}
+ # Relative path to a file containing some html we're required to place in
+ # about:credits.
+ optional_keys = ["Required Text"]
+
if path in SPECIAL_CASES:
metadata.update(SPECIAL_CASES[path])
else:
@@ -175,7 +191,7 @@ def ParseDir(path):
line = line.strip()
if not line:
break
- for key in metadata.keys():
+ for key in metadata.keys() + optional_keys:
field = key + ": "
if line.startswith(field):
metadata[key] = line[len(field):]
@@ -189,16 +205,10 @@ def ParseDir(path):
# Check that the license file exists.
for filename in (metadata["License File"], "COPYING"):
- if filename.startswith('/'):
- # Absolute-looking paths are relative to the source root
- # (which is the directory we're run from).
- license_path = os.path.join(os.getcwd(), filename[1:])
- else:
- license_path = os.path.join(path, filename)
- if os.path.exists(license_path):
+ license_path = AbsolutePath(path, filename)
+ if license_path is not None:
metadata["License File"] = license_path
break
- license_path = None
if not license_path:
raise LicenseError("License file not found. "
@@ -207,6 +217,13 @@ def ParseDir(path):
"or add a 'License File:' line to README.chromium "
"with the appropriate path.")
+ if "Required Text" in metadata:
+ required_path = AbsolutePath(path, metadata["Required Text"])
+ if required_path is not None:
+ metadata["Required Text"] = required_path
+ else:
+ raise LicenseError("Required text file listed but not found.")
+
return metadata
@@ -269,7 +286,7 @@ def GenerateCredits():
"""Expand a template with variables like {{foo}} using a
dictionary of expansions."""
for key, val in env.items():
- if escape:
+ if escape and not key.endswith("_unescaped"):
val = cgi.escape(val)
template = template.replace('{{%s}}' % key, val)
return template
@@ -290,7 +307,11 @@ def GenerateCredits():
'name': metadata['Name'],
'url': metadata['URL'],
'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))
file_template = open('chrome/browser/resources/about_credits.tmpl',
« no previous file with comments | « third_party/swiftshader/required.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698