Exemple #1
0
    def delete_multiple(self, var: Variable, period_content: Dict) -> None:
        list_base_var: Variable = self.schema.get(var.nearest_list)
        assert not list_base_var.descends_from_list, "Nested list handling not implemented"
        try:
            content: Union[Dict,
                           List] = nesteddicts.get(period_content,
                                                   list_base_var.absolute_path)
            if content is None:
                return
        except MissingDataError:
            return

        for element in _elements_of(content):  # type: Dict
            try:
                nesteddicts.delete(element, var.relative_path)
            except MissingDataError:
                continue
Exemple #2
0
 def del_immutable(self, var_id: VariableId) -> None:
     var = self.as_var(var_id, track_type=TrackType.IMMUTABLE)
     path: List = ["immutable"] + list(var.absolute_path)
     nesteddicts.delete(self.content, path)
Exemple #3
0
 def del_observation(self, var_id: VariableId, period: str) -> None:
     var = self.as_var(var_id, track_type=TrackType.TEMPORAL)
     path: List = [period] + list(var.absolute_path)
     nesteddicts.delete(self.content, path)
def test_delete(target: Dict):
    spec: List[str] = ["a", "b", "c"]
    nesteddicts.delete(target, spec)

    expected: Dict = {"a": {"b": {}}}
    assert expected == target
def test_delete_passthru():
    target: Dict = {}
    spec: List[str] = ["a", "b", "c"]
    nesteddicts.delete(target, spec)
    assert {} == target