Merge pull request '2020.12.9' (#6) from 2020.12.9 into 2020.12

Reviewed-on: sh-edraft.de/sh_common_py_lib#6
This commit is contained in:
Sven Heidemann 2020-12-15 17:35:47 +01:00
commit 8c86eb2417
67 changed files with 1110 additions and 127 deletions

View File

@ -15,11 +15,11 @@ __title__ = 'sh_edraft'
__author__ = 'Sven Heidemann' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 sh-edraft.de' __copyright__ = 'Copyright (c) 2020 sh-edraft.de'
__version__ = '2020.12.5' __version__ = '2020.12.9'
from collections import namedtuple from collections import namedtuple
# imports: # imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro') VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=5) version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

@ -15,11 +15,11 @@ __title__ = 'sh_edraft.coding'
__author__ = 'Sven Heidemann' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 sh-edraft.de' __copyright__ = 'Copyright (c) 2020 sh-edraft.de'
__version__ = '2020.12.5' __version__ = '2020.12.9'
from collections import namedtuple from collections import namedtuple
VersionInfo = namedtuple('VersionInfo', 'major minor micro') VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=5) version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" """
sh_edraft.coding.base sh_edraft.coding.model
~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~
@ -11,11 +11,11 @@ sh_edraft.coding.base
""" """
__title__ = 'sh_edraft.coding.base' __title__ = 'sh_edraft.coding.model'
__author__ = 'Sven Heidemann' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 sh-edraft.de' __copyright__ = 'Copyright (c) 2020 sh-edraft.de'
__version__ = '2020.12.5' __version__ = '2020.12.9'
from collections import namedtuple from collections import namedtuple
@ -24,4 +24,4 @@ from .version import Version
from .version_enum import VersionEnum from .version_enum import VersionEnum
VersionInfo = namedtuple('VersionInfo', 'major minor micro') VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=5) version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

@ -3,6 +3,6 @@ from enum import Enum
class VersionEnum(Enum): class VersionEnum(Enum):
Major = 'major' Major = 'Major'
Minor = 'minor' Minor = 'Minor'
Micro = 'micro' Micro = 'Micro'

View File

@ -15,7 +15,7 @@ __title__ = 'sh_edraft.configuration'
__author__ = 'Sven Heidemann' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 sh-edraft.de' __copyright__ = 'Copyright (c) 2020 sh-edraft.de'
__version__ = '2020.12.5' __version__ = '2020.12.9'
from collections import namedtuple from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
from .configuration import Configuration from .configuration import Configuration
VersionInfo = namedtuple('VersionInfo', 'major minor micro') VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=5) version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

@ -15,7 +15,7 @@ __title__ = 'sh_edraft.configuration.base'
__author__ = 'Sven Heidemann' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 sh-edraft.de' __copyright__ = 'Copyright (c) 2020 sh-edraft.de'
__version__ = '2020.12.5' __version__ = '2020.12.9'
from collections import namedtuple from collections import namedtuple
@ -24,4 +24,4 @@ from .configuration_base import ConfigurationBase
from .configuration_model_base import ConfigurationModelBase from .configuration_model_base import ConfigurationModelBase
VersionInfo = namedtuple('VersionInfo', 'major minor micro') VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=5) version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

@ -8,7 +8,8 @@ from sh_edraft.configuration.model.configuration_variable_name import Configurat
from sh_edraft.environment.base.environment_base import EnvironmentBase from sh_edraft.environment.base.environment_base import EnvironmentBase
from sh_edraft.environment.hosting_environment import HostingEnvironment from sh_edraft.environment.hosting_environment import HostingEnvironment
from sh_edraft.environment.model.environment_name import EnvironmentName from sh_edraft.environment.model.environment_name import EnvironmentName
from sh_edraft.utils.console import Console from sh_edraft.console.console import Console
from sh_edraft.console.model import ForegroundColor
class Configuration(ConfigurationBase): class Configuration(ConfigurationBase):
@ -25,15 +26,21 @@ class Configuration(ConfigurationBase):
@staticmethod @staticmethod
def _print_info(name: str, message: str): def _print_info(name: str, message: str):
Console.write_line(f'[{name}] {message}', 'green') Console.set_foreground_color(ForegroundColor.green)
Console.write_line(f'[{name}] {message}')
Console.set_foreground_color(ForegroundColor.default)
@staticmethod @staticmethod
def _print_warn(name: str, message: str): def _print_warn(name: str, message: str):
Console.write_line(f'[{name}] {message}', 'yellow') Console.set_foreground_color(ForegroundColor.yellow)
Console.write_line(f'[{name}] {message}')
Console.set_foreground_color(ForegroundColor.default)
@staticmethod @staticmethod
def _print_error(name: str, message: str): def _print_error(name: str, message: str):
Console.write_line(f'[{name}] {message}', 'red') Console.set_foreground_color(ForegroundColor.red)
Console.write_line(f'[{name}] {message}')
Console.set_foreground_color(ForegroundColor.default)
def _set_variable(self, name: str, value: str): def _set_variable(self, name: str, value: str):
if name == ConfigurationVariableName.environment.value: if name == ConfigurationVariableName.environment.value:

View File

@ -1,3 +1,26 @@
# imports: # -*- coding: utf-8 -*-
"""
sh_edraft.configuration.model
~~~~~~~~~~~~~~~~~~~
:copyright: (c) 2020 sh-edraft.de
:license: MIT, see LICENSE for more details.
"""
__title__ = 'sh_edraft.configuration.model'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 sh-edraft.de'
__version__ = '2020.12.9'
from collections import namedtuple
# imports:
from .configuration_variable_name import ConfigurationVariableName from .configuration_variable_name import ConfigurationVariableName
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
"""
sh_edraft.console
~~~~~~~~~~~~~~~~~~~
:copyright: (c) 2020 sh-edraft.de
:license: MIT, see LICENSE for more details.
"""
__title__ = 'sh_edraft.console'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 sh-edraft.de'
__version__ = '2020.12.9'
from collections import namedtuple
# imports:
from .console import Console
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

