Chromium Code Reviews| 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..acfa88fa01ac888cdc26ce5db184cd02e44c7794 |
| --- /dev/null |
| +++ b/grit/format/check_dups.py |
| @@ -0,0 +1,44 @@ |
| +#!/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 |
| + |
|
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.
|
| +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(): |
|
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.
|
| + 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() |