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

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

Issue 23549025: Clean up JSON Schema Compiler. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 3 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
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
7 import sys
8 6
9 import json_parse 7 import json_parse
10 import schema_util
11 8
12 def DeleteNodes(item, delete_key): 9 def DeleteNodes(item, delete_key):
13 """Deletes the given nodes in item, recursively, that have |delete_key| as 10 """Deletes the given nodes in item, recursively, that have |delete_key| as
14 an attribute. 11 an attribute.
15 """ 12 """
16 def HasKey(thing): 13 def HasKey(thing):
17 return json_parse.IsDict(thing) and thing.get(delete_key, False) 14 return json_parse.IsDict(thing) and thing.get(delete_key, False)
18 15
19 if json_parse.IsDict(item): 16 if json_parse.IsDict(item):
20 toDelete = [] 17 toDelete = []
(...skipping 20 matching lines...) Expand all
41 _cache = {} 38 _cache = {}
42 39
43 def CachedLoad(filename): 40 def CachedLoad(filename):
44 """Equivalent to Load(filename), but caches results for subsequent calls""" 41 """Equivalent to Load(filename), but caches results for subsequent calls"""
45 if filename not in _cache: 42 if filename not in _cache:
46 _cache[filename] = Load(filename) 43 _cache[filename] = Load(filename)
47 # 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
48 # the next caller. 45 # the next caller.
49 return copy.deepcopy(_cache[filename]) 46 return copy.deepcopy(_cache[filename])
50 47
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698