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) |