| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2016 The Chromium Authors. All rights reserved. | 2 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 import argparse |
| 6 import os | 7 import os |
| 7 import re | 8 import re |
| 8 import sys | 9 import sys |
| 9 | 10 |
| 10 | 11 |
| 11 _HERE_PATH = os.path.join(os.path.dirname(__file__)) | 12 _HERE_PATH = os.path.join(os.path.dirname(__file__)) |
| 12 | 13 |
| 13 | 14 |
| 14 _SRC_PATH = os.path.normpath(os.path.join(_HERE_PATH, '..', '..', '..')) | 15 _SRC_PATH = os.path.normpath(os.path.join(_HERE_PATH, '..', '..', '..')) |
| 15 sys.path.append(os.path.join(_SRC_PATH, 'tools', 'grit')) | 16 sys.path.append(os.path.join(_SRC_PATH, 'tools', 'grit')) |
| (...skipping 28 matching lines...) Expand all Loading... |
| 44 assert resource_filenames | 45 assert resource_filenames |
| 45 | 46 |
| 46 # Extract packed files, while preserving directory structure. | 47 # Extract packed files, while preserving directory structure. |
| 47 for (resource_id, text) in data.resources.iteritems(): | 48 for (resource_id, text) in data.resources.iteritems(): |
| 48 filename = resource_filenames[resource_ids[resource_id]] | 49 filename = resource_filenames[resource_ids[resource_id]] |
| 49 dirname = os.path.join(out_path, os.path.dirname(filename)) | 50 dirname = os.path.join(out_path, os.path.dirname(filename)) |
| 50 if not os.path.exists(dirname): | 51 if not os.path.exists(dirname): |
| 51 os.makedirs(dirname) | 52 os.makedirs(dirname) |
| 52 with open(os.path.join(out_path, filename), 'w') as file: | 53 with open(os.path.join(out_path, filename), 'w') as file: |
| 53 file.write(text) | 54 file.write(text) |
| 55 |
| 56 |
| 57 def main(): |
| 58 parser = argparse.ArgumentParser() |
| 59 parser.add_argument('--pak_file') |
| 60 parser.add_argument('--out_folder') |
| 61 args = parser.parse_args() |
| 62 |
| 63 unpack(args.pak_file, args.out_folder) |
| 64 |
| 65 |
| 66 if __name__ == '__main__': |
| 67 main() |
| OLD | NEW |