@ -0,0 +1,149 @@
import os
from typing import Union, Optional
from termcolor import colored
from sh_edraft.console.model.background_color import BackgroundColor
from sh_edraft.console.model.foreground_color import ForegroundColor
class Console:
_background_color: BackgroundColor = BackgroundColor.default
_foreground_color: ForegroundColor = ForegroundColor.default
_x: Optional[int] = None
_y: Optional[int] = None
_disabled: bool = False
"""
Properties
"""
@classmethod
@property
def background_color(cls) -> str:
return str(cls._background_color.value)
@classmethod
@property
def foreground_color(cls) -> str:
return str(cls._foreground_color.value)
"""
Settings
"""
@classmethod
def set_background_color(cls, color: Union[BackgroundColor, str]):
if type(color) is str:
cls._background_color = BackgroundColor[color]
else:
cls._background_color = color
@classmethod
def set_foreground_color(cls, color: Union[ForegroundColor, str]):
if type(color) is str:
cls._foreground_color = ForegroundColor[color]
else:
cls._foreground_color = color
@classmethod
def reset_cursor_position(cls):
cls._x = None
cls._y = None
@classmethod
def set_cursor_position(cls, x: int, y: int):
cls._x = x
cls._y = y
"""
Useful protected methods
"""
@classmethod
def _output(cls, string: str, x: int = None, y: int = None, end='\n'):
if cls._disabled:
return
args = []
colored_args = []
if x is not None and y is not None:
args.append(f'\033[{x};{y}H')
elif cls._x is not None and cls._y is not None:
args.append(f'\033[{cls._x};{cls._y}H')
colored_args.append(string)
if cls._foreground_color != ForegroundColor.default and cls._background_color == BackgroundColor.default:
colored_args.append(cls._foreground_color.value)
elif cls._foreground_color == ForegroundColor.default and cls._background_color != BackgroundColor.default:
colored_args.append(cls._background_color.value)
elif cls._foreground_color != ForegroundColor.default and cls._background_color != BackgroundColor.default:
colored_args.append(cls._foreground_color.value)
colored_args.append(cls._background_color.value)
args.append(colored(*colored_args))
print(*args, end=end)
"""
Useful public methods
"""
@staticmethod
def clear():
os.system('cls' if os.name == 'nt' else 'clear')
@staticmethod
def close():
Console.reset()
Console.write('\n\n\nPress any key to continue...')
Console.read_line()
exit()
@classmethod
def disable(cls):
cls._disabled = True
@classmethod
def enable(cls):
cls._disabled = False
@classmethod
def read(cls, output: str = None) -> str:
if output is not None:
cls.write(output)
return input()[0]
@classmethod
def read_line(cls, output: str = None) -> str:
if output is not None:
cls.write(output)
return input()
@classmethod
def reset(cls):
cls._background_color = BackgroundColor.default
cls._foreground_color = ForegroundColor.default
@classmethod
def write(cls, *args):
string = ' '.join(map(str, args))
cls._output(string, end='')
@classmethod
def write_at(cls, x: int, y: int, *args):
string = ' '.join(map(str, args))
cls._output(string, x, y, end='')
@classmethod
def write_line(cls, *args):
string = ' '.join(map(str, args))
cls._output('')
cls._output(string, end='')
@classmethod
def write_line_at(cls, x: int, y: int, *args):
string = ' '.join(map(str, args))
cls._output('', end='')
cls._output(string, x, y, end='')

View File

@ -0,0 +1,27 @@
# -*- coding: utf-8 -*-
"""
sh_edraft.console.model
~~~~~~~~~~~~~~~~~~~
:copyright: (c) 2020 sh-edraft.de
:license: MIT, see LICENSE for more details.
"""
__title__ = 'sh_edraft.console.model'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 sh-edraft.de'
__version__ = '2020.12.9'
from collections import namedtuple
# imports:
from .background_color import BackgroundColor
from .foreground_color import ForegroundColor
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

@ -0,0 +1,14 @@
from enum import Enum
class BackgroundColor(Enum):
default = 'on_default'
grey = 'on_grey'
red = 'on_red'
green = 'on_green'
yellow = 'on_yellow'
blue = 'on_blue'
magenta = 'on_magenta'
cyan = 'on_cyan'
white = 'on_white'

View File

@ -0,0 +1,14 @@
from enum import Enum
class ForegroundColor(Enum):
default = 'default'
grey = 'grey'
red = 'red'
green = 'green'
yellow = 'yellow'
blue = 'blue'
magenta = 'magenta'
cyan = 'cyan'
white = 'white'

View File

@ -1 +1,25 @@
# -*- coding: utf-8 -*-
"""
sh_edraft.database
~~~~~~~~~~~~~~~~~~~
:copyright: (c) 2020 sh-edraft.de
:license: MIT, see LICENSE for more details.
"""
__title__ = 'sh_edraft.database'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 sh-edraft.de'
__version__ = '2020.12.9'
from collections import namedtuple
# imports: # imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

@ -1,3 +1,26 @@
# imports: # -*- coding: utf-8 -*-
"""
sh_edraft.database.connection
~~~~~~~~~~~~~~~~~~~
:copyright: (c) 2020 sh-edraft.de
:license: MIT, see LICENSE for more details.
"""
__title__ = 'sh_edraft.database.connection'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 sh-edraft.de'
__version__ = '2020.12.9'
from collections import namedtuple
# imports:
from .database_connection import DatabaseConnection from .database_connection import DatabaseConnection
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

@ -1,3 +1,26 @@
# imports: # -*- coding: utf-8 -*-
"""
sh_edraft.database.connection.base
~~~~~~~~~~~~~~~~~~~
:copyright: (c) 2020 sh-edraft.de
:license: MIT, see LICENSE for more details.
"""
__title__ = 'sh_edraft.database.connection.base'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 sh-edraft.de'
__version__ = '2020.12.9'
from collections import namedtuple
# imports:
from .database_connection_base import DatabaseConnectionBase from .database_connection_base import DatabaseConnectionBase
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

@ -5,7 +5,8 @@ from sqlalchemy.orm import Session, sessionmaker
from sh_edraft.database.connection.base.database_connection_base import DatabaseConnectionBase from sh_edraft.database.connection.base.database_connection_base import DatabaseConnectionBase
from sh_edraft.database.model.database_settings import DatabaseSettings from sh_edraft.database.model.database_settings import DatabaseSettings
from sh_edraft.utils.console import Console from sh_edraft.console.console import Console
from sh_edraft.console.model.foreground_color import ForegroundColor
class DatabaseConnection(DatabaseConnectionBase): class DatabaseConnection(DatabaseConnectionBase):
@ -44,8 +45,12 @@ class DatabaseConnection(DatabaseConnectionBase):
db_session = sessionmaker(bind=self._engine) db_session = sessionmaker(bind=self._engine)
self._session = db_session() self._session = db_session()
Console.write_line(f'[{__name__}] Connected to database', 'green') Console.set_foreground_color(ForegroundColor.green)
Console.write_line(f'[{__name__}] Connected to database')
Console.set_foreground_color(ForegroundColor.default)
except Exception as e: except Exception as e:
Console.write_line(f'[{__name__}] Database connection failed -> {e}', 'red') Console.set_foreground_color(ForegroundColor.red)
Console.write_line(f'[{__name__}] Database connection failed -> {e}')
Console.set_foreground_color(ForegroundColor.default)
exit() exit()

