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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | grit/format/check_dups_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: grit/format/check_dups.py
diff --git a/grit/format/check_dups.py b/grit/format/check_dups.py
new file mode 100644
index 0000000000000000000000000000000000000000..0ecc0b4af2217630d4984bab8e75f092d67e7d46
--- /dev/null
+++ b/grit/format/check_dups.py
@@ -0,0 +1,45 @@
+#!/usr/bin/env python
+# Copyright 2015 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Check for duplicate resource in multiple pack files."""
+
+import os
+import sys
+
+if __name__ == '__main__':
+ sys.path.append(os.path.join(os.path.dirname(__file__), '../..'))
+
+from grit.format.data_pack import DataPack
+
+class ResourceDuplicateException(Exception):
+ pass
+
+
+def CheckDupResource(resource_filenames):
+ resources = {}
+ for filename in resource_filenames:
+ pack = DataPack.ReadDataPack(filename)
+ for (resource_id, data) in pack.resources.iteritems():
+ if resource_id in resources:
+ details = resources[resource_id]
+ raise ResourceDuplicateException(
+ "Duplicate resource with id %s in %s (size %d) and %s (size %d)" %
+ (resource_id, details['filename'],
+ details['size'], filename, len(data)))
+ resources[resource_id] = {
+ 'filename': filename,
+ 'size': len(data)
+ }
+
+
+def main():
+ if len(sys.argv) < 2:
+ print "There must be at least two pak files as input."
+ return
+ CheckDupResource(sys.argv[1:])
+
+
+if __name__ == '__main__':
+ main()
« 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