| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 """Recipe Configuration Meta DSL. | 5 """Recipe Configuration Meta DSL. |
| 6 | 6 |
| 7 This module contains, essentially, a DSL for writing composable configurations. | 7 This module contains, essentially, a DSL for writing composable configurations. |
| 8 You start by defining a schema which describes how your configuration blobs will | 8 You start by defining a schema which describes how your configuration blobs will |
| 9 be structured, and what data they can contain. For example: | 9 be structured, and what data they can contain. For example: |
| 10 | 10 |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 def set_val(self, val): | 366 def set_val(self, val): |
| 367 if isinstance(val, ConfigBase): | 367 if isinstance(val, ConfigBase): |
| 368 val = val.as_jsonish(include_hidden=True) | 368 val = val.as_jsonish(include_hidden=True) |
| 369 assert isinstance(val, dict) | 369 assert isinstance(val, dict) |
| 370 for name, config_obj in self._type_map.iteritems(): | 370 for name, config_obj in self._type_map.iteritems(): |
| 371 if name in val: | 371 if name in val: |
| 372 config_obj.set_val(val.pop()) | 372 config_obj.set_val(val.pop()) |
| 373 assert not val, "Got extra keys while setting ConfigGroup: %s" % val | 373 assert not val, "Got extra keys while setting ConfigGroup: %s" % val |
| 374 | 374 |
| 375 def as_jsonish(self, include_hidden=False): | 375 def as_jsonish(self, include_hidden=False): |
| 376 return { | 376 return dict( |
| 377 n: v.as_jsonish(include_hidden) for n, v in self._type_map.iteritems() | 377 (n, v.as_jsonish(include_hidden)) for n, v in self._type_map.iteritems() |
| 378 if (include_hidden or not v._hidden)} # pylint: disable=W0212 | 378 if (include_hidden or not v._hidden)) # pylint: disable=W0212 |
| 379 | 379 |
| 380 def reset(self): | 380 def reset(self): |
| 381 for v in self._type_map.values(): | 381 for v in self._type_map.values(): |
| 382 v.reset() | 382 v.reset() |
| 383 | 383 |
| 384 def complete(self): | 384 def complete(self): |
| 385 return all(v.complete() for v in self._type_map.values()) | 385 return all(v.complete() for v in self._type_map.values()) |
| 386 | 386 |
| 387 | 387 |
| 388 class ConfigList(ConfigBase, collections.MutableSequence): | 388 class ConfigList(ConfigBase, collections.MutableSequence): |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 assert False | 675 assert False |
| 676 | 676 |
| 677 def as_jsonish(self, _include_hidden=None): | 677 def as_jsonish(self, _include_hidden=None): |
| 678 assert False | 678 assert False |
| 679 | 679 |
| 680 def reset(self): | 680 def reset(self): |
| 681 assert False | 681 assert False |
| 682 | 682 |
| 683 def complete(self): | 683 def complete(self): |
| 684 return True | 684 return True |
| OLD | NEW |