View File

@ -1,3 +1,26 @@
# imports: # -*- coding: utf-8 -*-
"""
sh_edraft.database.context
~~~~~~~~~~~~~~~~~~~
:copyright: (c) 2020 sh-edraft.de
:license: MIT, see LICENSE for more details.
"""
__title__ = 'sh_edraft.database.context'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 sh-edraft.de'
__version__ = '2020.12.9'
from collections import namedtuple
# imports:
from .database_context import DatabaseContext from .database_context import DatabaseContext
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

@ -1,3 +1,26 @@
# imports: # -*- coding: utf-8 -*-
"""
sh_edraft.database.context.base
~~~~~~~~~~~~~~~~~~~
:copyright: (c) 2020 sh-edraft.de
:license: MIT, see LICENSE for more details.
"""
__title__ = 'sh_edraft.database.context.base'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 sh-edraft.de'
__version__ = '2020.12.9'
from collections import namedtuple
# imports:
from .database_context_base import DatabaseContextBase from .database_context_base import DatabaseContextBase
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

@ -6,7 +6,8 @@ from sh_edraft.database.connection.base.database_connection_base import Database
from sh_edraft.database.context.base.database_context_base import DatabaseContextBase from sh_edraft.database.context.base.database_context_base import DatabaseContextBase
from sh_edraft.database.model.dbmodel import DBModel from sh_edraft.database.model.dbmodel import DBModel
from sh_edraft.database.model.database_settings import DatabaseSettings from sh_edraft.database.model.database_settings import DatabaseSettings
from sh_edraft.utils.console import Console from sh_edraft.console.console import Console
from sh_edraft.console.model.foreground_color import ForegroundColor
class DatabaseContext(DatabaseContextBase): class DatabaseContext(DatabaseContextBase):
@ -39,7 +40,11 @@ class DatabaseContext(DatabaseContextBase):
DBModel.metadata.drop_all(self._db.engine, self._tables) DBModel.metadata.drop_all(self._db.engine, self._tables)
DBModel.metadata.create_all(self._db.engine, self._tables, checkfirst=True) DBModel.metadata.create_all(self._db.engine, self._tables, checkfirst=True)
Console.write_line(f'[{__name__}] Created tables', 'green') Console.set_foreground_color(ForegroundColor.green)
Console.write_line(f'[{__name__}] Created tables')
Console.set_foreground_color(ForegroundColor.default)
except Exception as e: except Exception as e:
Console.write_line(f'[{__name__}] Creating tables failed -> {e}', 'red') Console.set_foreground_color(ForegroundColor.red)
Console.write_line(f'[{__name__}] Creating tables failed -> {e}')
Console.set_foreground_color(ForegroundColor.default)
exit() exit()

View File

@ -1,5 +1,28 @@
# imports: # -*- coding: utf-8 -*-
"""
sh_edraft.database.model
~~~~~~~~~~~~~~~~~~~
:copyright: (c) 2020 sh-edraft.de
:license: MIT, see LICENSE for more details.
"""
__title__ = 'sh_edraft.database.model'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 sh-edraft.de'
__version__ = '2020.12.9'
from collections import namedtuple
# imports:
from .database_settings import DatabaseSettings from .database_settings import DatabaseSettings
from .database_settings_name import DatabaseSettingsName from .database_settings_name import DatabaseSettingsName
from .dbmodel import DBModel from .dbmodel import DBModel
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

@ -3,7 +3,8 @@ from typing import Optional
from sh_edraft.configuration.base.configuration_model_base import ConfigurationModelBase from sh_edraft.configuration.base.configuration_model_base import ConfigurationModelBase
from sh_edraft.database.model.database_settings_name import DatabaseSettingsName from sh_edraft.database.model.database_settings_name import DatabaseSettingsName
from sh_edraft.utils.console import Console from sh_edraft.console.console import Console
from sh_edraft.console.model.foreground_color import ForegroundColor
class DatabaseSettings(ConfigurationModelBase): class DatabaseSettings(ConfigurationModelBase):
@ -71,5 +72,7 @@ class DatabaseSettings(ConfigurationModelBase):
if DatabaseSettingsName.echo.value in settings: if DatabaseSettingsName.echo.value in settings:
self._echo = bool(settings[DatabaseSettingsName.echo.value]) self._echo = bool(settings[DatabaseSettingsName.echo.value])
except Exception as e: except Exception as e:
Console.write_line(f'[ ERROR ] [ {__name__} ]: Reading error in {self.__name__} settings', 'red') Console.set_foreground_color(ForegroundColor.red)
Console.write_line(f'[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}', 'red') Console.write_line(f'[ ERROR ] [ {__name__} ]: Reading error in {self.__name__} settings')
Console.write_line(f'[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}')
Console.set_foreground_color(ForegroundColor.default)

View File

@ -15,11 +15,11 @@ __title__ = 'sh_edraft.discord'
__author__ = 'Sven Heidemann' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 sh-edraft.de' __copyright__ = 'Copyright (c) 2020 sh-edraft.de'
__version__ = '2020.12.5' __version__ = '2020.12.9'
from collections import namedtuple from collections import namedtuple
VersionInfo = namedtuple('VersionInfo', 'major minor micro') VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=5) version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

@ -1,3 +1,26 @@
# imports: # -*- coding: utf-8 -*-
"""
sh_edraft.environment
~~~~~~~~~~~~~~~~~~~
:copyright: (c) 2020 sh-edraft.de
:license: MIT, see LICENSE for more details.
"""
__title__ = 'sh_edraft.environment'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 sh-edraft.de'
__version__ = '2020.12.9'
from collections import namedtuple
# imports:
from .hosting_environment import HostingEnvironment from .hosting_environment import HostingEnvironment
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

@ -1,3 +1,26 @@
# imports: # -*- coding: utf-8 -*-
"""
sh_edraft.environment.base
~~~~~~~~~~~~~~~~~~~
:copyright: (c) 2020 sh-edraft.de
:license: MIT, see LICENSE for more details.
"""
__title__ = 'sh_edraft.environment.base'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 sh-edraft.de'
__version__ = '2020.12.9'
from collections import namedtuple
# imports:
from .environment_base import EnvironmentBase from .environment_base import EnvironmentBase
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

@ -1,3 +1,26 @@
# imports: # -*- coding: utf-8 -*-
"""
sh_edraft.environment.model
~~~~~~~~~~~~~~~~~~~
:copyright: (c) 2020 sh-edraft.de
:license: MIT, see LICENSE for more details.
"""
__title__ = 'sh_edraft.environment.model'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 sh-edraft.de'
__version__ = '2020.12.9'
from collections import namedtuple
# imports:
from .environment_name import EnvironmentName from .environment_name import EnvironmentName
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

