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

Side by Side Diff: grit/format/check_dups.py

Issue 1056993003: check_dups: Add a script to check for the same resource in multiple pak files. (Closed) Base URL: https://chromium.googlesource.com/external/grit-i18n.git@master
Patch Set: . Created 5 years, 8 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
« no previous file with comments | « no previous file | grit/format/check_dups_unittest.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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
19
20 def CheckDupResource(resource_filenames):
21 resources = {}
22 for filename in resource_filenames:
23 pack = DataPack.ReadDataPack(filename)
24 for (resource_id, data) in pack.resources.iteritems():
25 if resource_id in resources:
26 details = resources[resource_id]
27 raise ResourceDuplicateException(
28 "Duplicate resource with id %s in %s (size %d) and %s (size %d)" %
29 (resource_id, details['filename'],
30 details['size'], filename, len(data)))
31 resources[resource_id] = {
32 'filename': filename,
33 'size': len(data)
34 }
35
36
37 def main():
38 if len(sys.argv) < 2:
39 print "There must be at least two pak files as input."
40 return
41 CheckDupResource(sys.argv[1:])
42
43
44 if __name__ == '__main__':
45 main()
OLDNEW
« no previous file with comments | « no previous file | grit/format/check_dups_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698