Skip to content

route_rules.export ¤

Classes:

Exporter ¤

Bases: ABC


              flowchart TD
              route_rules.export.Exporter[Exporter]

              

              click route_rules.export.Exporter href "" "route_rules.export.Exporter"
            

Methods:

export abstractmethod ¤

export(
    folder: str | PathLike[str], slug: str, ruleset: RuleSet
) -> Path | None
Source code in src/route_rules/export/_abc.py
12
13
14
15
16
@abc.abstractmethod
def export(
    self, folder: str | os.PathLike[str], slug: str, ruleset: RuleSet
) -> Path | None:
    raise NotImplementedError

ExporterMihomo ¤

Bases: Exporter


              flowchart TD
              route_rules.export.ExporterMihomo[ExporterMihomo]
              route_rules.export._abc.Exporter[Exporter]

                              route_rules.export._abc.Exporter --> route_rules.export.ExporterMihomo
                


              click route_rules.export.ExporterMihomo href "" "route_rules.export.ExporterMihomo"
              click route_rules.export._abc.Exporter href "" "route_rules.export._abc.Exporter"
            

Parameters:

Methods:

Attributes:

behavior instance-attribute ¤

behavior: Behavior

format instance-attribute ¤

format: Format

export ¤

export(
    folder: str | PathLike[str], slug: str, ruleset: RuleSet
) -> Path | None
Source code in src/route_rules/export/_mihomo.py
23
24
25
26
27
28
29
30
31
32
33
34
@override
def export(
    self, folder: str | os.PathLike[str], slug: str, ruleset: RuleSet
) -> Path | None:
    data: bytes = encode(ruleset, behavior=self.behavior, format=self.format)
    if not data:
        return None
    folder = Path(folder)
    file: Path = folder / "mihomo" / f"{slug}.{self.behavior}{self.format.ext}"
    file.parent.mkdir(parents=True, exist_ok=True)
    file.write_bytes(data)
    return file