@ -1,4 +1,27 @@
# imports: # -*- coding: utf-8 -*-
"""
sh_edraft.hosting
~~~~~~~~~~~~~~~~~~~
:copyright: (c) 2020 sh-edraft.de
:license: MIT, see LICENSE for more details.
"""
__title__ = 'sh_edraft.hosting'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 sh-edraft.de'
__version__ = '2020.12.9'
from collections import namedtuple
# imports:
from .application_host import ApplicationHost from .application_host import ApplicationHost
from .application_runtime import ApplicationRuntime from .application_runtime import ApplicationRuntime
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

@ -1,3 +1,4 @@
import atexit
from datetime import datetime from datetime import datetime
from sh_edraft.configuration.configuration import Configuration from sh_edraft.configuration.configuration import Configuration
@ -7,6 +8,7 @@ from sh_edraft.hosting.application_runtime import ApplicationRuntime
from sh_edraft.hosting.base.application_host_base import ApplicationHostBase from sh_edraft.hosting.base.application_host_base import ApplicationHostBase
from sh_edraft.service.providing.service_provider import ServiceProvider from sh_edraft.service.providing.service_provider import ServiceProvider
from sh_edraft.service.providing.base.service_provider_base import ServiceProviderBase from sh_edraft.service.providing.base.service_provider_base import ServiceProviderBase
from sh_edraft.console.console import Console
class ApplicationHost(ApplicationHostBase): class ApplicationHost(ApplicationHostBase):
@ -27,6 +29,8 @@ class ApplicationHost(ApplicationHostBase):
self._start_time: datetime = datetime.now() self._start_time: datetime = datetime.now()
self._end_time: datetime = datetime.now() self._end_time: datetime = datetime.now()
atexit.register(Console.close)
@property @property
def configuration(self) -> ConfigurationBase: def configuration(self) -> ConfigurationBase:
return self._config return self._config

View File

@ -1,4 +1,28 @@
# -*- coding: utf-8 -*-
"""
sh_edraft.hosting.base
~~~~~~~~~~~~~~~~~~~
:copyright: (c) 2020 sh-edraft.de
:license: MIT, see LICENSE for more details.
"""
__title__ = 'sh_edraft.hosting.base'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 sh-edraft.de'
__version__ = '2020.12.9'
from collections import namedtuple
# imports: # imports:
from .application_base import ApplicationBase from .application_base import ApplicationBase
from .application_host_base import ApplicationHostBase from .application_host_base import ApplicationHostBase
from .application_runtime_base import ApplicationRuntimeBase from .application_runtime_base import ApplicationRuntimeBase
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

@ -1 +1,25 @@
# -*- coding: utf-8 -*-
"""
sh_edraft.hosting.model
~~~~~~~~~~~~~~~~~~~
:copyright: (c) 2020 sh-edraft.de
:license: MIT, see LICENSE for more details.
"""
__title__ = 'sh_edraft.hosting.model'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 sh-edraft.de'
__version__ = '2020.12.9'
from collections import namedtuple
# imports: # imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

@ -15,7 +15,7 @@ __title__ = 'sh_edraft.logging'
__author__ = 'Sven Heidemann' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 sh-edraft.de' __copyright__ = 'Copyright (c) 2020 sh-edraft.de'
__version__ = '2020.12.5' __version__ = '2020.12.9'
from collections import namedtuple from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
from .logger import Logger from .logger import Logger
VersionInfo = namedtuple('VersionInfo', 'major minor micro') VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=5) version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

@ -15,7 +15,7 @@ __title__ = 'sh_edraft.logging.base'
__author__ = 'Sven Heidemann' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 sh-edraft.de' __copyright__ = 'Copyright (c) 2020 sh-edraft.de'
__version__ = '2020.12.5' __version__ = '2020.12.9'
from collections import namedtuple from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
from .logger_base import LoggerBase from .logger_base import LoggerBase
VersionInfo = namedtuple('VersionInfo', 'major minor micro') VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=5) version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

