| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 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 """Class for parsing metadata about extension samples.""" | 6 """Class for parsing metadata about extension samples.""" |
| 7 | 7 |
| 8 import locale | 8 import locale |
| 9 import os | 9 import os |
| 10 import os.path | 10 import os.path |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 try: | 50 try: |
| 51 json_obj = json.load(json_file, encoding) | 51 json_obj = json.load(json_file, encoding) |
| 52 except ValueError, msg: | 52 except ValueError, msg: |
| 53 raise Exception("Failed to parse JSON out of file %s: %s" % (path, msg)) | 53 raise Exception("Failed to parse JSON out of file %s: %s" % (path, msg)) |
| 54 finally: | 54 finally: |
| 55 json_file.close() | 55 json_file.close() |
| 56 | 56 |
| 57 return json_obj | 57 return json_obj |
| 58 | 58 |
| 59 class ApiManifest(object): | 59 class ApiManifest(object): |
| 60 """ Represents the list of API methods contained in extension_api.json """ | 60 """ Represents the list of API methods contained in extension_api.json etc """ |
| 61 | 61 |
| 62 _MODULE_DOC_KEYS = ['functions', 'events'] | 62 _MODULE_DOC_KEYS = ['functions', 'events'] |
| 63 """ Keys which may be passed to the _parseModuleDocLinksByKey method.""" | 63 """ Keys which may be passed to the _parseModuleDocLinksByKey method.""" |
| 64 | 64 |
| 65 def __init__(self, manifest_paths): | 65 def __init__(self, manifest_paths): |
| 66 """ Read the supplied manifest file and parse its contents. | 66 """ Read the supplied manifest file and parse its contents. |
| 67 | 67 |
| 68 Args: | 68 Args: |
| 69 manifest_paths: Array of paths to API schemas (extension_api.json etc). | 69 manifest_paths: Array of paths to API schemas (extension_api.json etc). |
| 70 """ | 70 """ |
| (...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 715 zip_file.write(abspath, relpath) | 715 zip_file.write(abspath, relpath) |
| 716 if file == 'manifest.json': | 716 if file == 'manifest.json': |
| 717 info = zip_file.getinfo(zip_manifest_path) | 717 info = zip_file.getinfo(zip_manifest_path) |
| 718 info.comment = self['source_hash'] | 718 info.comment = self['source_hash'] |
| 719 except RuntimeError, msg: | 719 except RuntimeError, msg: |
| 720 raise Exception("Could not write zip at %s: %s" % (zip_path, msg)) | 720 raise Exception("Could not write zip at %s: %s" % (zip_path, msg)) |
| 721 finally: | 721 finally: |
| 722 zip_file.close() | 722 zip_file.close() |
| 723 | 723 |
| 724 return self._get_relative_zip_path() | 724 return self._get_relative_zip_path() |
| OLD | NEW |