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 |
| 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() |
OLD | NEW |