@ -8,7 +8,8 @@ from sh_edraft.logging.base.logger_base import LoggerBase
from sh_edraft.logging.model.logging_settings import LoggingSettings from sh_edraft.logging.model.logging_settings import LoggingSettings
from sh_edraft.logging.model.logging_level import LoggingLevel from sh_edraft.logging.model.logging_level import LoggingLevel
from sh_edraft.time.model.time_format_settings import TimeFormatSettings from sh_edraft.time.model.time_format_settings import TimeFormatSettings
from sh_edraft.utils.console import Console from sh_edraft.console.console import Console
from sh_edraft.console.model.foreground_color import ForegroundColor
class Logger(LoggerBase): class Logger(LoggerBase):
@ -80,7 +81,9 @@ class Logger(LoggerBase):
def header(self, string: str): def header(self, string: str):
# append log and print message # append log and print message
self._append_log(string) self._append_log(string)
Console.write_line(string, 'white') Console.set_foreground_color(ForegroundColor.default)
Console.write_line(string)
Console.set_foreground_color(ForegroundColor.default)
def trace(self, name: str, message: str): def trace(self, name: str, message: str):
output = self._get_string(name, LoggingLevel.TRACE, message) output = self._get_string(name, LoggingLevel.TRACE, message)
@ -91,7 +94,9 @@ class Logger(LoggerBase):
# check if message can be shown in console # check if message can be shown in console
if self._console.value >= LoggingLevel.TRACE.value: if self._console.value >= LoggingLevel.TRACE.value:
Console.write_line(output, 'green') Console.set_foreground_color(ForegroundColor.green)
Console.write_line(output)
Console.set_foreground_color(ForegroundColor.default)
def debug(self, name: str, message: str): def debug(self, name: str, message: str):
output = self._get_string(name, LoggingLevel.DEBUG, message) output = self._get_string(name, LoggingLevel.DEBUG, message)
@ -102,7 +107,9 @@ class Logger(LoggerBase):
# check if message can be shown in console # check if message can be shown in console
if self._console.value >= LoggingLevel.DEBUG.value: if self._console.value >= LoggingLevel.DEBUG.value:
Console.write_line(output, 'green') Console.set_foreground_color(ForegroundColor.green)
Console.write_line(output)
Console.set_foreground_color(ForegroundColor.default)
def info(self, name: str, message: str): def info(self, name: str, message: str):
output = self._get_string(name, LoggingLevel.INFO, message) output = self._get_string(name, LoggingLevel.INFO, message)
@ -113,7 +120,9 @@ class Logger(LoggerBase):
# check if message can be shown in console # check if message can be shown in console
if self._console.value >= LoggingLevel.INFO.value: if self._console.value >= LoggingLevel.INFO.value:
Console.write_line(output, 'green') Console.set_foreground_color(ForegroundColor.green)
Console.write_line(output)
Console.set_foreground_color(ForegroundColor.default)
def warn(self, name: str, message: str): def warn(self, name: str, message: str):
output = self._get_string(name, LoggingLevel.WARN, message) output = self._get_string(name, LoggingLevel.WARN, message)
@ -124,7 +133,9 @@ class Logger(LoggerBase):
# check if message can be shown in console # check if message can be shown in console
if self._console.value >= LoggingLevel.WARN.value: if self._console.value >= LoggingLevel.WARN.value:
Console.write_line(output, 'yellow') Console.set_foreground_color(ForegroundColor.yellow)
Console.write_line(output)
Console.set_foreground_color(ForegroundColor.default)
def error(self, name: str, message: str, ex: Exception = None): def error(self, name: str, message: str, ex: Exception = None):
output = '' output = ''
@ -141,7 +152,9 @@ class Logger(LoggerBase):
# check if message can be shown in console # check if message can be shown in console
if self._console.value >= LoggingLevel.ERROR.value: if self._console.value >= LoggingLevel.ERROR.value:
Console.write_line(output, 'red') Console.set_foreground_color(ForegroundColor.red)
Console.write_line(output)
Console.set_foreground_color(ForegroundColor.default)
def fatal(self, name: str, message: str, ex: Exception = None): def fatal(self, name: str, message: str, ex: Exception = None):
output = '' output = ''
@ -158,7 +171,9 @@ class Logger(LoggerBase):
# check if message can be shown in console # check if message can be shown in console
if self._console.value >= LoggingLevel.FATAL.value: if self._console.value >= LoggingLevel.FATAL.value:
Console.write_line(output, 'red') Console.set_foreground_color(ForegroundColor.red)
Console.write_line(output)
Console.set_foreground_color(ForegroundColor.default)
exit() exit()
@ -173,6 +188,8 @@ class Logger(LoggerBase):
# check if message can be shown in console # check if message can be shown in console
if self._console.value >= LoggingLevel.FATAL.value: if self._console.value >= LoggingLevel.FATAL.value:
Console.write_line(output, 'red') Console.set_foreground_color(ForegroundColor.red)
Console.write_line(output)
Console.set_foreground_color(ForegroundColor.default)
exit() exit()

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" """
sh_edraft.logging.base sh_edraft.logging.model
~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~
@ -11,11 +11,11 @@ sh_edraft.logging.base
""" """
__title__ = 'sh_edraft.logging.base' __title__ = 'sh_edraft.logging.model'
__author__ = 'Sven Heidemann' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 sh-edraft.de' __copyright__ = 'Copyright (c) 2020 sh-edraft.de'
__version__ = '2020.12.5' __version__ = '2020.12.9'
from collections import namedtuple from collections import namedtuple
@ -25,4 +25,4 @@ from .logging_settings import LoggingSettings
from .logging_settings_name import LoggingSettingsName from .logging_settings_name import LoggingSettingsName
VersionInfo = namedtuple('VersionInfo', 'major minor micro') VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=5) version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

@ -3,8 +3,9 @@ from typing import Optional
from sh_edraft.configuration.base.configuration_model_base import ConfigurationModelBase from sh_edraft.configuration.base.configuration_model_base import ConfigurationModelBase
from sh_edraft.logging.model.logging_settings_name import LoggingSettingsName from sh_edraft.logging.model.logging_settings_name import LoggingSettingsName
from sh_edraft.utils.console import Console
from sh_edraft.logging.model.logging_level import LoggingLevel from sh_edraft.logging.model.logging_level import LoggingLevel
from sh_edraft.console.console import Console
from sh_edraft.console.model.foreground_color import ForegroundColor
class LoggingSettings(ConfigurationModelBase): class LoggingSettings(ConfigurationModelBase):
@ -55,5 +56,7 @@ class LoggingSettings(ConfigurationModelBase):
self._console = LoggingLevel[settings[LoggingSettingsName.console_level.value]] self._console = LoggingLevel[settings[LoggingSettingsName.console_level.value]]
self._level = LoggingLevel[settings[LoggingSettingsName.file_level.value]] self._level = LoggingLevel[settings[LoggingSettingsName.file_level.value]]
except Exception as e: except Exception as e:
Console.write_line(f'[ ERROR ] [ {__name__} ]: Reading error in {self.__name__} settings', 'red') Console.set_foreground_color(ForegroundColor.red)
Console.write_line(f'[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}', 'red') Console.write_line(f'[ ERROR ] [ {__name__} ]: Reading error in {self.__name__} settings')
Console.write_line(f'[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}')
Console.set_foreground_color(ForegroundColor.default)

View File

@ -15,11 +15,11 @@ __title__ = 'sh_edraft.mailing'
__author__ = 'Sven Heidemann' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 sh-edraft.de' __copyright__ = 'Copyright (c) 2020 sh-edraft.de'
__version__ = '2020.12.5' __version__ = '2020.12.9'
from collections import namedtuple from collections import namedtuple
VersionInfo = namedtuple('VersionInfo', 'major minor micro') VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=5) version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

@ -15,11 +15,11 @@ __title__ = 'sh_edraft.messaging'
__author__ = 'Sven Heidemann' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 sh-edraft.de' __copyright__ = 'Copyright (c) 2020 sh-edraft.de'
__version__ = '2020.12.5' __version__ = '2020.12.9'
from collections import namedtuple from collections import namedtuple
# imports: # imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro') VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=5) version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

@ -15,7 +15,7 @@ __title__ = 'sh_edraft.publishing'
__author__ = 'Sven Heidemann' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 sh-edraft.de' __copyright__ = 'Copyright (c) 2020 sh-edraft.de'
__version__ = '2020.12.5' __version__ = '2020.12.9'
from collections import namedtuple from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
from .publisher import Publisher from .publisher import Publisher
VersionInfo = namedtuple('VersionInfo', 'major minor micro') VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=5) version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

