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

Side by Side Diff: tools/resources/filter_resource_whitelist.py

Issue 2933343002: 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 unified diff | Download patch
OLDNEW
(Empty)
1 #!/usr/bin/env python
agrieve 2017/06/29 01:29:25 Also: Add yourself (and me) to the OWNERS file her
F 2017/06/29 18:31:20 Done.
2 # Copyright 2017 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 import argparse
7 import os
8 import re
9 import sys
10
11 USAGE = """filter_resource_whitelist.py [-h] [-i INPUT] [-f FILTER] [-o OUTPUT]
agrieve 2017/06/29 01:09:53 nit: Use this as the __doc__ string (put before im
F 2017/06/29 18:31:20 Done.
12
13 INPUT specifies a resource whitelist file containing resource IDs that should
14 be whitelisted, where each line of INPUT contains a single resource ID.
15
16 FILTER specifies a resource whitelist file containing resource IDs that should
17 not be whitelisted, where each line of FILTER contains a single resource ID.
18
19 Filters a resource whitelist by removing resource IDs that are contained in a
20 another resource whitelist.
21
22 This script is used to generate Monochrome's locale paks.
23
agrieve 2017/06/29 01:09:53 nit: remove blank line
F 2017/06/29 18:31:20 Done.
24 """
25
26
27 def main():
28 parser = argparse.ArgumentParser(usage=USAGE)
29 parser.add_argument(
30 '-i', '--input', type=argparse.FileType('r'), default=sys.stdin,
agrieve 2017/06/29 01:09:53 nit: drop the short form arguments. They just serv
F 2017/06/29 18:31:20 Done.
31 help='A resource whitelist where each line contains one resource ID. '
32 'These IDs, excluding the ones in FILTER, are to be included.')
33 parser.add_argument(
34 '-f', '--filter', type=argparse.FileType('r'), default=sys.stdin,
agrieve 2017/06/29 01:09:53 Seems strange to have two different flags default
F 2017/06/29 18:31:20 Done.
35 help='A resource whitelist where each line contains one resource ID. '
36 'These IDs are to be excluded.')
37 parser.add_argument(
38 '-o', '--output', type=argparse.FileType('w'), default=sys.stdout,
39 help='The resource list path to write (default stdout)')
40 parser.add_argument(
41 '--out-dir', required=True,
agrieve 2017/06/29 01:09:53 nit: call this '--output-directory' to be consiste
F 2017/06/29 18:31:20 Done.
42 help='The out target directory, for example out/Release')
43
44 args = parser.parse_args()
45
46 input_resources = list(int(resource_id) for resource_id in args.input)
47 filter_resources = set(int(resource_id) for resource_id in args.filter)
48 output_resources = [resource_id for resource_id in input_resources
49 if resource_id not in filter_resources]
50
51 for resource_id in sorted(output_resources):
52 args.output.write('%d\n' % resource_id)
53
54 if __name__ == '__main__':
55 main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698