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

Side by Side Diff: third_party/chrome/tools/json_schema.py

Issue 12300042: Update idlsync.py to pull in dependencies required for chrome api generation. (Closed) Base URL: git://github.com/dart-lang/bleeding_edge.git@master
Patch Set: From another checkout Created 7 years, 10 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
OLDNEW
(Empty)
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
3 # found in the LICENSE file.
4
5 import copy
6 import os
7 import sys
8
9 import json_parse
10 import schema_util
11
12 def DeleteNocompileNodes(item):
13 def HasNocompile(thing):
14 return json_parse.IsDict(thing) and thing.get('nocompile', False)
15
16 if json_parse.IsDict(item):
17 toDelete = []
18 for key, value in item.items():
19 if HasNocompile(value):
20 toDelete.append(key)
21 else:
22 DeleteNocompileNodes(value)
23 for key in toDelete:
24 del item[key]
25 elif type(item) == list:
26 item[:] = [DeleteNocompileNodes(thing)
27 for thing in item if not HasNocompile(thing)]
28
29 return item
30
31 def Load(filename):
32 with open(filename, 'r') as handle:
33 schemas = json_parse.Parse(handle.read())
34 return schemas
35
36 # A dictionary mapping |filename| to the object resulting from loading the JSON
37 # at |filename|.
38 _cache = {}
39
40 def CachedLoad(filename):
41 """Equivalent to Load(filename), but caches results for subsequent calls"""
42 if filename not in _cache:
43 _cache[filename] = Load(filename)
44 # Return a copy of the object so that any changes a caller makes won't affect
45 # the next caller.
46 return copy.deepcopy(_cache[filename])
OLDNEW
« no previous file with comments | « third_party/chrome/tools/json_parse.py ('k') | third_party/chrome/tools/json_schema_compiler/PRESUBMIT.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698