def distribute_config_updates(scaffolding, config_updates): if config_updates is None: return nested_config_updates = convert_to_nested_dict(config_updates) for path, value in iterate_flattened(nested_config_updates): for prefix, suffix in reversed(list(iter_path_splits(path))): if prefix in scaffolding: set_by_dotted_path(scaffolding[prefix].config_updates, suffix, value) break
def pick_relevant_config_updates(self, config_updates, past_paths): if config_updates is None: return for path, value in iterate_flattened(config_updates): for prefix, suffix in reversed(list(iter_path_splits(path))): if prefix in past_paths: # don't use config_updates for prior ingredients break elif prefix == self.path: set_by_dotted_path(self.config_updates, suffix, value) break
def test_iter_path_splits(): assert list(iter_path_splits('foo.bar.baz')) ==\ [('', 'foo.bar.baz'), ('foo', 'bar.baz'), ('foo.bar', 'baz')]
def test_iter_path_splits(): assert list(iter_path_splits("foo.bar.baz")) == [ ("", "foo.bar.baz"), ("foo", "bar.baz"), ("foo.bar", "baz"), ]