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

Side by Side Diff: tools/json_schema_compiler/json_parse.py

Issue 13599004: Fix some low hanging inefficiencies in the docs server (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 8 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 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import json 5 import json
6 import logging 6 import logging
7 import os 7 import os
8 import sys 8 import sys
9 9
10 _FILE_PATH = os.path.dirname(os.path.realpath(__file__)) 10 _FILE_PATH = os.path.dirname(os.path.realpath(__file__))
11 _SYS_PATH = sys.path[:] 11 _SYS_PATH = sys.path[:]
12 try: 12 try:
13 _COMMENT_EATER_PATH = os.path.join(_FILE_PATH, os.pardir) 13 _COMMENT_EATER_PATH = os.path.join(
14 _FILE_PATH, os.pardir, 'json_comment_eater')
14 sys.path.insert(0, _COMMENT_EATER_PATH) 15 sys.path.insert(0, _COMMENT_EATER_PATH)
15 import json_comment_eater 16 import json_comment_eater
16 finally: 17 finally:
17 sys.path = _SYS_PATH 18 sys.path = _SYS_PATH
18 19
19 try: 20 try:
20 from collections import OrderedDict 21 from collections import OrderedDict
21 22
22 # Successfully imported, so we're running Python >= 2.7, and json.loads 23 # Successfully imported, so we're running Python >= 2.7, and json.loads
23 # supports object_pairs_hook. 24 # supports object_pairs_hook.
(...skipping 27 matching lines...) Expand all
51 from simplejson import OrderedDict 52 from simplejson import OrderedDict
52 finally: 53 finally:
53 sys.path = _SYS_PATH 54 sys.path = _SYS_PATH
54 55
55 def Parse(json_str): 56 def Parse(json_str):
56 return simplejson.loads(json_comment_eater.Nom(json_str), 57 return simplejson.loads(json_comment_eater.Nom(json_str),
57 object_pairs_hook=OrderedDict) 58 object_pairs_hook=OrderedDict)
58 59
59 def IsDict(item): 60 def IsDict(item):
60 return isinstance(item, (dict, OrderedDict)) 61 return isinstance(item, (dict, OrderedDict))
OLDNEW
« no previous file with comments | « tools/json_comment_eater/json_comment_eater_test.py ('k') | tools/json_schema_compiler/memoize.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698