Skip to content

route_rules.core ¤

Classes:

RuleSet ¤

Bases: UserDict[str, set[str]]


              flowchart TD
              route_rules.core.RuleSet[RuleSet]

              

              click route_rules.core.RuleSet href "" "route_rules.core.RuleSet"
            

Methods:

Attributes:

domain property ¤

domain: set[str]

domain_suffix property ¤

domain_suffix: set[str]

ip_cidr property ¤

ip_cidr: set[str]

__missing__ ¤

__missing__(key: str) -> set[str]
Source code in src/route_rules/core/_ruleset.py
14
15
16
def __missing__(self, key: str) -> set[str]:
    self[key] = set()
    return self[key]

__or__ ¤

__or__(other: Mapping[str, Iterable[str]]) -> Self
Source code in src/route_rules/core/_ruleset.py
18
19
20
@override
def __or__(self, other: Mapping[str, Iterable[str]], /) -> Self:  # pyright: ignore[reportIncompatibleMethodOverride]
    return self.union(other)

__sub__ ¤

__sub__(other: Mapping[str, Iterable[str]]) -> Self
Source code in src/route_rules/core/_ruleset.py
22
23
def __sub__(self, other: Mapping[str, Iterable[str]], /) -> Self:
    return self.difference(other)

add ¤

add(typ: str, value: str) -> None
Source code in src/route_rules/core/_ruleset.py
37
38
39
def add(self, typ: str, value: str) -> None:
    typ = _ALIASES.get(typ, typ)
    self[typ].add(value)

difference ¤

difference(*others: Mapping[str, Iterable[str]]) -> Self
Source code in src/route_rules/core/_ruleset.py
50
51
52
53
def difference(self, *others: Mapping[str, Iterable[str]]) -> Self:
    return toolz.merge_with(
        lambda lst: set.difference(*lst), self, *others, factory=type(self)
    )

optimize ¤

optimize() -> Self
Source code in src/route_rules/core/_ruleset.py
41
42
43
def optimize(self) -> Self:
    # TODO: implement
    return self

union ¤

union(*others: Mapping[str, Iterable[str]]) -> Self
Source code in src/route_rules/core/_ruleset.py
45
46
47
48
def union(self, *others: Mapping[str, Iterable[str]]) -> Self:
    return toolz.merge_with(
        lambda lst: set.union(*lst), self, *others, factory=type(self)
    )