| 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 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 Loading... |
| 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 |
| OLD | NEW |