refactor base + ignore .env

This commit is contained in:
Dmitry Belyaev 2024-02-20 12:57:40 +03:00
parent 312875ed2b
commit 4fc2116dcb
Signed by: b4tman
GPG Key ID: 41A00BF15EA7E5F3
2 changed files with 15 additions and 5 deletions

3
.gitignore vendored
View File

@ -1,3 +1,4 @@
.venv/ .venv/
state/* state/*
__pycache__ __pycache__
.env*

View File

@ -21,6 +21,9 @@ class BaseSourceProvider(ABC):
ipv4t, ipv4t,
ipv6t, ipv6t,
) )
self.post_init()
def post_init(self): ...
def __str__(self): def __str__(self):
return f"{self.__class__.__name__}: {self.name}" return f"{self.__class__.__name__}: {self.name}"
@ -68,6 +71,9 @@ class BaseOutputProvider(ABC):
def __init__(self, name, config, ipv4t, ipv6t): def __init__(self, name, config, ipv4t, ipv6t):
self.name, self.config = name, config self.name, self.config = name, config
self.ipv4t, self.ipv6t = ipv4t, ipv6t self.ipv4t, self.ipv6t = ipv4t, ipv6t
self.post_init()
def post_init(self): ...
def __init_subclass__(cls) -> None: def __init_subclass__(cls) -> None:
BaseOutputProvider._childs[cls.__name__] = cls BaseOutputProvider._childs[cls.__name__] = cls
@ -76,10 +82,10 @@ class BaseOutputProvider(ABC):
def __str__(self): def __str__(self):
return f"{self.__class__.__name__}: {self.name}" return f"{self.__class__.__name__}: {self.name}"
def best_client(self, addr_v4, addr_v6): def best_transport(self, addr_v4, addr_v6):
if addr_v6 is None and addr_v4 is not None: if addr_v6:
return self.ipv4t return self.ipv6t
return self.ipv6t return self.ipv4t
@classmethod @classmethod
def validate_source_config(cls, name, config): def validate_source_config(cls, name, config):
@ -111,6 +117,9 @@ class BaseFilterProvider(ABC):
def __init__(self, name, config, ipv4t, ipv6t): def __init__(self, name, config, ipv4t, ipv6t):
self.name, self.config = name, config self.name, self.config = name, config
self.ipv4t, self.ipv6t = ipv4t, ipv6t self.ipv4t, self.ipv6t = ipv4t, ipv6t
self.post_init()
def post_init(self): ...
def __init_subclass__(cls) -> None: def __init_subclass__(cls) -> None:
BaseFilterProvider._childs[cls.__name__] = cls BaseFilterProvider._childs[cls.__name__] = cls