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

Unified Diff: tools/grit/grit/format/data_pack.py

Issue 2175413004: Enable whitelist generation for all builds. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase + change output dir Created 4 years, 4 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 | « chrome/chrome_repack_locales.gni ('k') | tools/grit/grit/format/repack.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/grit/grit/format/data_pack.py
diff --git a/tools/grit/grit/format/data_pack.py b/tools/grit/grit/format/data_pack.py
index 02616c39d40443d1c583f3acb351c7708f13ec54..9f92b7c608b79183f939475590292dcefe09175c 100755
--- a/tools/grit/grit/format/data_pack.py
+++ b/tools/grit/grit/format/data_pack.py
@@ -109,7 +109,8 @@ def WriteDataPack(resources, output_file, encoding):
file.write(content)
-def RePack(output_file, input_files, whitelist_file=None):
+def RePack(output_file, input_files, whitelist_file=None,
+ suppress_removed_key_output=False):
"""Write a new data pack file by combining input pack files.
Args:
@@ -118,6 +119,8 @@ def RePack(output_file, input_files, whitelist_file=None):
whitelist_file: path to the file that contains the list of resource IDs
that should be kept in the output file or None to include
all resources.
+ suppress_removed_key_output: allows the caller to suppress the output from
+ RePackFromDataPackStrings.
Raises:
KeyError: if there are duplicate keys or resource encoding is
@@ -128,17 +131,20 @@ def RePack(output_file, input_files, whitelist_file=None):
if whitelist_file:
whitelist = util.ReadFile(whitelist_file, util.RAW_TEXT).strip().split('\n')
whitelist = set(map(int, whitelist))
- resources, encoding = RePackFromDataPackStrings(input_data_packs, whitelist)
+ resources, encoding = RePackFromDataPackStrings(
+ input_data_packs, whitelist, suppress_removed_key_output)
WriteDataPack(resources, output_file, encoding)
-def RePackFromDataPackStrings(inputs, whitelist):
+def RePackFromDataPackStrings(inputs, whitelist,
+ suppress_removed_key_output=False):
"""Returns a data pack string that combines the resources from inputs.
Args:
inputs: a list of data pack strings that need to be combined.
whitelist: a list of resource IDs that should be kept in the output string
or None to include all resources.
+ suppress_removed_key_output: Do not print removed keys.
Returns:
DataPackContents: a tuple containing the new combined data pack and its
@@ -170,8 +176,9 @@ def RePackFromDataPackStrings(inputs, whitelist):
resources.update(whitelisted_resources)
removed_keys = [key for key in content.resources.keys()
if key not in whitelist]
- for key in removed_keys:
- print 'RePackFromDataPackStrings Removed Key:', key
+ if not suppress_removed_key_output:
+ for key in removed_keys:
+ print 'RePackFromDataPackStrings Removed Key:', key
else:
resources.update(content.resources)
« no previous file with comments | « chrome/chrome_repack_locales.gni ('k') | tools/grit/grit/format/repack.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698