@ -15,7 +15,7 @@ __title__ = 'sh_edraft.publishing.base'
__author__ = 'Sven Heidemann' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 sh-edraft.de' __copyright__ = 'Copyright (c) 2020 sh-edraft.de'
__version__ = '2020.12.5' __version__ = '2020.12.9'
from collections import namedtuple from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
from .publisher_base import PublisherBase from .publisher_base import PublisherBase
VersionInfo = namedtuple('VersionInfo', 'major minor micro') VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=5) version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" """
sh_edraft.publishing.base sh_edraft.publishing.model
~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~
@ -11,11 +11,11 @@ sh_edraft.publishing.base
""" """
__title__ = 'sh_edraft.publishing.base' __title__ = 'sh_edraft.publishing.model'
__author__ = 'Sven Heidemann' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 sh-edraft.de' __copyright__ = 'Copyright (c) 2020 sh-edraft.de'
__version__ = '2020.12.5' __version__ = '2020.12.9'
from collections import namedtuple from collections import namedtuple
@ -26,4 +26,4 @@ from .publish_settings_model import PublishSettings
from .publish_settings_name import PublishSettingsName from .publish_settings_name import PublishSettingsName
VersionInfo = namedtuple('VersionInfo', 'major minor micro') VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=5) version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

@ -4,7 +4,8 @@ from typing import Optional
from sh_edraft.configuration.base.configuration_model_base import ConfigurationModelBase from sh_edraft.configuration.base.configuration_model_base import ConfigurationModelBase
from sh_edraft.publishing.model.template import Template from sh_edraft.publishing.model.template import Template
from sh_edraft.publishing.model.publish_settings_name import PublishSettingsName from sh_edraft.publishing.model.publish_settings_name import PublishSettingsName
from sh_edraft.utils.console import Console from sh_edraft.console.console import Console
from sh_edraft.console.model.foreground_color import ForegroundColor
class PublishSettings(ConfigurationModelBase): class PublishSettings(ConfigurationModelBase):
@ -14,10 +15,10 @@ class PublishSettings(ConfigurationModelBase):
self._source_path: Optional[str] = None self._source_path: Optional[str] = None
self._dist_path: Optional[str] = None self._dist_path: Optional[str] = None
self._templates: Optional[list[Template]] = None self._templates: list[Template] = []
self._included_files: Optional[list[str]] = None self._included_files: list[str] = []
self._excluded_files: Optional[list[str]] = None self._excluded_files: list[str] = []
self._template_ending: Optional[str] = None self._template_ending: Optional[str] = None
@ -73,11 +74,17 @@ class PublishSettings(ConfigurationModelBase):
try: try:
self._source_path = settings[PublishSettingsName.source_path.value] self._source_path = settings[PublishSettingsName.source_path.value]
self._dist_path = settings[PublishSettingsName.dist_path.value] self._dist_path = settings[PublishSettingsName.dist_path.value]
self._templates = settings[PublishSettingsName.templates.value] for template in settings[PublishSettingsName.templates.value]:
temp = Template()
temp.from_dict(template)
self._templates.append(temp)
self._included_files = settings[PublishSettingsName.included_files.value] self._included_files = settings[PublishSettingsName.included_files.value]
self._excluded_files = settings[PublishSettingsName.excluded_files.value] self._excluded_files = settings[PublishSettingsName.excluded_files.value]
self._template_ending = settings[PublishSettingsName.template_ending.value] self._template_ending = settings[PublishSettingsName.template_ending.value]
except Exception as e: except Exception as e:
Console.set_foreground_color(ForegroundColor.red)
Console.write_line( Console.write_line(
f'[ ERROR ] [ {__name__} ]: Reading error in {PublishSettingsName.publish.value} settings', 'red') f'[ ERROR ] [ {__name__} ]: Reading error in {PublishSettingsName.publish.value} settings')
Console.write_line(f'[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}', 'red') Console.write_line(f'[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}')
Console.set_foreground_color(ForegroundColor.default)

View File

@ -19,7 +19,7 @@ class Template(ConfigurationModelBase):
license_description: Optional[str] = None, license_description: Optional[str] = None,
title: Optional[str] = None, title: Optional[str] = None,
author: Optional[str] = None, author: Optional[str] = None,
version: Optional[dict] = None version: Optional[Version] = Version()
): ):
ConfigurationModelBase.__init__(self) ConfigurationModelBase.__init__(self)
self._template_path: Optional[str] = template_path self._template_path: Optional[str] = template_path
@ -33,8 +33,7 @@ class Template(ConfigurationModelBase):
self._title: Optional[str] = title self._title: Optional[str] = title
self._author: Optional[str] = author self._author: Optional[str] = author
self._version: Optional[Version] = Version() self._version: Optional[Version] = version
self._version.from_dict(version)
self._file_content: Optional[str] = None self._file_content: Optional[str] = None

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" """
sh_edraft.services sh_edraft.service
~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~
@ -11,15 +11,15 @@ sh_edraft.services
""" """
__title__ = 'sh_edraft.services' __title__ = 'sh_edraft.service'
__author__ = 'Sven Heidemann' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 sh-edraft.de' __copyright__ = 'Copyright (c) 2020 sh-edraft.de'
__version__ = '2020.12.5' __version__ = '2020.12.9'
from collections import namedtuple from collections import namedtuple
# imports: # imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro') VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=5) version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" """
sh_edraft.services.base sh_edraft.service.base
~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~
@ -11,11 +11,11 @@ sh_edraft.services.base
""" """
__title__ = 'sh_edraft.services.base' __title__ = 'sh_edraft.service.base'
__author__ = 'Sven Heidemann' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 sh-edraft.de' __copyright__ = 'Copyright (c) 2020 sh-edraft.de'
__version__ = '2020.12.5' __version__ = '2020.12.9'
from collections import namedtuple from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
from .service_base import ServiceBase from .service_base import ServiceBase
VersionInfo = namedtuple('VersionInfo', 'major minor micro') VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=5) version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" """
sh_edraft.services.base sh_edraft.service.model
~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~
@ -11,11 +11,11 @@ sh_edraft.services.base
""" """
__title__ = 'sh_edraft.services.base' __title__ = 'sh_edraft.service.model'
__author__ = 'Sven Heidemann' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 sh-edraft.de' __copyright__ = 'Copyright (c) 2020 sh-edraft.de'
__version__ = '2020.12.5' __version__ = '2020.12.9'
from collections import namedtuple from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
from .provide_state import ProvideState from .provide_state import ProvideState
VersionInfo = namedtuple('VersionInfo', 'major minor micro') VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=5) version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

@ -1,4 +1,27 @@
# -*- coding: utf-8 -*-
"""
sh_edraft.service.providing
~~~~~~~~~~~~~~~~~~~
:copyright: (c) 2020 sh-edraft.de
:license: MIT, see LICENSE for more details.
"""
__title__ = 'sh_edraft.service.providing'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 sh-edraft.de'
__version__ = '2020.12.9'
from collections import namedtuple
# imports: # imports:
from .service_provider import ServiceProvider from .service_provider import ServiceProvider
from .service_provider import ServiceProviderBase from .service_provider import ServiceProviderBase
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

