refactor plugins.py
All checks were successful
Docker Image CI / test (push) Successful in 37s
Docker Image CI / push (push) Successful in 39s

This commit is contained in:
Dmitry Belyaev 2024-03-02 16:59:23 +03:00
parent 440c33b8e5
commit 2bf42162ef
Signed by: b4tman
GPG Key ID: 41A00BF15EA7E5F3

View File

@ -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
)