WIP: dev into master #184
@@ -28,6 +28,4 @@ class ApplicationABC(ABC):
|
||||
Console.close()
|
||||
|
||||
@abstractmethod
|
||||
def main(self):
|
||||
r"""Main method of application"""
|
||||
pass
|
||||
def main(self): ...
|
||||
|
||||
@@ -5,9 +5,7 @@ from cpl.dependency import ServiceProviderABC
|
||||
|
||||
class ApplicationExtensionABC(ABC):
|
||||
@abstractmethod
|
||||
def __init__(self):
|
||||
pass
|
||||
def __init__(self): ...
|
||||
|
||||
@abstractmethod
|
||||
def run(self, services: ServiceProviderABC):
|
||||
pass
|
||||
def run(self, services: ServiceProviderABC): ...
|
||||
|
||||
@@ -7,13 +7,11 @@ class StartupABC(ABC):
|
||||
r"""ABC for the startup class"""
|
||||
|
||||
@abstractmethod
|
||||
def __init__(self):
|
||||
pass
|
||||
def __init__(self): ...
|
||||
|
||||
@abstractmethod
|
||||
def configure_configuration(self):
|
||||
r"""Creates configuration of application
|
||||
"""
|
||||
r"""Creates configuration of application"""
|
||||
|
||||
@abstractmethod
|
||||
def configure_services(self, service: ServiceCollection):
|
||||
|
||||
@@ -7,14 +7,11 @@ class StartupExtensionABC(ABC):
|
||||
r"""ABC for startup extension classes"""
|
||||
|
||||
@abstractmethod
|
||||
def __init__(self):
|
||||
pass
|
||||
def __init__(self): ...
|
||||
|
||||
@abstractmethod
|
||||
def configure_configuration(self):
|
||||
r"""Creates configuration of application
|
||||
|
||||
"""
|
||||
r"""Creates configuration of application"""
|
||||
|
||||
@abstractmethod
|
||||
def configure_services(self, services: ServiceCollection):
|
||||
|
||||
@@ -14,4 +14,4 @@ class Host:
|
||||
if asyncio.iscoroutinefunction(func):
|
||||
return cls._loop.run_until_complete(func(*args, **kwargs))
|
||||
|
||||
return func(*args, **kwargs)
|
||||
return func(*args, **kwargs)
|
||||
|
||||
@@ -2,4 +2,6 @@ from abc import ABC
|
||||
|
||||
|
||||
class ConfigurationModelABC(ABC):
|
||||
pass
|
||||
r"""
|
||||
ABC for configuration model classes
|
||||
"""
|
||||
|
||||
@@ -7,12 +7,10 @@ class LoggerABC(ABC):
|
||||
r"""ABC for :class:`cpl.core.log.logger_service.Logger`"""
|
||||
|
||||
@abstractmethod
|
||||
def set_level(self, level: str):
|
||||
pass
|
||||
def set_level(self, level: str): ...
|
||||
|
||||
@abstractmethod
|
||||
def _format_message(self, level: str, timestamp, *messages: Messages) -> str:
|
||||
pass
|
||||
def _format_message(self, level: str, timestamp, *messages: Messages) -> str: ...
|
||||
|
||||
@abstractmethod
|
||||
def header(self, string: str):
|
||||
|
||||
@@ -7,10 +7,8 @@ from cpl.core.typing import T
|
||||
class PipeABC(ABC, Generic[T]):
|
||||
@staticmethod
|
||||
@abstractmethod
|
||||
def to_str(value: T, *args) -> str:
|
||||
pass
|
||||
def to_str(value: T, *args) -> str: ...
|
||||
|
||||
@staticmethod
|
||||
@abstractmethod
|
||||
def from_str(value: str, *args) -> T:
|
||||
pass
|
||||
def from_str(value: str, *args) -> T: ...
|
||||
|
||||
@@ -42,6 +42,5 @@ def add_postgres(collection: _ServiceCollection):
|
||||
_add(collection, DBContext, 5432, ServerTypes.POSTGRES.value)
|
||||
|
||||
|
||||
|
||||
_ServiceCollection.with_module(add_mysql, _mysql.__name__)
|
||||
_ServiceCollection.with_module(add_postgres, _postgres.__name__)
|
||||
|
||||
@@ -9,18 +9,15 @@ class ConnectionABC(ABC):
|
||||
r"""ABC for the :class:`cpl.database.connection.database_connection.DatabaseConnection`"""
|
||||
|
||||
@abstractmethod
|
||||
def __init__(self):
|
||||
pass
|
||||
def __init__(self): ...
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def server(self) -> MySQLConnectionAbstract:
|
||||
pass
|
||||
def server(self) -> MySQLConnectionAbstract: ...
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def cursor(self) -> MySQLCursorBuffered:
|
||||
pass
|
||||
def cursor(self) -> MySQLCursorBuffered: ...
|
||||
|
||||
@abstractmethod
|
||||
def connect(self, database_settings: DatabaseSettings):
|
||||
|
||||
@@ -4,5 +4,4 @@ from abc import ABC, abstractmethod
|
||||
class DataSeederABC(ABC):
|
||||
|
||||
@abstractmethod
|
||||
async def seed(self):
|
||||
pass
|
||||
async def seed(self): ...
|
||||
|
||||
@@ -4,8 +4,7 @@ from abc import ABC, abstractmethod
|
||||
class ScopeABC(ABC):
|
||||
r"""ABC for the class :class:`cpl.dependency.scope.Scope`"""
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
def __init__(self): ...
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
|
||||
@@ -13,8 +13,7 @@ class ServiceProviderABC(ABC):
|
||||
_provider: Optional["ServiceProviderABC"] = None
|
||||
|
||||
@abstractmethod
|
||||
def __init__(self):
|
||||
pass
|
||||
def __init__(self): ...
|
||||
|
||||
@classmethod
|
||||
def set_global_provider(cls, provider: "ServiceProviderABC"):
|
||||
@@ -37,8 +36,7 @@ class ServiceProviderABC(ABC):
|
||||
return cls._provider.get_services(instance_type, *args, **kwargs)
|
||||
|
||||
@abstractmethod
|
||||
def _build_by_signature(self, sig: Signature, origin_service_type: type) -> list[R]:
|
||||
pass
|
||||
def _build_by_signature(self, sig: Signature, origin_service_type: type) -> list[R]: ...
|
||||
|
||||
@abstractmethod
|
||||
def _build_service(self, service_type: type, *args, **kwargs) -> object:
|
||||
|
||||
@@ -5,25 +5,19 @@ from cpl.translation.translation_settings import TranslationSettings
|
||||
|
||||
class TranslationServiceABC(ABC):
|
||||
@abstractmethod
|
||||
def __init__(self):
|
||||
pass
|
||||
def __init__(self): ...
|
||||
|
||||
@abstractmethod
|
||||
def set_default_lang(self, lang: str):
|
||||
pass
|
||||
def set_default_lang(self, lang: str): ...
|
||||
|
||||
@abstractmethod
|
||||
def set_lang(self, lang: str):
|
||||
pass
|
||||
def set_lang(self, lang: str): ...
|
||||
|
||||
@abstractmethod
|
||||
def load(self, lang: str):
|
||||
pass
|
||||
def load(self, lang: str): ...
|
||||
|
||||
@abstractmethod
|
||||
def load_by_settings(self, settings: TranslationSettings):
|
||||
pass
|
||||
def load_by_settings(self, settings: TranslationSettings): ...
|
||||
|
||||
@abstractmethod
|
||||
def translate(self, key: str) -> str:
|
||||
pass
|
||||
def translate(self, key: str) -> str: ...
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
{
|
||||
"TimeFormatSettings": {
|
||||
"DateFormat": "%Y-%m-%d",
|
||||
"TimeFormat": "%H:%M:%S",
|
||||
"DateTimeFormat": "%Y-%m-%d %H:%M:%S.%f",
|
||||
"DateTimeLogFormat": "%Y-%m-%d_%H-%M-%S"
|
||||
},
|
||||
|
||||
"LoggingSettings": {
|
||||
"Path": "logs/",
|
||||
"Filename": "log_$start_time.log",
|
||||
"ConsoleLogLevel": "ERROR",
|
||||
"FileLogLevel": "WARN"
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"WorkspaceSettings": {
|
||||
"DefaultProject": "async",
|
||||
"Projects": {
|
||||
"async": "src/async/async.json"
|
||||
},
|
||||
"Scripts": {}
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
from cpl.application import ApplicationABC
|
||||
from cpl.core.configuration import ConfigurationABC
|
||||
from cpl.core.console import Console
|
||||
from cpl.dependency import ServiceProviderABC
|
||||
|
||||
|
||||
class Application(ApplicationABC):
|
||||
def __init__(self, config: ConfigurationABC, services: ServiceProviderABC):
|
||||
ApplicationABC.__init__(self, config, services)
|
||||
|
||||
async def configure(self):
|
||||
pass
|
||||
|
||||
async def main(self):
|
||||
Console.write_line("Hello World")
|
||||
@@ -1,41 +0,0 @@
|
||||
{
|
||||
"ProjectSettings": {
|
||||
"Name": "async",
|
||||
"Version": {
|
||||
"Major": "0",
|
||||
"Minor": "0",
|
||||
"Micro": "0"
|
||||
},
|
||||
"Author": "",
|
||||
"AuthorEmail": "",
|
||||
"Description": "",
|
||||
"LongDescription": "",
|
||||
"URL": "",
|
||||
"CopyrightDate": "",
|
||||
"CopyrightName": "",
|
||||
"LicenseName": "",
|
||||
"LicenseDescription": "",
|
||||
"Dependencies": [
|
||||
"sh_cpl>=2021.10.0.post1"
|
||||
],
|
||||
"PythonVersion": ">=3.9.2",
|
||||
"PythonPath": {},
|
||||
"Classifiers": []
|
||||
},
|
||||
"BuildSettings": {
|
||||
"ProjectType": "console",
|
||||
"SourcePath": "",
|
||||
"OutputPath": "../../dist",
|
||||
"Main": "async.main",
|
||||
"EntryPoint": "async",
|
||||
"IncludePackageData": false,
|
||||
"Included": [],
|
||||
"Excluded": [
|
||||
"*/__pycache__",
|
||||
"*/logs",
|
||||
"*/tests"
|
||||
],
|
||||
"PackageData": {},
|
||||
"ProjectReferences": []
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
import asyncio
|
||||
from cpl.application import ApplicationBuilder
|
||||
|
||||
from application import Application
|
||||
from startup import Startup
|
||||
|
||||
|
||||
async def main():
|
||||
app_builder = ApplicationBuilder(Application)
|
||||
app_builder.use_startup(Startup)
|
||||
app = await app_builder.build_async()
|
||||
await app.run_async()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
loop = asyncio.new_event_loop()
|
||||
loop.run_until_complete(main())
|
||||
@@ -1,17 +0,0 @@
|
||||
from cpl.application.async_startup_abc import AsyncStartupABC
|
||||
from cpl.core.configuration import ConfigurationABC
|
||||
from cpl.dependency import ServiceProviderABC, ServiceCollection
|
||||
from cpl.core.environment import Environment
|
||||
|
||||
|
||||
class Startup(AsyncStartupABC):
|
||||
def __init__(self):
|
||||
AsyncStartupABC.__init__(self)
|
||||
|
||||
async def configure_configuration(
|
||||
self, configuration: ConfigurationABC, environment: Environment
|
||||
) -> ConfigurationABC:
|
||||
return configuration
|
||||
|
||||
async def configure_services(self, services: ServiceCollection, environment: Environment) -> ServiceProviderABC:
|
||||
return services.build()
|
||||
@@ -1,5 +1,4 @@
|
||||
from cpl.application import ApplicationABC
|
||||
from cpl.core.configuration import ConfigurationABC
|
||||
from cpl.application.abc import ApplicationABC
|
||||
from cpl.core.console.console import Console
|
||||
from cpl.dependency import ServiceProviderABC
|
||||
from cpl.dependency.scope import Scope
|
||||
@@ -11,15 +10,14 @@ from di.tester import Tester
|
||||
|
||||
|
||||
class Application(ApplicationABC):
|
||||
def __init__(self, config: ConfigurationABC, services: ServiceProviderABC):
|
||||
ApplicationABC.__init__(self, config, services)
|
||||
def __init__(self, services: ServiceProviderABC):
|
||||
ApplicationABC.__init__(self, services)
|
||||
|
||||
def _part_of_scoped(self):
|
||||
ts: TestService = self._services.get_service(TestService)
|
||||
ts.run()
|
||||
|
||||
def configure(self):
|
||||
pass
|
||||
def configure(self): ...
|
||||
|
||||
def main(self):
|
||||
with self._services.create_scope() as scope:
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
from cpl.application import StartupABC
|
||||
from cpl.core.configuration import ConfigurationABC
|
||||
from cpl.application.abc import StartupABC
|
||||
from cpl.dependency import ServiceProviderABC, ServiceCollection
|
||||
from cpl.core.environment import Environment
|
||||
from di.di_tester_service import DITesterService
|
||||
from di.test1_service import Test1Service
|
||||
from di.test2_service import Test2Service
|
||||
from di.test_abc import TestABC
|
||||
from di.test_service import TestService
|
||||
from di.di_tester_service import DITesterService
|
||||
from di.tester import Tester
|
||||
|
||||
|
||||
@@ -14,10 +12,9 @@ class Startup(StartupABC):
|
||||
def __init__(self):
|
||||
StartupABC.__init__(self)
|
||||
|
||||
def configure_configuration(self, configuration: ConfigurationABC, environment: Environment) -> ConfigurationABC:
|
||||
return configuration
|
||||
def configure_configuration(self): ...
|
||||
|
||||
def configure_services(self, services: ServiceCollection, environment: Environment) -> ServiceProviderABC:
|
||||
def configure_services(self, services: ServiceCollection) -> ServiceProviderABC:
|
||||
services.add_scoped(TestService)
|
||||
services.add_scoped(DITesterService)
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
from cpl.core.configuration import ConfigurationABC
|
||||
from cpl.dependency import ServiceProvider, ServiceProviderABC
|
||||
from di.test_service import TestService
|
||||
|
||||
@@ -6,5 +5,5 @@ from di.test_service import TestService
|
||||
class StaticTest:
|
||||
@staticmethod
|
||||
@ServiceProvider.inject
|
||||
def test(services: ServiceProviderABC, config: ConfigurationABC, t1: TestService):
|
||||
def test(services: ServiceProviderABC, t1: TestService):
|
||||
t1.run()
|
||||
|
||||
@@ -6,7 +6,7 @@ from cpl.core.utils.string import String
|
||||
|
||||
class TestService:
|
||||
def __init__(self):
|
||||
self._name = String.random_string(string.ascii_lowercase, 8)
|
||||
self._name = String.random(8)
|
||||
|
||||
def run(self):
|
||||
Console.write_line(f"Im {self._name}")
|
||||
|
||||
@@ -18,8 +18,7 @@ class Application(ApplicationABC):
|
||||
self._translation.load_by_settings(config.get_configuration(TranslationSettings))
|
||||
self._translation.set_default_lang("de")
|
||||
|
||||
def configure(self):
|
||||
pass
|
||||
def configure(self): ...
|
||||
|
||||
def main(self):
|
||||
Console.write_line(self._translate.transform("main.text.hello_world"))
|
||||
|
||||
@@ -13,8 +13,7 @@ class Application(ApplicationABC):
|
||||
def __init__(self, config: ConfigurationABC, services: ServiceProviderABC):
|
||||
ApplicationABC.__init__(self, config, services)
|
||||
|
||||
def configure(self):
|
||||
pass
|
||||
def configure(self): ...
|
||||
|
||||
def main(self):
|
||||
runner = unittest.TextTestRunner()
|
||||
|
||||
@@ -2,8 +2,6 @@ from unittests_cli.abc.command_test_case import CommandTestCase
|
||||
|
||||
|
||||
class CustomTestCase(CommandTestCase):
|
||||
def setUp(self):
|
||||
pass
|
||||
def setUp(self): ...
|
||||
|
||||
def test_equal(self):
|
||||
pass
|
||||
def test_equal(self): ...
|
||||
|
||||
@@ -26,8 +26,7 @@ class VersionTestCase(CommandTestCase):
|
||||
self._block_packages = ""
|
||||
self._name = "CPL CLI"
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
def setUp(self): ...
|
||||
|
||||
def _get_version_output(self, version: str):
|
||||
index = 0
|
||||
|
||||
@@ -4,8 +4,7 @@ from cpl.core.pipes import BoolPipe
|
||||
|
||||
|
||||
class BoolPipeTestCase(unittest.TestCase):
|
||||
def setUp(self):
|
||||
pass
|
||||
def setUp(self): ...
|
||||
|
||||
def test_transform(self):
|
||||
self.assertEqual("true", BoolPipe.to_str(True))
|
||||
|
||||
@@ -4,8 +4,7 @@ from cpl.core.pipes import IPAddressPipe
|
||||
|
||||
|
||||
class IPAddressTestCase(unittest.TestCase):
|
||||
def setUp(self):
|
||||
pass
|
||||
def setUp(self): ...
|
||||
|
||||
def test_transform(self):
|
||||
self.assertEqual("192.168.178.1", IPAddressPipe.to_str([192, 168, 178, 1]))
|
||||
|
||||
@@ -4,8 +4,7 @@ from cpl.core.utils import CredentialManager
|
||||
|
||||
|
||||
class CredentialManagerTestCase(unittest.TestCase):
|
||||
def setUp(self):
|
||||
pass
|
||||
def setUp(self): ...
|
||||
|
||||
def test_encrypt(self):
|
||||
self.assertEqual("ZkVjSkplQUx4aW1zWHlPbA==", CredentialManager.encrypt("fEcJJeALximsXyOl"))
|
||||
|
||||
@@ -18,8 +18,7 @@ class TestClass:
|
||||
|
||||
|
||||
class JSONProcessorTestCase(unittest.TestCase):
|
||||
def setUp(self):
|
||||
pass
|
||||
def setUp(self): ...
|
||||
|
||||
def test_process(self):
|
||||
test_dict = {
|
||||
|
||||
@@ -5,8 +5,7 @@ from cpl.core.utils import String
|
||||
|
||||
|
||||
class StringTestCase(unittest.TestCase):
|
||||
def setUp(self):
|
||||
pass
|
||||
def setUp(self): ...
|
||||
|
||||
def test_convert_to_camel_case(self):
|
||||
expected = "HelloWorld"
|
||||
|
||||
@@ -20,8 +20,7 @@ class TranslationTestCase(unittest.TestCase):
|
||||
self._translation.set_default_lang("de")
|
||||
self._translate = TranslatePipe(self._translation)
|
||||
|
||||
def cleanUp(self):
|
||||
pass
|
||||
def cleanUp(self): ...
|
||||
|
||||
def test_service(self):
|
||||
self.assertEqual("Hallo Welt", self._translation.translate("main.text.hello_world"))
|
||||
|
||||
Reference in New Issue
Block a user