@ -1,3 +1,26 @@
# imports: # -*- coding: utf-8 -*-
"""
sh_edraft.service.providing.base
~~~~~~~~~~~~~~~~~~~
:copyright: (c) 2020 sh-edraft.de
:license: MIT, see LICENSE for more details.
"""
__title__ = 'sh_edraft.service.providing.base'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 sh-edraft.de'
__version__ = '2020.12.9'
from collections import namedtuple
# imports:
from .service_provider_base import ServiceProviderBase from .service_provider_base import ServiceProviderBase
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

@ -1,3 +1,26 @@
# imports: # -*- coding: utf-8 -*-
"""
sh_edraft.service.providing.model
~~~~~~~~~~~~~~~~~~~
:copyright: (c) 2020 sh-edraft.de
:license: MIT, see LICENSE for more details.
"""
__title__ = 'sh_edraft.service.providing.model'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 sh-edraft.de'
__version__ = '2020.12.9'
from collections import namedtuple
# imports:
from .provide_state import ProvideState from .provide_state import ProvideState
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

@ -15,11 +15,11 @@ __title__ = 'sh_edraft.time'
__author__ = 'Sven Heidemann' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 sh-edraft.de' __copyright__ = 'Copyright (c) 2020 sh-edraft.de'
__version__ = '2020.12.5' __version__ = '2020.12.9'
from collections import namedtuple from collections import namedtuple
# imports: # imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro') VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=5) version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" """
sh_edraft.time.base sh_edraft.time.model
~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~
@ -11,11 +11,11 @@ sh_edraft.time.base
""" """
__title__ = 'sh_edraft.time.base' __title__ = 'sh_edraft.time.model'
__author__ = 'Sven Heidemann' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 sh-edraft.de' __copyright__ = 'Copyright (c) 2020 sh-edraft.de'
__version__ = '2020.12.5' __version__ = '2020.12.9'
from collections import namedtuple from collections import namedtuple
@ -24,4 +24,4 @@ from .time_format_settings import TimeFormatSettings
from .time_format_settings_names import TimeFormatSettingsNames from .time_format_settings_names import TimeFormatSettingsNames
VersionInfo = namedtuple('VersionInfo', 'major minor micro') VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=5) version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

@ -3,7 +3,8 @@ from typing import Optional
from sh_edraft.configuration.base.configuration_model_base import ConfigurationModelBase from sh_edraft.configuration.base.configuration_model_base import ConfigurationModelBase
from sh_edraft.time.model.time_format_settings_names import TimeFormatSettingsNames from sh_edraft.time.model.time_format_settings_names import TimeFormatSettingsNames
from sh_edraft.utils.console import Console from sh_edraft.console.console import Console
from sh_edraft.console.model.foreground_color import ForegroundColor
class TimeFormatSettings(ConfigurationModelBase): class TimeFormatSettings(ConfigurationModelBase):
@ -56,5 +57,7 @@ class TimeFormatSettings(ConfigurationModelBase):
self._date_time_format = settings[TimeFormatSettingsNames.date_time_format.value] self._date_time_format = settings[TimeFormatSettingsNames.date_time_format.value]
self._date_time_log_format = settings[TimeFormatSettingsNames.date_time_log_format.value] self._date_time_log_format = settings[TimeFormatSettingsNames.date_time_log_format.value]
except Exception as e: except Exception as e:
Console.set_foreground_color(ForegroundColor.red)
Console.write_line(f'[ ERROR ] [ {__name__} ]: Reading error in {self.__name__} settings') Console.write_line(f'[ ERROR ] [ {__name__} ]: Reading error in {self.__name__} settings')
Console.write_line(f'[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}', 'red') Console.write_line(f'[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}')
Console.set_foreground_color(ForegroundColor.default)

View File

@ -15,13 +15,12 @@ __title__ = 'sh_edraft.utils'
__author__ = 'Sven Heidemann' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 sh-edraft.de' __copyright__ = 'Copyright (c) 2020 sh-edraft.de'
__version__ = '2020.12.5' __version__ = '2020.12.9'
from collections import namedtuple from collections import namedtuple
# imports: # imports:
from .console import Console
from .credential_manager import CredentialManager from .credential_manager import CredentialManager
VersionInfo = namedtuple('VersionInfo', 'major minor micro') VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=5) version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

@ -1,11 +0,0 @@
from termcolor import colored
class Console:
@staticmethod
def write_line(string: str, color: str = None):
if color is not None:
print(colored(string, color))
else:
print(string)

View File

@ -15,11 +15,11 @@ __title__ = 'tests'
__author__ = 'Sven Heidemann' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 sh-edraft.de' __copyright__ = 'Copyright (c) 2020 sh-edraft.de'
__version__ = '2020.12.5' __version__ = '2020.12.9'
from collections import namedtuple from collections import namedtuple
# imports: # imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro') VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=5) version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
"""
tests.configuration
~~~~~~~~~~~~~~~~~~~
:copyright: (c) 2020 sh-edraft.de
:license: MIT, see LICENSE for more details.
"""
__title__ = 'tests.configuration'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 sh-edraft.de'
__version__ = '2020.12.9'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
"""
tests.hosting
~~~~~~~~~~~~~~~~~~~
:copyright: (c) 2020 sh-edraft.de
:license: MIT, see LICENSE for more details.
"""
__title__ = 'tests.hosting'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 sh-edraft.de'
__version__ = '2020.12.9'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
"""
tests.service_providing
~~~~~~~~~~~~~~~~~~~
:copyright: (c) 2020 sh-edraft.de
:license: MIT, see LICENSE for more details.
"""
__title__ = 'tests.service_providing'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 sh-edraft.de'
__version__ = '2020.12.9'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
"""
tests.services
~~~~~~~~~~~~~~~~~~~
:copyright: (c) 2020 sh-edraft.de
:license: MIT, see LICENSE for more details.
"""
__title__ = 'tests.services'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 sh-edraft.de'
__version__ = '2020.12.9'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
"""
tests.services.logging
~~~~~~~~~~~~~~~~~~~
:copyright: (c) 2020 sh-edraft.de
:license: MIT, see LICENSE for more details.
"""
__title__ = 'tests.services.logging'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 sh-edraft.de'
__version__ = '2020.12.9'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
"""
tests.services.publishing
~~~~~~~~~~~~~~~~~~~
:copyright: (c) 2020 sh-edraft.de
:license: MIT, see LICENSE for more details.
"""
__title__ = 'tests.services.publishing'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 sh-edraft.de'
__version__ = '2020.12.9'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

