From 413800f2c35fe934d6047ceb9f386361b240fb21 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sun, 22 Nov 2020 20:56:31 +0100 Subject: [PATCH] Improved logging and updated modules --- src/sh_edraft/__init__.py | 6 +- src/sh_edraft/configuration/__init__.py | 6 +- src/sh_edraft/configuration/model/__init__.py | 6 +- src/sh_edraft/discord/__init__.py | 4 +- src/sh_edraft/logging/__init__.py | 7 +- src/sh_edraft/logging/base/__init__.py | 5 +- src/sh_edraft/logging/logger.py | 2 - src/sh_edraft/logging/model/__init__.py | 6 +- src/sh_edraft/mailing/__init__.py | 4 +- src/sh_edraft/messenger/__init__.py | 4 +- src/sh_edraft/publish/__init__.py | 6 +- src/sh_edraft/publish/base/__init__.py | 6 +- src/sh_edraft/publish/model/__init__.py | 8 +- src/sh_edraft/publish/publisher.py | 120 +++++++++++------- src/sh_edraft/service/__init__.py | 6 +- src/sh_edraft/service/base/__init__.py | 8 +- src/sh_edraft/service/model/__init__.py | 5 +- src/sh_edraft/source_code/__init__.py | 4 +- src/sh_edraft/source_code/model/__init__.py | 8 +- src/sh_edraft/source_code/model/version.py | 4 +- src/sh_edraft/time/__init__.py | 4 +- src/sh_edraft/time/model/__init__.py | 6 +- src/sh_edraft/utils/__init__.py | 5 +- src/tests/__init__.py | 4 +- src/tests/publisher.py | 8 +- src/tests/service_provider.py | 13 +- src/tests/tester.py | 23 ++-- 27 files changed, 158 insertions(+), 130 deletions(-) diff --git a/src/sh_edraft/__init__.py b/src/sh_edraft/__init__.py index 58fb4bac..775e3790 100644 --- a/src/sh_edraft/__init__.py +++ b/src/sh_edraft/__init__.py @@ -15,11 +15,11 @@ __title__ = 'sh_edraft' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2020 sh-edraft.de' -__version__ = '2020.12.0.1' +__version__ = '2020.12.5' from collections import namedtuple - +# imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major=2020, minor=12, micro=0.1) +version_info = VersionInfo(major=2020, minor=12, micro=5) diff --git a/src/sh_edraft/configuration/__init__.py b/src/sh_edraft/configuration/__init__.py index e08dcd42..12f35645 100644 --- a/src/sh_edraft/configuration/__init__.py +++ b/src/sh_edraft/configuration/__init__.py @@ -15,12 +15,12 @@ __title__ = 'sh_edraft.configuration' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2020 sh-edraft.de' -__version__ = '2020.12.0.1' +__version__ = '2020.12.5' from collections import namedtuple # imports: -from sh_edraft.configuration.application_host import ApplicationHost +from .application_host import ApplicationHost VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major=2020, minor=12, micro=0.1) +version_info = VersionInfo(major=2020, minor=12, micro=5) diff --git a/src/sh_edraft/configuration/model/__init__.py b/src/sh_edraft/configuration/model/__init__.py index 824ece23..e5226338 100644 --- a/src/sh_edraft/configuration/model/__init__.py +++ b/src/sh_edraft/configuration/model/__init__.py @@ -15,12 +15,12 @@ __title__ = 'sh_edraft.configuration.model' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2020 sh-edraft.de' -__version__ = '2020.12.0.1' +__version__ = '2020.12.5' from collections import namedtuple # imports: -from sh_edraft.configuration.model.configuration_model_base import ConfigurationModelBase +from .configuration_model_base import ConfigurationModelBase VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major=2020, minor=12, micro=0.1) +version_info = VersionInfo(major=2020, minor=12, micro=5) diff --git a/src/sh_edraft/discord/__init__.py b/src/sh_edraft/discord/__init__.py index e8957e78..e1ab9453 100644 --- a/src/sh_edraft/discord/__init__.py +++ b/src/sh_edraft/discord/__init__.py @@ -15,11 +15,11 @@ __title__ = 'sh_edraft.discord' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2020 sh-edraft.de' -__version__ = '2020.12.0.1' +__version__ = '2020.12.5' from collections import namedtuple VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major=2020, minor=12, micro=0.1) +version_info = VersionInfo(major=2020, minor=12, micro=5) diff --git a/src/sh_edraft/logging/__init__.py b/src/sh_edraft/logging/__init__.py index 7ac6e90c..a70129f6 100644 --- a/src/sh_edraft/logging/__init__.py +++ b/src/sh_edraft/logging/__init__.py @@ -15,11 +15,12 @@ __title__ = 'sh_edraft.logging' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2020 sh-edraft.de' -__version__ = '2020.12.0.1' +__version__ = '2020.12.5' from collections import namedtuple - +# imports: +from .logger import Logger VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major=2020, minor=12, micro=0.1) +version_info = VersionInfo(major=2020, minor=12, micro=5) diff --git a/src/sh_edraft/logging/base/__init__.py b/src/sh_edraft/logging/base/__init__.py index 662b7253..209ee125 100644 --- a/src/sh_edraft/logging/base/__init__.py +++ b/src/sh_edraft/logging/base/__init__.py @@ -15,11 +15,12 @@ __title__ = 'sh_edraft.logging.base' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2020 sh-edraft.de' -__version__ = '2020.12.0.1' +__version__ = '2020.12.5' from collections import namedtuple # imports: +from .logger_base import LoggerBase VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major=2020, minor=12, micro=0.1) +version_info = VersionInfo(major=2020, minor=12, micro=5) diff --git a/src/sh_edraft/logging/logger.py b/src/sh_edraft/logging/logger.py index b616b8b0..132369d8 100644 --- a/src/sh_edraft/logging/logger.py +++ b/src/sh_edraft/logging/logger.py @@ -4,8 +4,6 @@ import traceback from string import Template from typing import Optional -from termcolor import colored - from sh_edraft.configuration.application_host import ApplicationHost from sh_edraft.logging.base.logger_base import LoggerBase from sh_edraft.logging.model.log_level import LoggingLevel diff --git a/src/sh_edraft/logging/model/__init__.py b/src/sh_edraft/logging/model/__init__.py index e9d22762..6b232b0c 100644 --- a/src/sh_edraft/logging/model/__init__.py +++ b/src/sh_edraft/logging/model/__init__.py @@ -15,11 +15,13 @@ __title__ = 'sh_edraft.logging.model' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2020 sh-edraft.de' -__version__ = '2020.12.0.1' +__version__ = '2020.12.5' from collections import namedtuple # imports: +from .log_level import LoggingLevel +from .log_settings import LoggingSettings VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major=2020, minor=12, micro=0.1) +version_info = VersionInfo(major=2020, minor=12, micro=5) diff --git a/src/sh_edraft/mailing/__init__.py b/src/sh_edraft/mailing/__init__.py index 45e5a87e..5f2d9f23 100644 --- a/src/sh_edraft/mailing/__init__.py +++ b/src/sh_edraft/mailing/__init__.py @@ -15,11 +15,11 @@ __title__ = 'sh_edraft.mailing' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2020 sh-edraft.de' -__version__ = '2020.12.0.1' +__version__ = '2020.12.5' from collections import namedtuple VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major=2020, minor=12, micro=0.1) +version_info = VersionInfo(major=2020, minor=12, micro=5) diff --git a/src/sh_edraft/messenger/__init__.py b/src/sh_edraft/messenger/__init__.py index 2bab0145..8d501a96 100644 --- a/src/sh_edraft/messenger/__init__.py +++ b/src/sh_edraft/messenger/__init__.py @@ -15,11 +15,11 @@ __title__ = 'sh_edraft.messenger' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2020 sh-edraft.de' -__version__ = '2020.12.0.1' +__version__ = '2020.12.5' from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major=2020, minor=12, micro=0.1) +version_info = VersionInfo(major=2020, minor=12, micro=5) diff --git a/src/sh_edraft/publish/__init__.py b/src/sh_edraft/publish/__init__.py index e754a8ac..7b162462 100644 --- a/src/sh_edraft/publish/__init__.py +++ b/src/sh_edraft/publish/__init__.py @@ -15,12 +15,12 @@ __title__ = 'sh_edraft.publish' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2020 sh-edraft.de' -__version__ = '2020.12.0.1' +__version__ = '2020.12.5' from collections import namedtuple # imports: -from sh_edraft.publish.publisher import Publisher +from .publisher import Publisher VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major=2020, minor=12, micro=0.1) +version_info = VersionInfo(major=2020, minor=12, micro=5) diff --git a/src/sh_edraft/publish/base/__init__.py b/src/sh_edraft/publish/base/__init__.py index 0c156e0d..a7e178d1 100644 --- a/src/sh_edraft/publish/base/__init__.py +++ b/src/sh_edraft/publish/base/__init__.py @@ -15,12 +15,12 @@ __title__ = 'sh_edraft.publish.base' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2020 sh-edraft.de' -__version__ = '2020.12.0.1' +__version__ = '2020.12.5' from collections import namedtuple # imports: -from sh_edraft.publish.base.publisher_base import PublisherBase +from .publisher_base import PublisherBase VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major=2020, minor=12, micro=0.1) +version_info = VersionInfo(major=2020, minor=12, micro=5) diff --git a/src/sh_edraft/publish/model/__init__.py b/src/sh_edraft/publish/model/__init__.py index caad810e..dbc1c3b5 100644 --- a/src/sh_edraft/publish/model/__init__.py +++ b/src/sh_edraft/publish/model/__init__.py @@ -15,13 +15,13 @@ __title__ = 'sh_edraft.publish.model' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2020 sh-edraft.de' -__version__ = '2020.12.0.1' +__version__ = '2020.12.5' from collections import namedtuple # imports: -from sh_edraft.publish.model.template import Template -from sh_edraft.publish.model.template_enum import TemplateEnum +from .template import Template +from .template_enum import TemplateEnum VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major=2020, minor=12, micro=0.1) +version_info = VersionInfo(major=2020, minor=12, micro=5) diff --git a/src/sh_edraft/publish/publisher.py b/src/sh_edraft/publish/publisher.py index e776d906..7fae4fff 100644 --- a/src/sh_edraft/publish/publisher.py +++ b/src/sh_edraft/publish/publisher.py @@ -3,6 +3,7 @@ import shutil from string import Template as stringTemplate from typing import Optional +from sh_edraft.logging.base.logger_base import LoggerBase from sh_edraft.publish.base.publisher_base import PublisherBase from sh_edraft.publish.model.template import Template @@ -12,7 +13,7 @@ class Publisher(PublisherBase): def __init__(self): super().__init__() - self._logger: Optional[None] = None + self._logger: Optional[LoggerBase] = None self._source_path: Optional[str] = None self._dist_path: Optional[str] = None self._settings: Optional[list[Template]] = None @@ -30,12 +31,13 @@ class Publisher(PublisherBase): def dist_path(self): return self._dist_path - @staticmethod - def _get_template_output(t: Template, name: str, imports: str) -> str: + def _get_template_output(self, t: Template, name: str, imports: str) -> str: + self._logger.trace(__name__, f'Started {__name__}._get_template_output') try: if t.file_content == '': raise Exception(f'Template is empty: {t.template_path}') + self._logger.trace(__name__, f'Stopped {__name__}._get_template_output') return stringTemplate(t.file_content).substitute( Name=name, Description=t.description, @@ -53,16 +55,20 @@ class Publisher(PublisherBase): Imports=imports ) except Exception as e: - print(1, e) - # todo: better logging + self._logger.fatal(__name__, f'Cannot read Template: {t.template_path}', e) + self._logger.trace(__name__, f'Stopped {__name__}._get_template_output') def _read_source_path(self): + self._logger.trace(__name__, f'Started {__name__}._read_source_path') for r, d, f in os.walk(self._source_path): for file in f: if file.endswith('.py') or file in self._included_files: self._included_files.append(os.path.join(r, file)) + self._logger.trace(__name__, f'Stopped {__name__}._read_source_path') + def _read_templates(self): + self._logger.trace(__name__, f'Started {__name__}._read_templates') for t in self._settings: output_template: str = '' if not os.path.isfile(t.template_path): @@ -74,22 +80,26 @@ class Publisher(PublisherBase): if t.file_content == '': raise Exception(f'Template is empty: {t.template_path}') + self._logger.trace(__name__, f'Stopped {__name__}._read_templates') + def _create_dist_path(self): + self._logger.trace(__name__, f'Started {__name__}._create_dist_path') if os.path.isdir(self._dist_path): try: shutil.rmtree(self._dist_path) - print(f'Deleted {self._dist_path}') - # todo: better logging + self._logger.info(__name__, f'Deleted {self._dist_path}') except Exception as e: - print(e) - # todo: log error + self._logger.fatal(__name__, f'Cannot delete old dist directory', e) if not os.path.isdir(self._dist_path): try: os.makedirs(self._dist_path) + self._logger.debug(__name__, f'Created directories: {self._dist_path}') + self._logger.info(__name__, f'Created dist directory') except Exception as e: - print(e) - # todo: log error + self._logger.fatal(__name__, f'Cannot create dist directory', e) + + self._logger.trace(__name__, f'Stopped {__name__}._create_dist_path') @staticmethod def _get_template_name_from_dirs(file: str) -> str: @@ -104,6 +114,7 @@ class Publisher(PublisherBase): return '.'.join(dirs) def _write_templates(self): + self._logger.trace(__name__, f'Started {__name__}._write_templates') for template in self._settings: for file in self._included_files: if os.path.basename(file) == '__init__.py' and file not in self._excluded_files: @@ -133,7 +144,7 @@ class Publisher(PublisherBase): with open(file, 'w+') as py_file: py_file.write(self._get_template_output(template, template_name, '# imports:')) py_file.close() - print(f'Written to {file}') + self._logger.debug(__name__, f'Written to {file}') else: is_started = False for line in module_file_lines: @@ -149,73 +160,86 @@ class Publisher(PublisherBase): with open(file, 'w+') as py_file: py_file.write(self._get_template_output(template, template_name, imports)) py_file.close() - print(f'Written to {file}') + self._logger.debug(__name__, f'Written to {file}') except Exception as e: - print(e) - # todo: better logging + self._logger.error(__name__, f'Cannot write to file: {file}', e) + + self._logger.info(__name__, f'Written to all included modules') + self._logger.trace(__name__, f'Stopped {__name__}._write_templates') def _copy_all_included_files(self): + self._logger.trace(__name__, f'Started {__name__}._copy_all_included_files') dist_path = self._dist_path if self._dist_path.endswith('/'): dist_path = dist_path[:len(dist_path) - 1] - for file in self._included_files: - is_file_excluded = False - if file in self._excluded_files: - is_file_excluded = True - else: - for excluded in self._excluded_files: - if file.__contains__(excluded): - is_file_excluded = True + for file in self._included_files: + is_file_excluded = False + if file in self._excluded_files: + is_file_excluded = True + else: + for excluded in self._excluded_files: + if file.__contains__(excluded): + is_file_excluded = True - if not is_file_excluded: - output_file = '' - if file.startswith('..'): - output_file = file.replace('..', '') + if not is_file_excluded: + output_file = '' - elif file.startswith('.'): - output_file = file.replace('.', '', 1) + if file.startswith('..'): + output_file = file.replace('..', '') + elif file.startswith('.'): + output_file = file.replace('.', '', 1) - output_file = f'{dist_path}{output_file}' - output_path = os.path.dirname(output_file) + output_file = f'{dist_path}{output_file}' + output_path = os.path.dirname(output_file) - try: - if not os.path.isdir(output_path): - os.makedirs(output_path) - except Exception as e: - print(e) - # todo: better logging + try: + if not os.path.isdir(output_path): + os.makedirs(output_path) + except Exception as e: + self._logger.error(__name__, f'Cannot create directories: {output_path}', e) - try: - shutil.copy(file, output_file) - except Exception as e: - print(e) - # todo: better logging + try: + shutil.copy(file, output_file) + except Exception as e: + self._logger.error(__name__, f'Cannot copy file: {file} to {output_path}', e) - print(f'Copied {file} to {output_path}') - # todo: better logging + self._logger.debug(__name__, f'Copied {file} to {output_path}') + + self._logger.info(__name__, f'Copied all included files') + self._logger.trace(__name__, f'Stopped {__name__}._copy_all_included_files') def include(self, path: str): + self._logger.trace(__name__, f'Started {__name__}.include') self._included_files.append(path) + self._logger.trace(__name__, f'Stopped {__name__}.include') def exclude(self, path: str): + self._logger.trace(__name__, f'Started {__name__}.exclude') self._excluded_files.append(path) + self._logger.trace(__name__, f'Stopped {__name__}.exclude') def init(self, args: tuple): - self._logger = args[0] - self._source_path = args[1] - self._dist_path = args[2] - self._settings = args[3] + self._logger: LoggerBase = args[0] + self._source_path: str = args[1] + self._dist_path: str = args[2] + self._settings: list[Template] = args[3] + + self._logger.header(f'{__name__}:') def create(self): + self._logger.trace(__name__, f'Started {__name__}.create') if not self._dist_path.endswith('/'): self._dist_path += '/' self._read_source_path() self._read_templates() self._create_dist_path() + self._logger.trace(__name__, f'Stopped {__name__}.create') def publish(self): + self._logger.trace(__name__, f'Started {__name__}.publish') self._write_templates() self._copy_all_included_files() + self._logger.trace(__name__, f'Stopped {__name__}.publish') diff --git a/src/sh_edraft/service/__init__.py b/src/sh_edraft/service/__init__.py index 50d977b6..dbc93593 100644 --- a/src/sh_edraft/service/__init__.py +++ b/src/sh_edraft/service/__init__.py @@ -15,12 +15,12 @@ __title__ = 'sh_edraft.service' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2020 sh-edraft.de' -__version__ = '2020.12.0.1' +__version__ = '2020.12.5' from collections import namedtuple # imports: -from sh_edraft.service.service_provider import ServiceProvider +from .service_provider import ServiceProvider VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major=2020, minor=12, micro=0.1) +version_info = VersionInfo(major=2020, minor=12, micro=5) diff --git a/src/sh_edraft/service/base/__init__.py b/src/sh_edraft/service/base/__init__.py index 80cbcb9b..e2c43c24 100644 --- a/src/sh_edraft/service/base/__init__.py +++ b/src/sh_edraft/service/base/__init__.py @@ -15,13 +15,13 @@ __title__ = 'sh_edraft.service.base' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2020 sh-edraft.de' -__version__ = '2020.12.0.1' +__version__ = '2020.12.5' from collections import namedtuple # imports: -from sh_edraft.service.base.service_base import ServiceBase -from sh_edraft.service.base.service_provider_base import ServiceProviderBase +from .service_base import ServiceBase +from .service_provider_base import ServiceProviderBase VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major=2020, minor=12, micro=0.1) +version_info = VersionInfo(major=2020, minor=12, micro=5) diff --git a/src/sh_edraft/service/model/__init__.py b/src/sh_edraft/service/model/__init__.py index f48cec28..9a4effc3 100644 --- a/src/sh_edraft/service/model/__init__.py +++ b/src/sh_edraft/service/model/__init__.py @@ -15,11 +15,12 @@ __title__ = 'sh_edraft.service.model' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2020 sh-edraft.de' -__version__ = '2020.12.0.1' +__version__ = '2020.12.5' from collections import namedtuple # imports: +from .provide_state import ProvideState VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major=2020, minor=12, micro=0.1) +version_info = VersionInfo(major=2020, minor=12, micro=5) diff --git a/src/sh_edraft/source_code/__init__.py b/src/sh_edraft/source_code/__init__.py index 43c2d77d..1df505f4 100644 --- a/src/sh_edraft/source_code/__init__.py +++ b/src/sh_edraft/source_code/__init__.py @@ -15,11 +15,11 @@ __title__ = 'sh_edraft.source_code' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2020 sh-edraft.de' -__version__ = '2020.12.0.1' +__version__ = '2020.12.5' from collections import namedtuple VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major=2020, minor=12, micro=0.1) +version_info = VersionInfo(major=2020, minor=12, micro=5) diff --git a/src/sh_edraft/source_code/model/__init__.py b/src/sh_edraft/source_code/model/__init__.py index a37844ed..5e7c6981 100644 --- a/src/sh_edraft/source_code/model/__init__.py +++ b/src/sh_edraft/source_code/model/__init__.py @@ -15,13 +15,13 @@ __title__ = 'sh_edraft.source_code.model' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2020 sh-edraft.de' -__version__ = '2020.12.0.1' +__version__ = '2020.12.5' from collections import namedtuple # imports: -from sh_edraft.source_code.model.version import Version -from sh_edraft.source_code.model.version_enum import VersionEnum +from .version import Version +from .version_enum import VersionEnum VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major=2020, minor=12, micro=0.1) +version_info = VersionInfo(major=2020, minor=12, micro=5) diff --git a/src/sh_edraft/source_code/model/version.py b/src/sh_edraft/source_code/model/version.py index c9ccfeb0..a7ba870e 100644 --- a/src/sh_edraft/source_code/model/version.py +++ b/src/sh_edraft/source_code/model/version.py @@ -14,7 +14,7 @@ class Version(ConfigurationModelBase): ): self._major: Optional[int] = major self._minor: Optional[int] = minor - self._micro: Optional[float] = micro + self._micro: Optional[int] = micro @property def major(self) -> int: @@ -34,7 +34,7 @@ class Version(ConfigurationModelBase): def from_dict(self, settings: dict): self._major = int(settings[VersionEnum.Major.value]) self._minor = int(settings[VersionEnum.Minor.value]) - self._micro = float(settings[VersionEnum.Micro.value]) + self._micro = int(settings[VersionEnum.Micro.value]) def to_dict(self) -> dict: return { diff --git a/src/sh_edraft/time/__init__.py b/src/sh_edraft/time/__init__.py index 28f6ff53..8b6e4c87 100644 --- a/src/sh_edraft/time/__init__.py +++ b/src/sh_edraft/time/__init__.py @@ -15,11 +15,11 @@ __title__ = 'sh_edraft.time' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2020 sh-edraft.de' -__version__ = '2020.12.0.1' +__version__ = '2020.12.5' from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major=2020, minor=12, micro=0.1) +version_info = VersionInfo(major=2020, minor=12, micro=5) diff --git a/src/sh_edraft/time/model/__init__.py b/src/sh_edraft/time/model/__init__.py index 3950ec94..e786e832 100644 --- a/src/sh_edraft/time/model/__init__.py +++ b/src/sh_edraft/time/model/__init__.py @@ -15,11 +15,13 @@ __title__ = 'sh_edraft.time.model' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2020 sh-edraft.de' -__version__ = '2020.12.0.1' +__version__ = '2020.12.5' from collections import namedtuple # imports: +from .time_format_settings import TimeFormatSettings +from .time_format_settings_names import TimeFormatSettingsNames VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major=2020, minor=12, micro=0.1) +version_info = VersionInfo(major=2020, minor=12, micro=5) diff --git a/src/sh_edraft/utils/__init__.py b/src/sh_edraft/utils/__init__.py index f6849df3..4130c05d 100644 --- a/src/sh_edraft/utils/__init__.py +++ b/src/sh_edraft/utils/__init__.py @@ -15,11 +15,12 @@ __title__ = 'sh_edraft.utils' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2020 sh-edraft.de' -__version__ = '2020.12.0.1' +__version__ = '2020.12.5' from collections import namedtuple # imports: +from .console import Console VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major=2020, minor=12, micro=0.1) +version_info = VersionInfo(major=2020, minor=12, micro=5) diff --git a/src/tests/__init__.py b/src/tests/__init__.py index ce54614e..6d9d25af 100644 --- a/src/tests/__init__.py +++ b/src/tests/__init__.py @@ -15,11 +15,11 @@ __title__ = 'tests' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2020 sh-edraft.de' -__version__ = '2020.12.0.1' +__version__ = '2020.12.5' from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major=2020, minor=12, micro=0.1) +version_info = VersionInfo(major=2020, minor=12, micro=5) diff --git a/src/tests/publisher.py b/src/tests/publisher.py index 3e100328..73923471 100644 --- a/src/tests/publisher.py +++ b/src/tests/publisher.py @@ -1,5 +1,6 @@ import os +from sh_edraft.logging.base.logger_base import LoggerBase from sh_edraft.publish.base import PublisherBase from sh_edraft.service.base import ServiceProviderBase from sh_edraft.source_code.model import Version @@ -11,6 +12,7 @@ class PublisherTest: @staticmethod def start(services: ServiceProviderBase): + version = Version(2020, 12, 5).to_dict() templates = [ Template( '../../publish_templates/*_template.txt', @@ -23,7 +25,7 @@ class PublisherTest: ', see LICENSE for more details.', '', 'Sven Heidemann', - Version(2020, 12, 0.1).to_dict() + version ), Template( '../../publish_templates/*_template.txt', @@ -36,14 +38,14 @@ class PublisherTest: ', see LICENSE for more details.', '', 'Sven Heidemann', - Version(2020, 12, 0.1).to_dict() + version ) ] source = '../' dist = '../../dist' - services.add_singleton(Publisher, None, source, dist, templates) + services.add_transient(Publisher, services.get_service(LoggerBase), source, dist, templates) publisher: Publisher = services.get_service(PublisherBase) publisher.exclude('../tests/') diff --git a/src/tests/service_provider.py b/src/tests/service_provider.py index d5808d05..676cc604 100644 --- a/src/tests/service_provider.py +++ b/src/tests/service_provider.py @@ -1,3 +1,4 @@ +from sh_edraft.logging.base.logger_base import LoggerBase from sh_edraft.publish import Publisher from sh_edraft.publish.base import PublisherBase from sh_edraft.service.base import ServiceProviderBase @@ -6,16 +7,14 @@ from sh_edraft.service.base import ServiceProviderBase class ServiceProviderTest: @staticmethod - def start(provider: ServiceProviderBase): - provider.create() + def start(services: ServiceProviderBase): + services.add_transient(Publisher, services.get_service(LoggerBase), '../', '../../dist', []) - provider.add_transient(Publisher, None, '../', '../../dist', []) - - publisher: Publisher = provider.get_service(PublisherBase) + publisher: Publisher = services.get_service(PublisherBase) if publisher is None or publisher.source_path != '../' or publisher.dist_path != '../../dist': raise Exception(f'{__name__}: Invalid value in {Publisher.__name__}') - provider.remove_service(PublisherBase) - if provider.get_service(PublisherBase) is not None: + services.remove_service(PublisherBase) + if services.get_service(PublisherBase) is not None: raise Exception(f'{__name__}: Service {Publisher.__name__} was not removed') diff --git a/src/tests/tester.py b/src/tests/tester.py index 64fa121e..e4eb313e 100644 --- a/src/tests/tester.py +++ b/src/tests/tester.py @@ -1,12 +1,10 @@ import os import sys import traceback -from typing import Optional from termcolor import colored from sh_edraft.configuration import ApplicationHost -from sh_edraft.service import ServiceProvider from tests.logger import LoggerTest from tests.publisher import PublisherTest from tests.service_provider import ServiceProviderTest @@ -16,7 +14,6 @@ class Tester: def __init__(self): self._app_host = ApplicationHost() - self._services: Optional[ServiceProvider] = None self._error: bool = False @@ -46,7 +43,14 @@ class Tester: def create(self): pass def start(self): - self.disable_print() + if not self._error: + try: + LoggerTest.start(self._app_host) + self.success(f'{LoggerTest.__name__} test succeeded.') + except Exception as e: + self._error = True + self.failed(f'{LoggerTest.__name__} test failed!\n{e}') + self.exception() if not self._error: try: @@ -57,15 +61,6 @@ class Tester: self.failed(f'{ServiceProviderTest.__name__} test failed!\n{e}') self.exception() - if not self._error: - try: - LoggerTest.start(self._app_host) - self.success(f'{LoggerTest.__name__} test succeeded.') - except Exception as e: - self._error = True - self.failed(f'{LoggerTest.__name__} test failed!\n{e}') - self.exception() - if not self._error: try: PublisherTest.start(self._app_host.services) @@ -79,4 +74,6 @@ class Tester: if __name__ == '__main__': tester = Tester() tester.create() + tester.disable_print() tester.start() + tester.enable_print()