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

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: better-test 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
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()
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