Files
pddnsc/pddnsc/plugins.py
Dmitry 2bf42162ef
All checks were successful
Docker Image CI / test (push) Successful in 37s
Docker Image CI / push (push) Successful in 39s
refactor plugins.py
2024-03-02 16:59:23 +03:00

31 lines
1.2 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
""" модуль взаимодействия и регистрации плагинов """
from httpx import AsyncHTTPTransport
from .base import BaseSourceProvider, BaseFilterProvider, BaseOutputProvider
from . import sources
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.get("sources", []):
BaseSourceProvider.register_provider(
source_name, config["sources"][source_name], ipv4t, ipv6t
)
for filter_name in config.get("filters", []):
BaseFilterProvider.register_provider(
filter_name, config["filters"][filter_name], ipv4t, ipv6t
)
for output_name in config.get("outputs", []):
BaseOutputProvider.register_provider(
output_name, config["outputs"][output_name], ipv4t, ipv6t
)