@ -15,7 +15,7 @@ from sh_edraft.time.model import TimeFormatSettings
class PublisherTest(unittest.TestCase): class PublisherTest(unittest.TestCase):
def _configure(self): def _configure(self):
self._version = Version(2020, 12, 5).to_dict() self._version = Version(2020, 12, 5)
templates = [ templates = [
Template( Template(
'../../publish_templates/all_template.txt', '../../publish_templates/all_template.txt',

View File

@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
"""
tests_dev
~~~~~~~~~~~~~~~~~~~
:copyright: (c) 2020 sh-edraft.de
:license: MIT, see LICENSE for more details.
"""
__title__ = 'tests_dev'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 sh-edraft.de'
__version__ = '2020.12.9'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

@ -5,6 +5,7 @@
"ConsoleLogLevel": "TRACE", "ConsoleLogLevel": "TRACE",
"FileLogLevel": "TRACE" "FileLogLevel": "TRACE"
}, },
"DatabaseSettings": { "DatabaseSettings": {
"ConnectionString": "mysql+mysqlconnector://sh_cpl:$credentials@localhost/sh_cpl", "ConnectionString": "mysql+mysqlconnector://sh_cpl:$credentials@localhost/sh_cpl",
"Credentials": "MHZhc0Y2bjhKc1VUMWV0Qw==", "Credentials": "MHZhc0Y2bjhKc1VUMWV0Qw==",

View File

@ -0,0 +1,57 @@
{
"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": "TRACE",
"FileLogLevel": "TRACE"
},
"PublishSettings": {
"SourcePath": "../",
"DistPath": "../../dist",
"Templates": [
{
"TemplatePath": "../../publish_templates/all_template.txt",
"Name": "all",
"Description": "",
"LongDescription": "",
"CopyrightDate": "2020",
"CopyrightName": "sh-edraft.de",
"LicenseName": "MIT",
"LicenseDescription": ", see LICENSE for more details.",
"Title": "",
"Author": "Sven Heidemann",
"Version": {
"Major": 2020,
"Minor": 12,
"Micro": 9
}
},
{
"TemplatePath": "../../publish_templates/all_template.txt",
"Name": "sh_edraft",
"Description": "common python library",
"LongDescription": "Library to share common classes and models used at sh-edraft.de",
"CopyrightDate": "2020",
"CopyrightName": "sh-edraft.de",
"LicenseName": "MIT",
"LicenseDescription": ", see LICENSE for more details.",
"Title": "",
"Author": "Sven Heidemann",
"Version": {
"Major": 2020,
"Minor": 12,
"Micro": 9
}
}
],
"IncludedFiles": [],
"ExcludedFiles": [],
"TemplateEnding": "_template.txt"
}
}

View File

@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
"""
tests_dev.db
~~~~~~~~~~~~~~~~~~~
:copyright: (c) 2020 sh-edraft.de
:license: MIT, see LICENSE for more details.
"""
__title__ = 'tests_dev.db'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 sh-edraft.de'
__version__ = '2020.12.9'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

@ -1,6 +1,7 @@
from typing import Optional from typing import Optional
from sh_edraft.configuration.base import ConfigurationBase from sh_edraft.configuration.base import ConfigurationBase
from sh_edraft.console import Console
from sh_edraft.database.context import DatabaseContext from sh_edraft.database.context import DatabaseContext
from sh_edraft.database.model import DatabaseSettings from sh_edraft.database.model import DatabaseSettings
from sh_edraft.hosting import ApplicationHost from sh_edraft.hosting import ApplicationHost
@ -56,3 +57,22 @@ class Program(ApplicationBase):
self._logger.debug(__name__, f'Environment: {self._configuration.environment.environment_name}') self._logger.debug(__name__, f'Environment: {self._configuration.environment.environment_name}')
self._logger.debug(__name__, f'Customer: {self._configuration.environment.customer}') self._logger.debug(__name__, f'Customer: {self._configuration.environment.customer}')
self._services.get_service(UserRepoBase).add_test_user() self._services.get_service(UserRepoBase).add_test_user()
Console.clear()
Console.write_line('Hello', 'World')
# name = Console.read_line('Name: ')
# Console.write_line('Hello', name)
Console.set_foreground_color('red')
Console.set_background_color('green')
Console.set_cursor_position(5, 5)
Console.write_line('Error')
Console.write_line_at(10, 5, 'Error')
Console.write_at(15, 5, 'Error')
Console.reset_cursor_position()
Console.set_foreground_color('green')
Console.set_background_color('default')
Console.write_line('Test')
Console.write('1')
# Console.write('x: ')
# Console.read_line('Test> ')
Console.write_line(Console.foreground_color)

View File

@ -0,0 +1,63 @@
from typing import Optional
from sh_edraft.configuration.base import ConfigurationBase
from sh_edraft.console import Console
from sh_edraft.hosting import ApplicationHost
from sh_edraft.hosting.base import ApplicationBase
from sh_edraft.logging import Logger
from sh_edraft.logging.base import LoggerBase
from sh_edraft.publishing import Publisher
from sh_edraft.publishing.base import PublisherBase
from sh_edraft.service.providing.base import ServiceProviderBase
class Program(ApplicationBase):
def __init__(self):
ApplicationBase.__init__(self)
self._app_host: Optional[ApplicationHost] = None
self._services: Optional[ServiceProviderBase] = None
self._configuration: Optional[ConfigurationBase] = None
self._logger: Optional[LoggerBase] = None
self._publisher: Optional[PublisherBase] = None
def create_application_host(self):
self._app_host = ApplicationHost()
self._configuration = self._app_host.configuration
self._services = self._app_host.services
def create_configuration(self):
self._configuration.add_environment_variables('PYTHON_')
self._configuration.add_environment_variables('CPL_')
self._configuration.add_argument_variables()
self._configuration.add_json_file(f'appsettings.json')
self._configuration.add_json_file(f'appsettings.{self._configuration.environment.environment_name}.json')
self._configuration.add_json_file(f'appsettings.{self._configuration.environment.host_name}.json', optional=True)
def create_services(self):
# Add and create logger
self._services.add_singleton(LoggerBase, Logger)
self._logger = self._services.get_service(LoggerBase)
# Add and create publisher
self._services.add_singleton(PublisherBase, Publisher)
self._publisher: Publisher = self._services.get_service(PublisherBase)
def main(self):
self._logger.header(f'{self._configuration.environment.application_name}:')
self._logger.debug(__name__, f'Host: {self._configuration.environment.host_name}')
self._logger.debug(__name__, f'Environment: {self._configuration.environment.environment_name}')
self._logger.debug(__name__, f'Customer: {self._configuration.environment.customer}')
self._publisher.exclude('../tests')
self._publisher.exclude('../tests_dev')
self._publisher.create()
self._publisher.publish()
if __name__ == '__main__':
program = Program()
program.create_application_host()
program.create_configuration()
program.create_services()
program.main()