OLD | NEW |
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 | |
7 import os | 6 import os |
8 import sys | 7 import sys |
9 | 8 |
10 _FILE_PATH = os.path.dirname(os.path.realpath(__file__)) | 9 _FILE_PATH = os.path.dirname(os.path.realpath(__file__)) |
11 _SYS_PATH = sys.path[:] | 10 _SYS_PATH = sys.path[:] |
12 try: | 11 try: |
13 _COMMENT_EATER_PATH = os.path.join( | 12 _COMMENT_EATER_PATH = os.path.join( |
14 _FILE_PATH, os.pardir, 'json_comment_eater') | 13 _FILE_PATH, os.pardir, 'json_comment_eater') |
15 sys.path.insert(0, _COMMENT_EATER_PATH) | 14 sys.path.insert(0, _COMMENT_EATER_PATH) |
16 import json_comment_eater | 15 import json_comment_eater |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 'json_schema_compiler')) | 49 'json_schema_compiler')) |
51 import simplejson | 50 import simplejson |
52 from simplejson import OrderedDict | 51 from simplejson import OrderedDict |
53 finally: | 52 finally: |
54 sys.path = _SYS_PATH | 53 sys.path = _SYS_PATH |
55 | 54 |
56 def Parse(json_str): | 55 def Parse(json_str): |
57 return simplejson.loads(json_comment_eater.Nom(json_str), | 56 return simplejson.loads(json_comment_eater.Nom(json_str), |
58 object_pairs_hook=OrderedDict) | 57 object_pairs_hook=OrderedDict) |
59 | 58 |
| 59 |
60 def IsDict(item): | 60 def IsDict(item): |
61 return isinstance(item, (dict, OrderedDict)) | 61 return isinstance(item, (dict, OrderedDict)) |
OLD | NEW |