refactor plugins.py
This commit is contained in:
parent
440c33b8e5
commit
2bf42162ef
@ -3,23 +3,28 @@
|
||||
from httpx import AsyncHTTPTransport
|
||||
from .base import BaseSourceProvider, BaseFilterProvider, BaseOutputProvider
|
||||
from . import sources
|
||||
from . import outputs
|
||||
from . import filters
|
||||
from . import outputs
|
||||
|
||||
|
||||
def unused():
|
||||
"""Чтобы убрать предупреждение о неиспользуемых импортах"""
|
||||
return sources, filters, outputs
|
||||
|
||||
|
||||
def use_plugins(config: dict, ipv4t: AsyncHTTPTransport, ipv6t: AsyncHTTPTransport):
|
||||
"""Регистрация всех плагинов указаных в конфигурации"""
|
||||
for source_name in config["sources"]:
|
||||
for source_name in config.get("sources", []):
|
||||
BaseSourceProvider.register_provider(
|
||||
source_name, config["sources"][source_name], ipv4t, ipv6t
|
||||
)
|
||||
|
||||
for filter_name in config["filters"]:
|
||||
for filter_name in config.get("filters", []):
|
||||
BaseFilterProvider.register_provider(
|
||||
filter_name, config["filters"][filter_name], ipv4t, ipv6t
|
||||
)
|
||||
|
||||
for output_name in config["outputs"]:
|
||||
for output_name in config.get("outputs", []):
|
||||
BaseOutputProvider.register_provider(
|
||||
output_name, config["outputs"][output_name], ipv4t, ipv6t
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user