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

Unified Diff: tools/resources/filter_resource_whitelist.py

Issue 2977993002: Reland of Deduplicate Monochrome locale .paks (Closed)
Patch Set: Created 3 years, 5 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 | « tools/resources/OWNERS ('k') | ui/base/resource/resource_bundle.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/resources/filter_resource_whitelist.py
diff --git a/tools/resources/filter_resource_whitelist.py b/tools/resources/filter_resource_whitelist.py
new file mode 100755
index 0000000000000000000000000000000000000000..2cf5fe3690649cfd4659522724ab5662f60465ed
--- /dev/null
+++ b/tools/resources/filter_resource_whitelist.py
@@ -0,0 +1,50 @@
+#!/usr/bin/env python
+# Copyright 2017 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""filter_resource_whitelist.py [-h] [--input INPUT] [--filter FILTER]
+[--output OUTPUT]
+
+INPUT specifies a resource whitelist file containing resource IDs that should
+be whitelisted, where each line of INPUT contains a single resource ID.
+
+FILTER specifies a resource whitelist file containing resource IDs that should
+not be whitelisted, where each line of FILTER contains a single resource ID.
+
+Filters a resource whitelist by removing resource IDs that are contained in a
+another resource whitelist.
+
+This script is used to generate Monochrome's locale paks.
+"""
+
+import argparse
+import sys
+
+
+def main():
+ parser = argparse.ArgumentParser(usage=__doc__)
+ parser.add_argument(
+ '--input', type=argparse.FileType('r'), required=True,
+ help='A resource whitelist where each line contains one resource ID. '
+ 'These IDs, excluding the ones in FILTER, are to be included.')
+ parser.add_argument(
+ '--filter', type=argparse.FileType('r'), required=True,
+ help='A resource whitelist where each line contains one resource ID. '
+ 'These IDs are to be excluded.')
+ parser.add_argument(
+ '--output', type=argparse.FileType('w'), default=sys.stdout,
+ help='The resource list path to write (default stdout)')
+
+ args = parser.parse_args()
+
+ input_resources = list(int(resource_id) for resource_id in args.input)
+ filter_resources = set(int(resource_id) for resource_id in args.filter)
+ output_resources = [resource_id for resource_id in input_resources
+ if resource_id not in filter_resources]
+
+ for resource_id in sorted(output_resources):
+ args.output.write('%d\n' % resource_id)
+
+if __name__ == '__main__':
+ main()
« no previous file with comments | « tools/resources/OWNERS ('k') | ui/base/resource/resource_bundle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698