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

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

Issue 11827026: Overhaul JSON Schema Compiler to support a number of features required to (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 11 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
« no previous file with comments | « tools/json_schema_compiler/idl_schema_test.py ('k') | tools/json_schema_compiler/model.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 copy 5 import copy
6 import os 6 import os
7 import sys 7 import sys
8 8
9 import json_parse 9 import json_parse
10 import schema_util 10 import schema_util
(...skipping 13 matching lines...) Expand all
24 del item[key] 24 del item[key]
25 elif type(item) == list: 25 elif type(item) == list:
26 item[:] = [DeleteNocompileNodes(thing) 26 item[:] = [DeleteNocompileNodes(thing)
27 for thing in item if not HasNocompile(thing)] 27 for thing in item if not HasNocompile(thing)]
28 28
29 return item 29 return item
30 30
31 def Load(filename): 31 def Load(filename):
32 with open(filename, 'r') as handle: 32 with open(filename, 'r') as handle:
33 schemas = json_parse.Parse(handle.read()) 33 schemas = json_parse.Parse(handle.read())
34 schema_util.PrefixSchemasWithNamespace(schemas)
35 return schemas 34 return schemas
36 35
37 # A dictionary mapping |filename| to the object resulting from loading the JSON 36 # A dictionary mapping |filename| to the object resulting from loading the JSON
38 # at |filename|. 37 # at |filename|.
39 _cache = {} 38 _cache = {}
40 39
41 def CachedLoad(filename): 40 def CachedLoad(filename):
42 """Equivalent to Load(filename), but caches results for subsequent calls""" 41 """Equivalent to Load(filename), but caches results for subsequent calls"""
43 if filename not in _cache: 42 if filename not in _cache:
44 _cache[filename] = Load(filename) 43 _cache[filename] = Load(filename)
45 # Return a copy of the object so that any changes a caller makes won't affect 44 # Return a copy of the object so that any changes a caller makes won't affect
46 # the next caller. 45 # the next caller.
47 return copy.deepcopy(_cache[filename]) 46 return copy.deepcopy(_cache[filename])
OLDNEW
« no previous file with comments | « tools/json_schema_compiler/idl_schema_test.py ('k') | tools/json_schema_compiler/model.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698