Exemplo n.º 1
0
def _filter_tree(struct_tree: Optional[StructuredDataNode]) -> Optional[StructuredDataNode]:
    if struct_tree is None:
        return None

    if permitted_paths := _get_permitted_inventory_paths():
        return struct_tree.get_filtered_node([
            make_filter((parse_visible_raw_path(entry["path"]), entry.get("attributes")))
            for entry in permitted_paths
        ])
Exemplo n.º 2
0
def _get_intervals_from_config(
        raw_intervals_from_config: RawIntervalsFromConfig
) -> IntervalsFromConfig:
    intervals: IntervalsFromConfig = {}

    for entry in raw_intervals_from_config:
        interval = entry["interval"]
        node_path = tuple(parse_visible_raw_path(entry["visible_raw_path"]))

        if for_attributes := entry.get("attributes"):
            intervals.setdefault((node_path, ATTRIBUTES_KEY),
                                 IntervalFromConfig(for_attributes, interval))

        if for_table := entry.get("columns"):
            intervals.setdefault((node_path, TABLE_KEY),
                                 IntervalFromConfig(for_table, interval))
Exemplo n.º 3
0
def test_parse_visible_tree_path(raw_path, expected_path):
    assert parse_visible_raw_path(raw_path) == expected_path