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

Side by Side Diff: chrome/common/extensions/docs/build/directory.py

Issue 9582013: Revert 124660 - Allow comments in extension config files. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 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
11 import re 11 import re
12 import hashlib 12 import hashlib
13 import zipfile 13 import zipfile
14 import simplejson as json 14 import simplejson as json
15 import json_minify as minify
16 15
17 # Make sure we get consistent string sorting behavior by explicitly using the 16 # Make sure we get consistent string sorting behavior by explicitly using the
18 # default C locale. 17 # default C locale.
19 locale.setlocale(locale.LC_ALL, 'C') 18 locale.setlocale(locale.LC_ALL, 'C')
20 19
21 def sorted_walk(path): 20 def sorted_walk(path):
22 """ A version of os.walk that yields results in order sorted by name. 21 """ A version of os.walk that yields results in order sorted by name.
23 22
24 This is to prevent spurious docs changes due to os.walk returning items in a 23 This is to prevent spurious docs changes due to os.walk returning items in a
25 filesystem dependent order (by inode creation time, etc). 24 filesystem dependent order (by inode creation time, etc).
(...skipping 16 matching lines...) Expand all
42 Raises: 41 Raises:
43 Exception: If the file could not be read or its contents could not be 42 Exception: If the file could not be read or its contents could not be
44 parsed as JSON data. 43 parsed as JSON data.
45 """ 44 """
46 try: 45 try:
47 json_file = open(path, 'r') 46 json_file = open(path, 'r')
48 except IOError, msg: 47 except IOError, msg:
49 raise Exception("Failed to read the file at %s: %s" % (path, msg)) 48 raise Exception("Failed to read the file at %s: %s" % (path, msg))
50 49
51 try: 50 try:
52 json_str = json_file.read() 51 json_obj = json.load(json_file, encoding)
53 json_obj = json.loads(minify.json_minify(json_str), encoding)
54 except ValueError, msg: 52 except ValueError, msg:
55 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))
56 finally: 54 finally:
57 json_file.close() 55 json_file.close()
58 56
59 return json_obj 57 return json_obj
60 58
61 class ApiManifest(object): 59 class ApiManifest(object):
62 """ Represents the list of API methods contained in the extension API JSON """ 60 """ Represents the list of API methods contained in the extension API JSON """
63 61
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 zip_file.write(abspath, relpath) 727 zip_file.write(abspath, relpath)
730 if file == 'manifest.json': 728 if file == 'manifest.json':
731 info = zip_file.getinfo(zip_manifest_path) 729 info = zip_file.getinfo(zip_manifest_path)
732 info.comment = self['source_hash'] 730 info.comment = self['source_hash']
733 except RuntimeError, msg: 731 except RuntimeError, msg:
734 raise Exception("Could not write zip at %s: %s" % (zip_path, msg)) 732 raise Exception("Could not write zip at %s: %s" % (zip_path, msg))
735 finally: 733 finally:
736 zip_file.close() 734 zip_file.close()
737 735
738 return self._get_relative_zip_path() 736 return self._get_relative_zip_path()
OLDNEW
« no previous file with comments | « chrome/common/extensions/api/windows.json ('k') | chrome/common/extensions/docs/js/api_page_generator.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698