def add_from_dict(self, d): """Returns a new config from this config with another layer added from a given dictionary. """ layer = {} rv = Config() rv.stack = self.stack + [layer] def _walk(d, prefix): for key, value in d.iteritems(): if isinstance(value, dict): _walk(value, prefix + key + '.') else: layer[prefix + key] = value _walk(d, '') return rv
def add_from_dict(self, d): """Returns a new config from this config with another layer added from a given dictionary. """ layer = {} rv = Config() rv.stack = self.stack + [layer] def _walk(d, prefix): for key, value in d.iteritems(): if isinstance(value, dict): _walk(value, prefix + key + ".") else: layer[prefix + key] = value _walk(d, "") return rv