def json_fixup(obj): if isinstance(obj, RecipeConfigType): return str(obj) thawed = infra_types.thaw(obj) if thawed is not obj: # i.e. it was a frozen type return thawed raise TypeError("%r is not JSON serializable" % obj)
def set_val(self, val): if isinstance(val, ConfigBase): val = val.as_jsonish(include_hidden=True) if isinstance(val, infra_types.FrozenDict): val = infra_types.thaw(val) typeAssert(val, dict) val = dict(val) # because we pop later. for name, config_obj in self._type_map.iteritems(): if name in val: try: config_obj.set_val(val.pop(name)) except Exception as e: raise Exception('While assigning key %r: %s' % (name, e)) if val: raise TypeError("Got extra keys while setting ConfigGroup: %s" % val)
def thaw(self): """Returns a vanilla python jsonish dictionary of properties.""" return thaw(self._engine.properties)