route_rules
¤
Modules:
Classes:
-
ArtifactMeta
– -
Behavior
– -
Builder
– -
Config
– -
Format
– -
Meta
– -
Provider
– -
ProviderMeta
– -
ProviderMihomo
– -
ProviderRegistry
– -
Recipe
– -
RecipeMeta
– -
RecipeWrapper
– -
RuleSet
–.
Functions:
-
download
–
Behavior
¤
Builder
¤
Parameters:
-
dist_dir
(Path
, default:PosixPath('dist')
) – -
exporters
(list[ExporterMihomo]
, default:[ExporterMihomo(behavior=<Behavior.DOMAIN: 'domain'>, format=<Format.MRS: 'mrs'>, export_path_template='mihomo/{slug}.{behavior}{format.ext}'), ExporterMihomo(behavior=<Behavior.DOMAIN: 'domain'>, format=<Format.TEXT: 'text'>, export_path_template='mihomo/{slug}.{behavior}{format.ext}'), ExporterMihomo(behavior=<Behavior.IPCIDR: 'ipcidr'>, format=<Format.MRS: 'mrs'>, export_path_template='mihomo/{slug}.{behavior}{format.ext}'), ExporterMihomo(behavior=<Behavior.IPCIDR: 'ipcidr'>, format=<Format.TEXT: 'text'>, export_path_template='mihomo/{slug}.{behavior}{format.ext}'), ExporterMihomo(behavior=<Behavior.CLASSICAL: 'classical'>, format=<Format.TEXT: 'text'>, export_path_template='mihomo/{slug}.{behavior}{format.ext}')]
) – -
recipes
(list[RecipeWrapper]
, default:<dynamic>
) –Built-in mutable sequence.
If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified.
Methods:
-
build
– -
build_recipe
– -
load
–
Attributes:
-
dist_dir
(Path
) – -
exporters
(list[ExporterMihomo]
) – -
recipes
(list[RecipeWrapper]
) –
exporters
class-attribute
instance-attribute
¤
exporters: list[ExporterMihomo] = field(
factory=_default_exporters
)
build
async
¤
build() -> None
Source code in src/route_rules/gen/_builder.py
42 43 44 45 46 |
|
build_recipe
async
¤
build_recipe(recipe: RecipeWrapper) -> RecipeMeta
Source code in src/route_rules/gen/_builder.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
|
load
classmethod
¤
Source code in src/route_rules/gen/_builder.py
34 35 36 37 38 39 40 |
|
Config
pydantic-model
¤
Bases: BaseModel
Parameters:
-
recipes
(list[RecipeConfig]
) –
Show JSON schema:
{
"$defs": {
"RecipeConfig": {
"properties": {
"name": {
"title": "Name",
"type": "string"
},
"providers": {
"items": {
"type": "string"
},
"title": "Providers",
"type": "array"
}
},
"required": [
"name",
"providers"
],
"title": "RecipeConfig",
"type": "object"
}
},
"properties": {
"recipes": {
"items": {
"$ref": "#/$defs/RecipeConfig"
},
"title": "Recipes",
"type": "array"
}
},
"required": [
"recipes"
],
"title": "Config",
"type": "object"
}
Fields:
Format
¤
Meta
¤
Bases: Struct
Parameters:
-
build_time
(datetime
) – -
recipes
(list[RecipeMeta]
, default:<dynamic>
) –Built-in mutable sequence.
If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified.
Methods:
Attributes:
-
build_time
(datetime
) – -
recipes
(list[RecipeMeta]
) –
recipes
class-attribute
instance-attribute
¤
recipes: list[RecipeMeta] = field(default_factory=list)
json_decode
classmethod
¤
Source code in src/route_rules/gen/_meta.py
41 42 43 |
|
Provider
¤
Bases: ABC
Parameters:
Methods:
-
download_url
– -
load
– -
preview_url
–
Attributes:
-
download_url_template
(str
) – -
name
(str
) – -
preview_url_template
(str
) –
preview_url_template
class-attribute
instance-attribute
¤
preview_url_template: str = field(
default=Factory(
_default_preview_url_template, takes_self=True
)
)
download_url
¤
Source code in src/route_rules/provider/_abc.py
26 27 28 |
|
load
abstractmethod
async
¤
Source code in src/route_rules/provider/_abc.py
30 31 32 |
|
ProviderMeta
¤
ProviderMihomo
¤
Bases: Provider
Parameters:
-
name
(str
) – -
download_url_template
(str
) – -
preview_url_template
(str
, default:<dynamic>
) – -
behavior
(Behavior
) – -
format
(Format
, default:<Format.YAML: 'yaml'>
) –
Methods:
-
download_url
– -
load
– -
preview_url
–
Attributes:
-
behavior
(Behavior
) – -
download_url_template
(str
) – -
format
(Format
) – -
name
(str
) – -
preview_url_template
(str
) –
preview_url_template
class-attribute
instance-attribute
¤
preview_url_template: str = field(
default=Factory(
_default_preview_url_template, takes_self=True
)
)
download_url
¤
Source code in src/route_rules/provider/_abc.py
26 27 28 |
|
load
async
¤
Source code in src/route_rules/provider/mihomo/_provider.py
20 21 22 23 24 |
|
ProviderRegistry
¤
Parameters:
-
registry
(dict[str, Provider]
, default:<class 'dict'>
) –dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)
Methods:
-
download_url
– -
load
– -
presets
– -
preview_url
– -
register
–
Attributes:
download_url
¤
Source code in src/route_rules/provider/_registry.py
57 58 59 60 61 |
|
load
async
¤
Source code in src/route_rules/provider/_registry.py
63 64 65 66 67 |
|
presets
cached
classmethod
¤
presets() -> Self
Source code in src/route_rules/provider/_registry.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
|
preview_url
¤
Source code in src/route_rules/provider/_registry.py
69 70 71 72 73 |
|
Recipe
¤
Parameters:
-
name
(str
) – -
providers
(list[str]
) – -
registry
(ProviderRegistry
, default:ProviderRegistry(registry={'blackmatrix7': ProviderMihomo(name='blackmatrix7', download_url_template='https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Clash/{name}/{name}.list', preview_url_template='https://github.com/blackmatrix7/ios_rule_script/tree/master/rule/Clash/{name}', _cache=LRUCache({}, maxsize=65536, currsize=0), behavior=<Behavior.CLASSICAL: 'classical'>, format=<Format.TEXT: 'text'>), 'dler-io': ProviderMihomo(name='dler-io', download_url_template='https://raw.githubusercontent.com/dler-io/Rules/main/Clash/Provider/{name}.yaml', preview_url_template='https://github.com/dler-io/Rules/blob/main/Clash/Provider/{name}.yaml', _cache=LRUCache({}, maxsize=65536, currsize=0), behavior=<Behavior.CLASSICAL: 'classical'>, format=<Format.YAML: 'yaml'>), 'MetaCubeX/geosite': ProviderMihomo(name='MetaCubeX/geosite', download_url_template='https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/meta/geo/geosite/{name}.yaml', preview_url_template='https://github.com/MetaCubeX/meta-rules-dat/blob/meta/geo/geosite/{name}.yaml', _cache=LRUCache({}, maxsize=65536, currsize=0), behavior=<Behavior.DOMAIN: 'domain'>, format=<Format.YAML: 'yaml'>), 'SukkaW/classical': ProviderMihomo(name='SukkaW/classical', download_url_template='https://ruleset.skk.moe/Clash/{name}.txt', preview_url_template='https://ruleset.skk.moe/Clash/{name}.txt', _cache=LRUCache({}, maxsize=65536, currsize=0), behavior=<Behavior.CLASSICAL: 'classical'>, format=<Format.TEXT: 'text'>), 'SukkaW/domain': ProviderMihomo(name='SukkaW/domain', download_url_template='https://ruleset.skk.moe/Clash/{name}.txt', preview_url_template='https://ruleset.skk.moe/Clash/{name}.txt', _cache=LRUCache({}, maxsize=65536, currsize=0), behavior=<Behavior.DOMAIN: 'domain'>, format=<Format.TEXT: 'text'>)})
) – -
slug
(str
, default:<dynamic>
) –
Methods:
-
build
–
Attributes:
registry
class-attribute
instance-attribute
¤
registry: ProviderRegistry = field(
factory=presets, kw_only=True
)
slug
class-attribute
instance-attribute
¤
slug: str = field(
default=Factory(default_slug, takes_self=True),
kw_only=True,
)
build
async
¤
build() -> RuleSet
Source code in src/route_rules/core/_recipe.py
28 29 30 31 32 33 34 |
|
RecipeMeta
¤
Bases: Struct
Parameters:
-
name
(str
) – -
slug
(str
) – -
artifacts
(list[ArtifactMeta]
, default:<dynamic>
) –Built-in mutable sequence.
If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified.
-
providers
(list[ProviderMeta]
, default:<dynamic>
) –Built-in mutable sequence.
If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified.
-
statistics
(RecipeStatistics
, default:<dynamic>
) –
Attributes:
-
artifacts
(list[ArtifactMeta]
) – -
name
(str
) – -
providers
(list[ProviderMeta]
) – -
slug
(str
) – -
statistics
(RecipeStatistics
) –
artifacts
class-attribute
instance-attribute
¤
artifacts: list[ArtifactMeta] = field(default_factory=list)
providers
class-attribute
instance-attribute
¤
providers: list[ProviderMeta] = field(default_factory=list)
RecipeWrapper
¤
Bases: Recipe
Parameters:
-
name
(str
) – -
providers
(list[str]
) – -
registry
(ProviderRegistry
, default:ProviderRegistry(registry={'blackmatrix7': ProviderMihomo(name='blackmatrix7', download_url_template='https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Clash/{name}/{name}.list', preview_url_template='https://github.com/blackmatrix7/ios_rule_script/tree/master/rule/Clash/{name}', _cache=LRUCache({}, maxsize=65536, currsize=0), behavior=<Behavior.CLASSICAL: 'classical'>, format=<Format.TEXT: 'text'>), 'dler-io': ProviderMihomo(name='dler-io', download_url_template='https://raw.githubusercontent.com/dler-io/Rules/main/Clash/Provider/{name}.yaml', preview_url_template='https://github.com/dler-io/Rules/blob/main/Clash/Provider/{name}.yaml', _cache=LRUCache({}, maxsize=65536, currsize=0), behavior=<Behavior.CLASSICAL: 'classical'>, format=<Format.YAML: 'yaml'>), 'MetaCubeX/geosite': ProviderMihomo(name='MetaCubeX/geosite', download_url_template='https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/meta/geo/geosite/{name}.yaml', preview_url_template='https://github.com/MetaCubeX/meta-rules-dat/blob/meta/geo/geosite/{name}.yaml', _cache=LRUCache({}, maxsize=65536, currsize=0), behavior=<Behavior.DOMAIN: 'domain'>, format=<Format.YAML: 'yaml'>), 'SukkaW/classical': ProviderMihomo(name='SukkaW/classical', download_url_template='https://ruleset.skk.moe/Clash/{name}.txt', preview_url_template='https://ruleset.skk.moe/Clash/{name}.txt', _cache=LRUCache({}, maxsize=65536, currsize=0), behavior=<Behavior.CLASSICAL: 'classical'>, format=<Format.TEXT: 'text'>), 'SukkaW/domain': ProviderMihomo(name='SukkaW/domain', download_url_template='https://ruleset.skk.moe/Clash/{name}.txt', preview_url_template='https://ruleset.skk.moe/Clash/{name}.txt', _cache=LRUCache({}, maxsize=65536, currsize=0), behavior=<Behavior.DOMAIN: 'domain'>, format=<Format.TEXT: 'text'>)})
) – -
slug
(str
, default:<dynamic>
) –
Methods:
-
build
– -
from_config
–
Attributes:
registry
class-attribute
instance-attribute
¤
registry: ProviderRegistry = field(
factory=presets, kw_only=True
)
slug
class-attribute
instance-attribute
¤
slug: str = field(
default=Factory(default_slug, takes_self=True),
kw_only=True,
)
build
async
¤
build() -> RuleSet
Source code in src/route_rules/core/_recipe.py
28 29 30 31 32 33 34 |
|
RuleSet
¤
Bases: UserDict[str, set[str]]
.
References
Methods:
-
__missing__
– -
__or__
– -
add
– -
optimize
– -
union
–
Attributes:
__missing__
¤
Source code in src/route_rules/core/_ruleset.py
21 22 23 |
|
__or__
¤
Source code in src/route_rules/core/_ruleset.py
14 15 16 17 18 19 |
|
add
¤
Source code in src/route_rules/core/_ruleset.py
37 38 39 40 41 |
|
optimize
¤
optimize() -> Self
Source code in src/route_rules/core/_ruleset.py
43 44 45 |
|
union
¤
Source code in src/route_rules/core/_ruleset.py
47 48 49 50 51 52 53 |
|
download
async
¤
download(url: str) -> Response
Source code in src/route_rules/utils/_download.py
9 10 11 12 13 14 15 16 |
|