OLD | NEW |
---|---|
(Empty) | |
1 #!/usr/bin/env python | |
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 __doc__ = """filter_resource_whitelist.py [-h] [--input INPUT] | |
Dirk Pranke
2017/07/14 23:01:51
Nit: you don't need to (and shouldn't) assign to _
F
2017/07/17 14:35:14
Done.
| |
7 [--filter FILTER] [--output OUTPUT] | |
8 | |
9 INPUT specifies a resource whitelist file containing resource IDs that should | |
10 be whitelisted, where each line of INPUT contains a single resource ID. | |
11 | |
12 FILTER specifies a resource whitelist file containing resource IDs that should | |
13 not be whitelisted, where each line of FILTER contains a single resource ID. | |
14 | |
15 Filters a resource whitelist by removing resource IDs that are contained in a | |
16 another resource whitelist. | |
17 | |
18 This script is used to generate Monochrome's locale paks. | |
19 """ | |
20 | |
21 import argparse | |
22 import sys | |
23 | |
24 | |
25 def main(): | |
26 parser = argparse.ArgumentParser(usage=__doc__) | |
27 parser.add_argument( | |
28 '--input', type=argparse.FileType('r'), required=True, | |
29 help='A resource whitelist where each line contains one resource ID. ' | |
30 'These IDs, excluding the ones in FILTER, are to be included.') | |
31 parser.add_argument( | |
32 '--filter', type=argparse.FileType('r'), required=True, | |
33 help='A resource whitelist where each line contains one resource ID. ' | |
34 'These IDs are to be excluded.') | |
35 parser.add_argument( | |
36 '--output', type=argparse.FileType('w'), default=sys.stdout, | |
37 help='The resource list path to write (default stdout)') | |
38 | |
39 args = parser.parse_args() | |
40 | |
41 input_resources = list(int(resource_id) for resource_id in args.input) | |
42 filter_resources = set(int(resource_id) for resource_id in args.filter) | |
43 output_resources = [resource_id for resource_id in input_resources | |
44 if resource_id not in filter_resources] | |
45 | |
46 for resource_id in sorted(output_resources): | |
47 args.output.write('%d\n' % resource_id) | |
48 | |
49 if __name__ == '__main__': | |
50 main() | |
OLD | NEW |