OLD | NEW |
---|---|
(Empty) | |
1 #!/usr/bin/env python | |
2 # Copyright 2015 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 """Check for duplicate resource in multiple pack files.""" | |
7 | |
8 import os | |
9 import sys | |
10 | |
11 if __name__ == '__main__': | |
12 sys.path.append(os.path.join(os.path.dirname(__file__), '../..')) | |
13 | |
14 from grit.format.data_pack import DataPack | |
15 | |
16 class ResourceDuplicateException(Exception): | |
17 pass | |
18 | |
Mattias Nissler (ping if slow)
2015/04/07 10:12:38
nit: two blank lines between top-levels (here and
sadrul
2015/04/07 20:09:30
Done.
| |
19 def CheckDupResource(resource_filenames): | |
20 resources = {} | |
21 for filename in resource_filenames: | |
22 pack = DataPack.ReadDataPack(filename) | |
23 for (resource_id, data) in pack.resources.iteritems(): | |
24 if resource_id in resources: | |
25 details = resources[resource_id] | |
26 raise ResourceDuplicateException( | |
27 "Duplicate resource with id %s in %s (size %d) and %s (size %d)" % | |
28 (resource_id, details['filename'], | |
29 details['size'], filename, len(data))) | |
30 resources[resource_id] = { | |
31 'filename': filename, | |
32 'size': len(data) | |
33 } | |
34 | |
35 | |
36 def main(): | |
Mattias Nissler (ping if slow)
2015/04/07 10:12:38
Hm, a new program doesn't really fit with grit's c
sadrul
2015/04/07 20:09:30
I am not very familiar with grit. Are there existi
Mattias Nissler (ping if slow)
2015/04/08 08:29:52
Let's wait and hear what thakis@ says.
| |
37 if len(sys.argv) < 2: | |
38 print "There must be at least two pak files as input." | |
39 return | |
40 CheckDupResource(sys.argv[1:]) | |
41 | |
42 | |
43 if __name__ == '__main__': | |
44 main() | |
OLD | NEW |