2021.4 #19

Merged
edraft merged 237 commits from 2021.4 into master 2021-04-01 10:13:33 +02:00
108 changed files with 11 additions and 4105 deletions
Showing only changes of commit ed0b761502 - Show all commits

2
.gitignore vendored
View File

@ -130,5 +130,3 @@ dmypy.json
# IDE
.vscode/
/src_old/

View File

@ -22,211 +22,9 @@
<select />
</component>
<component name="ChangeListManager">
<list default="true" id="7e2256bc-a6b8-4880-83a6-8b0e3372d0a4" name="Default Changelist" comment="Updated requirements">
<change afterPath="$PROJECT_DIR$/src/cpl/application/application_abc.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/cpl/application/application_host_abc.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/cpl/application/application_runtime_abc.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/cpl/application/startup_abc.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/cpl/configuration/configuration.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/cpl/configuration/configuration_abc.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/cpl/configuration/configuration_model_abc.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/cpl/console/console.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/cpl/environment/environment_abc.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/cpl/environment/hosting_environment.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/cpl/logging/logger.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/cpl/logging/logger_abc.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/cpl/logging/logging_settings.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/cpl/mailing/email_client_abc.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/cpl/mailing/email_client_settings.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/cpl/time/time_format_settings.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/cpl_cli/__init__.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/tests/Application.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/tests/Startup.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/tests/cpl.json" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/tests/main.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src_old/sh_edraft/configuration/__init__.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src_old/sh_edraft/configuration/model/configuration_variable_name.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src_old/sh_edraft/console/__init__.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src_old/sh_edraft/console/model/background_color.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src_old/sh_edraft/console/model/foreground_color.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src_old/sh_edraft/database/__init__.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src_old/sh_edraft/database/connection/__init__.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src_old/sh_edraft/database/connection/base/database_connection_base.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src_old/sh_edraft/database/connection/database_connection.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src_old/sh_edraft/database/context/__init__.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src_old/sh_edraft/database/context/base/database_context_base.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src_old/sh_edraft/database/context/database_context.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src_old/sh_edraft/database/model/database_settings.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src_old/sh_edraft/database/model/database_settings_name.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src_old/sh_edraft/database/model/dbmodel.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src_old/sh_edraft/environment/__init__.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src_old/sh_edraft/environment/model/environment_name.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src_old/sh_edraft/hosting/application_host.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src_old/sh_edraft/hosting/application_runtime.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src_old/sh_edraft/logging/__init__.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src_old/sh_edraft/logging/model/logging_level.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src_old/sh_edraft/logging/model/logging_settings_name.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src_old/sh_edraft/mailing/email_client.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src_old/sh_edraft/mailing/model/email.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src_old/sh_edraft/mailing/model/email_client_settings_name.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src_old/sh_edraft/service/providing/base/service_provider_base.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src_old/sh_edraft/service/providing/model/provide_state.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src_old/sh_edraft/service/providing/service_provider.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src_old/sh_edraft/time/model/time_format_settings_names.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src_old/sh_edraft/utils/__init__.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src_old/sh_edraft/utils/credential_manager.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src_old/tests/appsettings.edrafts-lapi.json" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src_old/tests/appsettings.edrafts-pc.json" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src_old/tests/publish_test/__init__.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src_old/tests/service_test/__init__.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src_old/tests/time_test/__init__.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src_old/tests/utils_test/__init__.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src_old/tests_dev/app.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src_old/tests_dev/appsettings.development.json" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src_old/tests_dev/appsettings.json" afterDir="false" />
<list default="true" id="7e2256bc-a6b8-4880-83a6-8b0e3372d0a4" name="Default Changelist" comment="Refactored code">
<change beforePath="$PROJECT_DIR$/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/sh_common_py_lib.iml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/sh_common_py_lib.iml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/MANIFEST.in" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/MANIFEST.in" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/build.json" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/setup.py" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/setup.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/sh_edraft/__init__.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/cli/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/sh_edraft/mailing/__init__.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/cli/command/__init__.py" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/cli/command/base/__init__.py" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/cli/command/base/command_base.py" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/cli/cpl_cli/__init__.py" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/cli/cpl_cli/cli.py" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/cli/cpl_cli/commands/__init__.py" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/cli/cpl_cli/commands/build/__init__.py" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/cli/cpl_cli/commands/build/app.py" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/cli/cpl_cli/commands/build/build.py" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/cli/cpl_cli/commands/help.py" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/cli/cpl_cli/commands/new.py" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/cli/cpl_cli/commands/publish/__init__.py" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/cli/cpl_cli/commands/publish/app.py" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/cli/cpl_cli/commands/publish/publish.py" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/cli/cpl_cli/commands/version.py" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/cli/cpl_cli/templates/app/__init__.txt" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/cli/cpl_cli/templates/app/build.json" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/cli/cpl_cli/templates/app/main.txt" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/cli/cpl_cli/templates/app/program.txt" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/cli/cpl_cli/templates/base/base.txt" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/sh_edraft/service/base/service_base.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/cli/cpl_cli/templates/class/class.txt" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/cli/cpl_cli/templates/configmodel/model.txt" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/cli/cpl_cli/templates/enum/enum.txt" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/cli/cpl_cli/templates/service/service.txt" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/cli/interpreter/__init__.py" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/cli/interpreter/interpreter.py" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/coding/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/sh_edraft/coding/__init__.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/coding/model/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/sh_edraft/coding/model/__init__.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/coding/model/version.py" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/sh_edraft/coding/model/version.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/coding/model/version_enum.py" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/sh_edraft/coding/model/version_enum.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/configuration/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/cpl/configuration/__init__.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/configuration/base/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/sh_edraft/configuration/base/__init__.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/configuration/base/configuration_base.py" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/sh_edraft/configuration/base/configuration_base.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/configuration/base/configuration_model_base.py" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/sh_edraft/configuration/base/configuration_model_base.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/configuration/configuration.py" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/sh_edraft/configuration/configuration.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/configuration/model/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/sh_edraft/configuration/model/__init__.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/configuration/model/configuration_variable_name.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/cpl/configuration/configuration_variable_name.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/console/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/cpl/console/__init__.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/console/console.py" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/sh_edraft/console/console.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/console/model/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/sh_edraft/console/model/__init__.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/console/model/background_color.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/cpl/console/background_color.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/console/model/foreground_color.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/cpl/console/foreground_color.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/database/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/cpl/database/__init__.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/database/connection/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/cpl/database/connection/__init__.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/database/connection/base/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/sh_edraft/database/connection/base/__init__.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/database/connection/base/database_connection_base.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/cpl/database/connection/database_connection_abc.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/database/connection/database_connection.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/cpl/database/connection/database_connection.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/database/context/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/cpl/database/context/__init__.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/database/context/base/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/sh_edraft/database/context/base/__init__.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/database/context/base/database_context_base.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/cpl/database/context/database_context_abc.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/database/context/database_context.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/cpl/database/context/database_context.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/database/model/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/sh_edraft/database/model/__init__.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/database/model/database_settings.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/cpl/database/database_settings.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/database/model/database_settings_name.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/cpl/database/database_settings_name.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/database/model/dbmodel.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/cpl/database/database_model.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/environment/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/cpl/environment/__init__.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/environment/base/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/sh_edraft/environment/base/__init__.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/environment/base/environment_base.py" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/sh_edraft/environment/base/environment_base.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/environment/hosting_environment.py" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/sh_edraft/environment/hosting_environment.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/environment/model/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/sh_edraft/environment/model/__init__.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/environment/model/environment_name.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/cpl/environment/environment_name.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/hosting/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/sh_edraft/hosting/__init__.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/hosting/application_host.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/cpl/application/application_host.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/hosting/application_runtime.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/cpl/application/application_runtime.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/hosting/base/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/sh_edraft/hosting/base/__init__.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/hosting/base/application_base.py" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/sh_edraft/hosting/base/application_base.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/hosting/base/application_host_base.py" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/sh_edraft/hosting/base/application_host_base.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/hosting/base/application_runtime_base.py" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/sh_edraft/hosting/base/application_runtime_base.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/hosting/model/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/sh_edraft/hosting/model/__init__.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/logging/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/cpl/logging/__init__.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/logging/base/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/sh_edraft/logging/base/__init__.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/logging/base/logger_base.py" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/sh_edraft/logging/base/logger_base.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/logging/logger.py" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/sh_edraft/logging/logger.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/logging/model/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/sh_edraft/logging/model/__init__.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/logging/model/logging_level.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/cpl/logging/logging_level.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/logging/model/logging_settings.py" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/sh_edraft/logging/model/logging_settings.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/logging/model/logging_settings_name.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/cpl/logging/logging_settings_name.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/mailing/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/cpl/mailing/__init__.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/mailing/base/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/sh_edraft/mailing/base/__init__.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/mailing/base/email_client_base.py" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/sh_edraft/mailing/base/email_client_base.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/mailing/email_client.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/cpl/mailing/email_client.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/mailing/model/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/sh_edraft/mailing/model/__init__.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/mailing/model/email.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/cpl/mailing/email.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/mailing/model/email_client_settings.py" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/sh_edraft/mailing/model/email_client_settings.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/mailing/model/email_client_settings_name.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/cpl/mailing/email_client_settings_name.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/publish/base/publisher_base.py" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/sh_edraft/publish/base/publisher_base.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/publish/model/publish_settings_model.py" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/sh_edraft/publish/model/publish_settings_model.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/publish/model/publish_settings_name.py" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/sh_edraft/publish/model/publish_settings_name.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/publish/model/template.py" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/sh_edraft/publish/model/template.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/publish/model/template_enum.py" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/sh_edraft/publish/model/template_enum.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/publish/publisher.py" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/sh_edraft/publish/publisher.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/publishing/__init__.py" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/publishing/base/__init__.py" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/publishing/model/__init__.py" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/service/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/sh_edraft/service/__init__.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/service/base/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/sh_edraft/service/base/__init__.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/service/base/service_base.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/cpl/dependency_injection/service_abc.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/service/providing/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/sh_edraft/service/providing/__init__.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/service/providing/base/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/sh_edraft/service/providing/base/__init__.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/service/providing/base/service_provider_base.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/cpl/dependency_injection/service_provider_base.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/service/providing/model/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/sh_edraft/service/providing/model/__init__.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/service/providing/model/provide_state.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/cpl/dependency_injection/provide_state.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/service/providing/service_provider.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/cpl/dependency_injection/service_provider.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/time/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/sh_edraft/time/__init__.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/time/model/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/sh_edraft/time/model/__init__.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/time/model/time_format_settings.py" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/sh_edraft/time/model/time_format_settings.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/time/model/time_format_settings_names.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/cpl/time/time_format_settings_names.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/utils/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/cpl/utils/__init__.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sh_edraft/utils/credential_manager.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/cpl/utils/credential_manager.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/tests/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/tests/__init__.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/tests/appsettings.edrafts-lapi.json" beforeDir="false" afterPath="$PROJECT_DIR$/src/tests/appsettings.edrafts-lapi.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/tests/appsettings.edrafts-pc.json" beforeDir="false" afterPath="$PROJECT_DIR$/src/tests/appsettings.edrafts-pc.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/tests/appsettings.testing.json" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/tests/appsettings.testing.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/tests/build.json" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/tests/build.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/tests/publish_test/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/cpl/__init__.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/tests/publish_test/publisher_test.py" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/tests/publish_test/publisher_test.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/tests/service_test/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/cpl/application/__init__.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/tests/service_test/provider_test.py" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/tests/service_test/provider_test.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/tests/setup.py" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/tests/setup.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/tests/time_test/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/cpl/dependency_injection/__init__.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/tests/time_test/time_format_settings_test.py" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/tests/time_test/time_format_settings_test.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/tests/utils_test/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/cpl/time/__init__.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/tests/utils_test/credential_manager_test.py" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/tests/utils_test/credential_manager_test.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/tests_dev/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/tests_dev/__init__.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/tests_dev/appsettings.development.json" beforeDir="false" afterPath="$PROJECT_DIR$/src/tests/appsettings.development.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/tests_dev/appsettings.edrafts-lapi.json" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/tests_dev/appsettings.edrafts-lapi.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/tests_dev/appsettings.edrafts-pc.json" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/tests_dev/appsettings.edrafts-pc.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/tests_dev/appsettings.json" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/tests/appsettings.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/tests_dev/db/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/tests/__init__.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/tests_dev/db/city.py" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/tests_dev/db/user.py" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/tests_dev/db/user_repo.py" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/tests_dev/db/user_repo_base.py" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/tests_dev/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/tests_dev/main.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/tests_dev/program.py" beforeDir="false" afterPath="$PROJECT_DIR$/src_old/tests_dev/program.py" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -664,13 +462,6 @@
<option name="presentableId" value="Default" />
<updated>1605881914521</updated>
</task>
<task id="LOCAL-00032" summary="Improved database module structure">
<created>1607620265254</created>
<option name="number" value="00032" />
<option name="presentableId" value="LOCAL-00032" />
<option name="project" value="LOCAL" />
<updated>1607620265254</updated>
</task>
<task id="LOCAL-00033" summary="Changed DatabaseConnection">
<created>1607712129507</created>
<option name="number" value="00033" />
@ -1007,7 +798,14 @@
<option name="project" value="LOCAL" />
<updated>1614372713621</updated>
</task>
<option name="localTasksCounter" value="81" />
<task id="LOCAL-00081" summary="Refactored code">
<created>1614764872108</created>
<option name="number" value="00081" />
<option name="presentableId" value="LOCAL-00081" />
<option name="project" value="LOCAL" />
<updated>1614764872108</updated>
</task>
<option name="localTasksCounter" value="82" />
<servers />
</component>
<component name="Vcs.Log.Tabs.Properties">
@ -1023,7 +821,6 @@
<option name="oldMeFiltersMigrated" value="true" />
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="Improved publish process" />
<MESSAGE value="Added publish command to cli" />
<MESSAGE value="Added imports to cli module" />
<MESSAGE value="Improved help command" />
@ -1048,7 +845,8 @@
<MESSAGE value="Bugfixes and improved tests" />
<MESSAGE value="Removed unused packages" />
<MESSAGE value="Removed publish package" />
<option name="LAST_COMMIT_MESSAGE" value="Removed publish package" />
<MESSAGE value="Refactored code" />
<option name="LAST_COMMIT_MESSAGE" value="Refactored code" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>

View File

@ -1,2 +0,0 @@
include ../ README
recursive-include sh_edraft *.txt

View File

@ -1,29 +0,0 @@
import setuptools
setuptools.setup(
name='sh_edraft',
version='2020.0.1',
packages=setuptools.find_packages(exclude=["tests*"]),
url='https://www.sh-edraft.de',
license='MIT',
author='Sven Heidemann',
author_email='edraft.sh@gmail.com',
include_package_data=True,
description='sh-edraft python common lib',
python_requires='>=3.8',
install_requires=[
'discord.py',
'flask',
'mysql-connector',
'SQLAlchemy',
'termcolor',
'pyfiglet',
'tabulate',
'smtplib'
],
entry_points={
'console_scripts': [
'cpl = sh_edraft.cli.cpl_cli.cli:main'
]
}
)

View File

@ -1,25 +0,0 @@
# -*- coding: utf-8 -*-
"""
sh_edraft common python library
~~~~~~~~~~~~~~~~~~~
Library to share common classes and models used at sh-edraft.de
:copyright: (c) 2020 sh-edraft.de
:license: MIT, see LICENSE for more details.
"""
__title__ = 'sh_edraft'
__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,25 +0,0 @@
# -*- coding: utf-8 -*-
"""
sh_edraft.coding
~~~~~~~~~~~~~~~~~~~
:copyright: (c) 2020 sh-edraft.de
:license: MIT, see LICENSE for more details.
"""
__title__ = 'sh_edraft.coding'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 sh-edraft.de'
__version__ = '2020.12.9'
from collections import namedtuple
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

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

View File

@ -1,46 +0,0 @@
from typing import Optional
from sh_edraft.coding.model.version_enum import VersionEnum
from sh_edraft.configuration.base.configuration_model_base import ConfigurationModelBase
class Version(ConfigurationModelBase):
def __init__(
self,
major: int = None,
minor: int = None,
micro: float = None
):
ConfigurationModelBase.__init__(self)
self._major: Optional[int] = major
self._minor: Optional[int] = minor
self._micro: Optional[int] = micro
@property
def major(self) -> int:
return self._major
@property
def minor(self) -> int:
return self._minor
@property
def micro(self) -> float:
return self._micro
def to_str(self) -> str:
return f'{self._major}.{self._minor}.{self._micro}'
def from_dict(self, settings: dict):
self._major = int(settings[VersionEnum.Major.value])
self._minor = int(settings[VersionEnum.Minor.value])
self._micro = int(settings[VersionEnum.Micro.value])
def to_dict(self) -> dict:
return {
VersionEnum.Major.value: self._major,
VersionEnum.Minor.value: self._minor,
VersionEnum.Micro.value: self._micro
}

View File

@ -1,8 +0,0 @@
from enum import Enum
class VersionEnum(Enum):
Major = 'Major'
Minor = 'Minor'
Micro = 'Micro'

View File

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

View File

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

View File

@ -1,34 +0,0 @@
from abc import abstractmethod, ABC
from collections import Callable
from typing import Type
from sh_edraft.configuration.base.configuration_model_base import ConfigurationModelBase
from sh_edraft.environment.base.environment_base import EnvironmentBase
class ConfigurationBase(ABC):
@abstractmethod
def __init__(self): pass
@property
@abstractmethod
def environment(self) -> EnvironmentBase: pass
@abstractmethod
def add_environment_variables(self, prefix: str): pass
@abstractmethod
def add_argument_variables(self): pass
@abstractmethod
def add_json_file(self, name: str, optional: bool = None): pass
@abstractmethod
def add_configuration(self, key_type: type, value: object): pass
@abstractmethod
def get_configuration(self, search_type: Type[ConfigurationModelBase]) -> Callable[ConfigurationModelBase]: pass
@abstractmethod
def create(self): pass

View File

@ -1,10 +0,0 @@
from abc import ABC, abstractmethod
class ConfigurationModelBase(ABC):
@abstractmethod
def __init__(self): pass
@abstractmethod
def from_dict(self, settings: dict): pass

View File

@ -1,121 +0,0 @@
import json
import os
import sys
from sh_edraft.configuration.base.configuration_model_base import ConfigurationModelBase
from sh_edraft.configuration.base.configuration_base import ConfigurationBase
from sh_edraft.configuration.model.configuration_variable_name import ConfigurationVariableName
from sh_edraft.environment.base.environment_base import EnvironmentBase
from sh_edraft.environment.hosting_environment import HostingEnvironment
from sh_edraft.environment.model.environment_name import EnvironmentName
from sh_edraft.console.console import Console
from sh_edraft.console.model import ForegroundColor
class Configuration(ConfigurationBase):
def __init__(self):
ConfigurationBase.__init__(self)
self._hosting_environment = HostingEnvironment()
self._config: dict[type, ConfigurationModelBase] = {}
@property
def environment(self) -> EnvironmentBase:
return self._hosting_environment
@staticmethod
def _print_info(name: str, message: str):
Console.set_foreground_color(ForegroundColor.green)
Console.write_line(f'[{name}] {message}')
Console.set_foreground_color(ForegroundColor.default)
@staticmethod
def _print_warn(name: str, message: str):
Console.set_foreground_color(ForegroundColor.yellow)
Console.write_line(f'[{name}] {message}')
Console.set_foreground_color(ForegroundColor.default)
@staticmethod
def _print_error(name: str, message: str):
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):
if name == ConfigurationVariableName.environment.value:
self._hosting_environment.environment_name = EnvironmentName(value)
elif name == ConfigurationVariableName.name.value:
self._hosting_environment.application_name = value
elif name == ConfigurationVariableName.customer.value:
self._hosting_environment.customer = value
def add_environment_variables(self, prefix: str):
for variable in ConfigurationVariableName.to_list():
var_name = f'{prefix}{variable}'
if var_name in [key.upper() for key in os.environ.keys()]:
self._set_variable(variable, os.environ[var_name])
def add_argument_variables(self):
for arg in sys.argv[1:]:
try:
argument = arg.split('--')[1].split('=')[0].upper()
value = arg.split('=')[1]
if argument not in ConfigurationVariableName.to_list():
raise Exception(f'Invalid argument name: {argument}')
self._set_variable(argument, value)
except Exception as e:
self._print_error(__name__, f'Invalid argument: {arg} -> {e}')
exit()
def add_json_file(self, name: str, optional: bool = None):
if self._hosting_environment.content_root_path.endswith('/') and not name.startswith('/'):
file_path = f'{self._hosting_environment.content_root_path}{name}'
else:
file_path = f'{self._hosting_environment.content_root_path}/{name}'
if not os.path.isfile(file_path):
if not optional:
self._print_error(__name__, f'File not found: {file_path}')
exit()
self._print_warn(__name__, f'Not Loaded config file: {file_path}')
return None
config_from_file = self._load_json_file(file_path)
for sub in ConfigurationModelBase.__subclasses__():
for key, value in config_from_file.items():
if sub.__name__ == key:
configuration = sub()
configuration.from_dict(value)
self.add_configuration(sub, configuration)
def _load_json_file(self, file: str) -> dict:
try:
# open config file, create if not exists
with open(file, encoding='utf-8') as cfg:
# load json
json_cfg = json.load(cfg)
self._print_info(__name__, f'Loaded config file: {file}')
return json_cfg
except Exception as e:
self._print_error(__name__, f'Cannot load config file: {file}! -> {e}')
return {}
def add_configuration(self, key_type: type, value: ConfigurationModelBase):
self._config[key_type] = value
def get_configuration(self, search_type: type) -> ConfigurationModelBase:
if search_type not in self._config:
raise Exception(f'Config model by type {search_type} not found')
for config_model in self._config:
if config_model == search_type:
return self._config[config_model]
def create(self):
pass

View File

@ -1,26 +0,0 @@
# -*- 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
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

@ -1,12 +0,0 @@
from enum import Enum
class ConfigurationVariableName(Enum):
environment = 'ENVIRONMENT'
name = 'NAME'
customer = 'CUSTOMER'
@staticmethod
def to_list():
return [var.value for var in ConfigurationVariableName]

View File

@ -1,26 +0,0 @@
# -*- 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

@ -1,205 +0,0 @@
import os
from typing import Union, Optional
import pyfiglet
from tabulate import tabulate
from termcolor import colored
from sh_edraft.console.model.background_color import BackgroundColor
from sh_edraft.console.model.foreground_color import ForegroundColor
class Console:
_is_first_write = True
_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._is_first_write:
cls._is_first_write = False
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
"""
@classmethod
def banner(cls, string: str):
if cls._disabled:
return
ascii_banner = pyfiglet.figlet_format(string)
cls.write_line(ascii_banner)
@classmethod
def clear(cls):
os.system('cls' if os.name == 'nt' else 'clear')
@classmethod
def close(cls):
if cls._disabled:
return
Console.reset()
Console.write('\n\n\nPress any key to continue...')
Console.read_line()
exit()
@classmethod
def disable(cls):
cls._disabled = True
@classmethod
def error(cls, string: str, tb: str = None):
if cls._disabled:
return
cls.set_foreground_color('red')
if tb is not None:
cls.write_line(f'{string} -> {tb}')
else:
cls.write_line(string)
cls.set_foreground_color('default')
@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 cls._disabled:
return ''
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 table(cls, header: list[str], values: list[list[str]]):
if cls._disabled:
return
table = tabulate(values, headers=header)
Console.write_line(table)
Console.write('\n')
@classmethod
def write(cls, *args):
if cls._disabled:
return
string = ' '.join(map(str, args))
cls._output(string, end='')
@classmethod
def write_at(cls, x: int, y: int, *args):
if cls._disabled:
return
string = ' '.join(map(str, args))
cls._output(string, x, y, end='')
@classmethod
def write_line(cls, *args):
if cls._disabled:
return
string = ' '.join(map(str, args))
if not cls._is_first_write:
cls._output('')
cls._output(string, end='')
@classmethod
def write_line_at(cls, x: int, y: int, *args):
if cls._disabled:
return
string = ' '.join(map(str, args))
if not cls._is_first_write:
cls._output('', end='')
cls._output(string, x, y, end='')

View File

@ -1,27 +0,0 @@
# -*- 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

@ -1,14 +0,0 @@
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

@ -1,14 +0,0 @@
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,25 +0,0 @@
# -*- 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:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

@ -1,26 +0,0 @@
# -*- 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
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

@ -1,26 +0,0 @@
# -*- 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
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

@ -1,21 +0,0 @@
from abc import abstractmethod, ABC
from sqlalchemy import engine
from sqlalchemy.orm import Session
class DatabaseConnectionBase(ABC):
@abstractmethod
def __init__(self): pass
@property
@abstractmethod
def engine(self) -> engine: pass
@property
@abstractmethod
def session(self) -> Session: pass
@abstractmethod
def connect(self, connection_string: str): pass

View File

@ -1,56 +0,0 @@
from typing import Optional
from sqlalchemy import engine, create_engine
from sqlalchemy.orm import Session, sessionmaker
from sh_edraft.database.connection.base.database_connection_base import DatabaseConnectionBase
from sh_edraft.database.model.database_settings import DatabaseSettings
from sh_edraft.console.console import Console
from sh_edraft.console.model.foreground_color import ForegroundColor
class DatabaseConnection(DatabaseConnectionBase):
def __init__(self, database_settings: DatabaseSettings):
DatabaseConnectionBase.__init__(self)
self._db_settings = database_settings
self._engine: Optional[engine] = None
self._session: Optional[Session] = None
self._credentials: Optional[str] = None
@property
def engine(self) -> engine:
return self._engine
@property
def session(self) -> Session:
return self._session
def connect(self, connection_string: str):
try:
self._engine = create_engine(connection_string)
if self._db_settings.encoding is not None:
self._engine.encoding = self._db_settings.encoding
if self._db_settings.case_sensitive is not None:
self._engine.case_sensitive = self._db_settings.case_sensitive
if self._db_settings.echo is not None:
self._engine.echo = self._db_settings.echo
self._engine.connect()
db_session = sessionmaker(bind=self._engine)
self._session = db_session()
Console.set_foreground_color(ForegroundColor.green)
Console.write_line(f'[{__name__}] Connected to database')
Console.set_foreground_color(ForegroundColor.default)
except Exception as e:
Console.set_foreground_color(ForegroundColor.red)
Console.write_line(f'[{__name__}] Database connection failed -> {e}')
Console.set_foreground_color(ForegroundColor.default)
exit()

View File

@ -1,26 +0,0 @@
# -*- 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
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

@ -1,26 +0,0 @@
# -*- 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
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

@ -1,27 +0,0 @@
from abc import abstractmethod
from sqlalchemy import engine
from sqlalchemy.orm import Session
from sh_edraft.service.base.service_base import ServiceBase
class DatabaseContextBase(ServiceBase):
@abstractmethod
def __init__(self):
ServiceBase.__init__(self)
@property
@abstractmethod
def engine(self) -> engine: pass
@property
@abstractmethod
def session(self) -> Session: pass
@abstractmethod
def connect(self, connection_string: str): pass
@abstractmethod
def _create_tables(self): pass

View File

@ -1,50 +0,0 @@
from sqlalchemy import engine, Table
from sqlalchemy.orm import Session
from sh_edraft.database.connection.database_connection import DatabaseConnection
from sh_edraft.database.connection.base.database_connection_base import DatabaseConnectionBase
from sh_edraft.database.context.base.database_context_base import DatabaseContextBase
from sh_edraft.database.model.dbmodel import DBModel
from sh_edraft.database.model.database_settings import DatabaseSettings
from sh_edraft.console.console import Console
from sh_edraft.console.model.foreground_color import ForegroundColor
class DatabaseContext(DatabaseContextBase):
def __init__(self, database_settings: DatabaseSettings):
DatabaseContextBase.__init__(self)
self._db: DatabaseConnectionBase = DatabaseConnection(database_settings)
self._tables: list[Table] = []
@property
def engine(self) -> engine:
return self._db.engine
@property
def session(self) -> Session:
return self._db.session
def create(self):
pass
def connect(self, connection_string: str):
self._db.connect(connection_string)
self._create_tables()
def _create_tables(self):
try:
for subclass in DBModel.__subclasses__():
self._tables.append(subclass.__table__)
DBModel.metadata.drop_all(self._db.engine, self._tables)
DBModel.metadata.create_all(self._db.engine, self._tables, checkfirst=True)
Console.set_foreground_color(ForegroundColor.green)
Console.write_line(f'[{__name__}] Created tables')
Console.set_foreground_color(ForegroundColor.default)
except Exception as e:
Console.set_foreground_color(ForegroundColor.red)
Console.write_line(f'[{__name__}] Creating tables failed -> {e}')
Console.set_foreground_color(ForegroundColor.default)
exit()

View File

@ -1,28 +0,0 @@
# -*- 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_name import DatabaseSettingsName
from .dbmodel import DBModel
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

@ -1,78 +0,0 @@
import traceback
from typing import Optional
from sh_edraft.configuration.base.configuration_model_base import ConfigurationModelBase
from sh_edraft.database.model.database_settings_name import DatabaseSettingsName
from sh_edraft.console.console import Console
from sh_edraft.console.model.foreground_color import ForegroundColor
class DatabaseSettings(ConfigurationModelBase):
def __init__(self):
ConfigurationModelBase.__init__(self)
self._connection_string: Optional[str] = None
self._credentials: Optional[str] = None
self._encoding: Optional[str] = None
self._case_sensitive: Optional[bool] = None
self._echo: Optional[bool] = None
@property
def connection_string(self) -> str:
return self._connection_string
@connection_string.setter
def connection_string(self, connection_string: str):
self._connection_string = connection_string
@property
def credentials(self) -> str:
return self._credentials
@credentials.setter
def credentials(self, credentials: str):
self._credentials = credentials
@property
def encoding(self) -> str:
return self._encoding
@encoding.setter
def encoding(self, encoding: str) -> None:
self._encoding = encoding
@property
def case_sensitive(self) -> bool:
return self._case_sensitive
@case_sensitive.setter
def case_sensitive(self, case_sensitive: bool) -> None:
self._case_sensitive = case_sensitive
@property
def echo(self) -> bool:
return self._echo
@echo.setter
def echo(self, echo: bool) -> None:
self._echo = echo
def from_dict(self, settings: dict):
try:
self._connection_string = settings[DatabaseSettingsName.connection_string.value]
self._credentials = settings[DatabaseSettingsName.credentials.value]
if DatabaseSettingsName.encoding.value in settings:
self._encoding = settings[DatabaseSettingsName.encoding.value]
if DatabaseSettingsName.case_sensitive.value in settings:
self._case_sensitive = bool(settings[DatabaseSettingsName.case_sensitive.value])
if DatabaseSettingsName.echo.value in settings:
self._echo = bool(settings[DatabaseSettingsName.echo.value])
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'[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}')
Console.set_foreground_color(ForegroundColor.default)

View File

@ -1,10 +0,0 @@
from enum import Enum
class DatabaseSettingsName(Enum):
connection_string = 'ConnectionString'
credentials = 'Credentials'
encoding = 'Encoding'
case_sensitive = 'CaseSensitive'
echo = 'Echo'

View File

@ -1,3 +0,0 @@
from sqlalchemy.ext.declarative import declarative_base
DBModel: declarative_base = declarative_base()

View File

@ -1,26 +0,0 @@
# -*- 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
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

@ -1,26 +0,0 @@
# -*- 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
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

@ -1,43 +0,0 @@
from abc import ABC, abstractmethod
class EnvironmentBase(ABC):
@abstractmethod
def __init__(self): pass
@property
@abstractmethod
def environment_name(self) -> str: pass
@environment_name.setter
@abstractmethod
def environment_name(self, environment_name: str): pass
@property
@abstractmethod
def application_name(self) -> str: pass
@application_name.setter
@abstractmethod
def application_name(self, application_name: str): pass
@property
@abstractmethod
def customer(self) -> str: pass
@customer.setter
@abstractmethod
def customer(self, customer: str): pass
@property
@abstractmethod
def content_root_path(self) -> str: pass
@content_root_path.setter
@abstractmethod
def content_root_path(self, content_root_path: str): pass
@property
@abstractmethod
def host_name(self) -> str: pass

View File

@ -1,52 +0,0 @@
from socket import gethostname
from typing import Optional
from sh_edraft.environment.base.environment_base import EnvironmentBase
from sh_edraft.environment.model.environment_name import EnvironmentName
class HostingEnvironment(EnvironmentBase):
def __init__(self, name: EnvironmentName = EnvironmentName.production, crp: str = './'):
EnvironmentBase.__init__(self)
self._environment_name: Optional[EnvironmentName] = name
self._app_name: Optional[str] = None
self._customer: Optional[str] = None
self._content_root_path: Optional[str] = crp
@property
def environment_name(self) -> str:
return str(self._environment_name.value)
@environment_name.setter
def environment_name(self, environment_name: str):
self._environment_name = EnvironmentName(environment_name)
@property
def application_name(self) -> str:
return self._app_name if self._app_name is not None else ''
@application_name.setter
def application_name(self, application_name: str):
self._app_name = application_name
@property
def customer(self) -> str:
return self._customer if self._customer is not None else ''
@customer.setter
def customer(self, customer: str):
self._customer = customer
@property
def content_root_path(self) -> str:
return self._content_root_path
@content_root_path.setter
def content_root_path(self, content_root_path: str):
self._content_root_path = content_root_path
@property
def host_name(self):
return gethostname()

View File

@ -1,26 +0,0 @@
# -*- 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
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

@ -1,9 +0,0 @@
from enum import Enum
class EnvironmentName(Enum):
production = 'production'
staging = 'staging'
testing = 'testing'
development = 'development'

View File

@ -1,27 +0,0 @@
# -*- 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_runtime import ApplicationRuntime
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

@ -1,46 +0,0 @@
import atexit
from datetime import datetime
from sh_edraft.configuration.configuration import Configuration
from sh_edraft.configuration.base.configuration_base import ConfigurationBase
from sh_edraft.hosting.base.application_runtime_base import ApplicationRuntimeBase
from sh_edraft.hosting.application_runtime import ApplicationRuntime
from sh_edraft.hosting.base.application_host_base import ApplicationHostBase
from sh_edraft.service.providing.service_provider import ServiceProvider
from sh_edraft.service.providing.base.service_provider_base import ServiceProviderBase
from sh_edraft.console.console import Console
class ApplicationHost(ApplicationHostBase):
def __init__(self):
ApplicationHostBase.__init__(self)
# Init
self._config = Configuration()
self._app_runtime = ApplicationRuntime(self._config)
self._services = ServiceProvider(self._app_runtime)
# Create
self._config.create()
self._services.create()
# Set vars
self._start_time: datetime = datetime.now()
self._end_time: datetime = datetime.now()
atexit.register(Console.close)
@property
def configuration(self) -> ConfigurationBase:
return self._config
@property
def application_runtime(self) -> ApplicationRuntimeBase:
return self._app_runtime
@property
def services(self) -> ServiceProviderBase:
return self._services
def create(self): pass

View File

@ -1,38 +0,0 @@
from datetime import datetime
from sh_edraft.configuration.base.configuration_base import ConfigurationBase
from sh_edraft.hosting.base.application_runtime_base import ApplicationRuntimeBase
class ApplicationRuntime(ApplicationRuntimeBase):
def __init__(self, config: ConfigurationBase):
ApplicationRuntimeBase.__init__(self)
self._app_configuration = config
self._start_time: datetime = datetime.now()
self._end_time: datetime = datetime.now()
@property
def configuration(self) -> ConfigurationBase:
return self._app_configuration
@property
def start_time(self) -> datetime:
return self._start_time
@start_time.setter
def start_time(self, start_time: datetime):
self._start_time = start_time
@property
def end_time(self) -> datetime:
return self._end_time
@end_time.setter
def end_time(self, end_time: datetime):
self._end_time = end_time
@property
def date_time_now(self) -> datetime:
return datetime.now()

View File

@ -1,28 +0,0 @@
# -*- 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:
from .application_base import ApplicationBase
from .application_host_base import ApplicationHostBase
from .application_runtime_base import ApplicationRuntimeBase
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

@ -1,19 +0,0 @@
from abc import ABC, abstractmethod
class ApplicationBase(ABC):
@abstractmethod
def __init__(self): pass
@abstractmethod
def create_application_host(self): pass
@abstractmethod
def create_configuration(self): pass
@abstractmethod
def create_services(self): pass
@abstractmethod
def main(self): pass

View File

@ -1,26 +0,0 @@
from abc import ABC, abstractmethod
from sh_edraft.configuration.base.configuration_base import ConfigurationBase
from sh_edraft.hosting.base.application_runtime_base import ApplicationRuntimeBase
from sh_edraft.service.providing.base.service_provider_base import ServiceProviderBase
class ApplicationHostBase(ABC):
@abstractmethod
def __init__(self): pass
@property
@abstractmethod
def configuration(self) -> ConfigurationBase: pass
@property
@abstractmethod
def application_runtime(self) -> ApplicationRuntimeBase: pass
@property
@abstractmethod
def services(self) -> ServiceProviderBase: pass
@abstractmethod
def create(self): pass

View File

@ -1,34 +0,0 @@
from abc import ABC, abstractmethod
from datetime import datetime
from sh_edraft.configuration.base.configuration_base import ConfigurationBase
class ApplicationRuntimeBase(ABC):
@abstractmethod
def __init__(self): pass
@property
@abstractmethod
def configuration(self) -> ConfigurationBase: pass
@property
@abstractmethod
def start_time(self) -> datetime: pass
@start_time.setter
@abstractmethod
def start_time(self, start_time: datetime): pass
@property
@abstractmethod
def end_time(self): pass
@end_time.setter
@abstractmethod
def end_time(self, end_time: datetime): pass
@property
@abstractmethod
def date_time_now(self) -> datetime: pass

View File

@ -1,25 +0,0 @@
# -*- 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:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

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

View File

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

View File

@ -1,31 +0,0 @@
from abc import abstractmethod
from sh_edraft.service.base.service_base import ServiceBase
class LoggerBase(ServiceBase):
@abstractmethod
def __init__(self):
ServiceBase.__init__(self)
@abstractmethod
def header(self, string: str): pass
@abstractmethod
def trace(self, name: str, message: str): pass
@abstractmethod
def debug(self, name: str, message: str): pass
@abstractmethod
def info(self, name: str, message: str): pass
@abstractmethod
def warn(self, name: str, message: str): pass
@abstractmethod
def error(self, name: str, message: str, ex: Exception = None): pass
@abstractmethod
def fatal(self, name: str, message: str, ex: Exception = None): pass

View File

@ -1,195 +0,0 @@
import datetime
import os
import traceback
from string import Template
from sh_edraft.hosting.base.application_runtime_base import ApplicationRuntimeBase
from sh_edraft.logging.base.logger_base import LoggerBase
from sh_edraft.logging.model.logging_settings import LoggingSettings
from sh_edraft.logging.model.logging_level import LoggingLevel
from sh_edraft.time.model.time_format_settings import TimeFormatSettings
from sh_edraft.console.console import Console
from sh_edraft.console.model.foreground_color import ForegroundColor
class Logger(LoggerBase):
def __init__(self, logging_settings: LoggingSettings, time_format: TimeFormatSettings, app_runtime: ApplicationRuntimeBase):
LoggerBase.__init__(self)
self._app_runtime = app_runtime
self._log_settings: LoggingSettings = logging_settings
self._time_format_settings: TimeFormatSettings = time_format
self._log = Template(self._log_settings.filename).substitute(
date_time_now=self._app_runtime.date_time_now.strftime(self._time_format_settings.date_time_format),
start_time=self._app_runtime.start_time.strftime(self._time_format_settings.date_time_log_format)
)
self._path = self._log_settings.path
self._level = self._log_settings.level
self._console = self._log_settings.console
self.create()
def _get_datetime_now(self) -> str:
try:
return datetime.datetime.now().strftime(self._time_format_settings.date_time_format)
except Exception as e:
self.error(__name__, 'Cannot get time', ex=e)
def _get_date(self) -> str:
try:
return datetime.datetime.now().strftime(self._time_format_settings.date_format)
except Exception as e:
self.error(__name__, 'Cannot get date', ex=e)
def create(self) -> None:
""" path """
try:
# check if log file path exists
if not os.path.exists(self._path):
os.makedirs(self._path)
except Exception as e:
self._fatal_console(__name__, 'Cannot create log dir', ex=e)
""" create new log file """
try:
# open log file, create if not exists
path = f'{self._path}{self._log}'
f = open(path, "w+")
Console.write_line(f'[{__name__}]: Using log file: {path}')
f.close()
except Exception as e:
self._fatal_console(__name__, 'Cannot open log file', ex=e)
def _append_log(self, string):
try:
# open log file and append always
if not os.path.isdir(self._path):
self._fatal_console(__name__, 'Log directory not found')
with open(self._path + self._log, "a+", encoding="utf-8") as f:
f.write(string + '\n')
f.close()
except Exception as e:
self._fatal_console(__name__, f'Cannot append log file, message: {string}', ex=e)
def _get_string(self, name: str, level: LoggingLevel, message: str) -> str:
log_level = level.name
return f'<{self._get_datetime_now()}> [ {log_level} ] [ {name} ]: {message}'
def header(self, string: str):
# append log and print message
self._append_log(string)
Console.set_foreground_color(ForegroundColor.default)
Console.write_line(string)
Console.set_foreground_color(ForegroundColor.default)
def trace(self, name: str, message: str):
output = self._get_string(name, LoggingLevel.TRACE, message)
# check if message can be written to log
if self._level.value >= LoggingLevel.TRACE.value:
self._append_log(output)
# check if message can be shown in console
if self._console.value >= LoggingLevel.TRACE.value:
Console.set_foreground_color(ForegroundColor.green)
Console.write_line(output)
Console.set_foreground_color(ForegroundColor.default)
def debug(self, name: str, message: str):
output = self._get_string(name, LoggingLevel.DEBUG, message)
# check if message can be written to log
if self._level.value >= LoggingLevel.DEBUG.value:
self._append_log(output)
# check if message can be shown in console
if self._console.value >= LoggingLevel.DEBUG.value:
Console.set_foreground_color(ForegroundColor.green)
Console.write_line(output)
Console.set_foreground_color(ForegroundColor.default)
def info(self, name: str, message: str):
output = self._get_string(name, LoggingLevel.INFO, message)
# check if message can be written to log
if self._level.value >= LoggingLevel.INFO.value:
self._append_log(output)
# check if message can be shown in console
if self._console.value >= LoggingLevel.INFO.value:
Console.set_foreground_color(ForegroundColor.green)
Console.write_line(output)
Console.set_foreground_color(ForegroundColor.default)
def warn(self, name: str, message: str):
output = self._get_string(name, LoggingLevel.WARN, message)
# check if message can be written to log
if self._level.value >= LoggingLevel.WARN.value:
self._append_log(output)
# check if message can be shown in console
if self._console.value >= LoggingLevel.WARN.value:
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):
output = ''
if ex is not None:
tb = traceback.format_exc()
self.error(name, message)
output = self._get_string(name, LoggingLevel.ERROR, f'{ex} -> {tb}')
else:
output = self._get_string(name, LoggingLevel.ERROR, message)
# check if message can be written to log
if self._level.value >= LoggingLevel.ERROR.value:
self._append_log(output)
# check if message can be shown in console
if self._console.value >= LoggingLevel.ERROR.value:
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):
output = ''
if ex is not None:
tb = traceback.format_exc()
self.error(name, message)
output = self._get_string(name, LoggingLevel.FATAL, f'{ex} -> {tb}')
else:
output = self._get_string(name, LoggingLevel.FATAL, message)
# check if message can be written to log
if self._level.value >= LoggingLevel.FATAL.value:
self._append_log(output)
# check if message can be shown in console
if self._console.value >= LoggingLevel.FATAL.value:
Console.set_foreground_color(ForegroundColor.red)
Console.write_line(output)
Console.set_foreground_color(ForegroundColor.default)
exit()
def _fatal_console(self, name: str, message: str, ex: Exception = None):
output = ''
if ex is not None:
tb = traceback.format_exc()
self.error(name, message)
output = self._get_string(name, LoggingLevel.ERROR, f'{ex} -> {tb}')
else:
output = self._get_string(name, LoggingLevel.ERROR, message)
# check if message can be shown in console
if self._console.value >= LoggingLevel.FATAL.value:
Console.set_foreground_color(ForegroundColor.red)
Console.write_line(output)
Console.set_foreground_color(ForegroundColor.default)
exit()

View File

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

View File

@ -1,12 +0,0 @@
from enum import Enum
class LoggingLevel(Enum):
OFF = 0 # Nothing
FATAL = 1 # Error that cause exit
ERROR = 2 # Non fatal error
WARN = 3 # Error that can later be fatal
INFO = 4 # Normal information's
DEBUG = 5 # Detailed app state
TRACE = 6 # Detailed app information's

View File

@ -1,62 +0,0 @@
import traceback
from typing import Optional
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_level import LoggingLevel
from sh_edraft.console.console import Console
from sh_edraft.console.model.foreground_color import ForegroundColor
class LoggingSettings(ConfigurationModelBase):
def __init__(self):
ConfigurationModelBase.__init__(self)
self._path: Optional[str] = None
self._filename: Optional[str] = None
self._console: Optional[LoggingLevel] = None
self._level: Optional[LoggingLevel] = None
@property
def path(self) -> str:
return self._path
@path.setter
def path(self, path: str) -> None:
self._path = path
@property
def filename(self) -> str:
return self._filename
@filename.setter
def filename(self, filename: str) -> None:
self._filename = filename
@property
def console(self) -> LoggingLevel:
return self._console
@console.setter
def console(self, console: LoggingLevel) -> None:
self._console = console
@property
def level(self) -> LoggingLevel:
return self._level
@level.setter
def level(self, level: LoggingLevel) -> None:
self._level = level
def from_dict(self, settings: dict):
try:
self._path = settings[LoggingSettingsName.path.value]
self._filename = settings[LoggingSettingsName.filename.value]
self._console = LoggingLevel[settings[LoggingSettingsName.console_level.value]]
self._level = LoggingLevel[settings[LoggingSettingsName.file_level.value]]
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'[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}')
Console.set_foreground_color(ForegroundColor.default)

View File

@ -1,9 +0,0 @@
from enum import Enum
class LoggingSettingsName(Enum):
path = 'Path'
filename = 'Filename'
console_level = 'ConsoleLogLevel'
file_level = 'FileLogLevel'

View File

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

View File

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

View File

@ -1,17 +0,0 @@
from abc import abstractmethod
from sh_edraft.mailing.model.email import EMail
from sh_edraft.service.base.service_base import ServiceBase
class EMailClientBase(ServiceBase):
@abstractmethod
def __init__(self):
ServiceBase.__init__(self)
@abstractmethod
def connect(self): pass
@abstractmethod
def send_mail(self, email: EMail): pass

View File

@ -1,71 +0,0 @@
import ssl
from smtplib import SMTP
from typing import Optional
from sh_edraft.environment.base.environment_base import EnvironmentBase
from sh_edraft.logging.base.logger_base import LoggerBase
from sh_edraft.mailing.base.email_client_base import EMailClientBase
from sh_edraft.mailing.model.email import EMail
from sh_edraft.mailing.model.email_client_settings import EMailClientSettings
from sh_edraft.service.base.service_base import ServiceBase
from sh_edraft.utils.credential_manager import CredentialManager
class EMailClient(EMailClientBase):
def __init__(self, environment: EnvironmentBase, logger: LoggerBase, mail_settings: EMailClientSettings):
ServiceBase.__init__(self)
self._environment = environment
self._mail_settings = mail_settings
self._logger = logger
self._server: Optional[SMTP] = None
self.create()
def create(self):
self._logger.trace(__name__, f'Started {__name__}.create')
self.connect()
self._logger.trace(__name__, f'Stopped {__name__}.create')
def connect(self):
self._logger.trace(__name__, f'Started {__name__}.connect')
try:
self._logger.debug(__name__, f'Try to connect to {self._mail_settings.host}:{self._mail_settings.port}')
self._server = SMTP(self._mail_settings.host, self._mail_settings.port)
self._logger.info(__name__, f'Connected to {self._mail_settings.host}:{self._mail_settings.port}')
self._logger.debug(__name__, 'Try to start tls')
self._server.starttls(context=ssl.create_default_context())
self._logger.info(__name__, 'Started tls')
except Exception as e:
self._logger.error(__name__, 'Cannot connect to mail server', e)
self._logger.trace(__name__, f'Stopped {__name__}.connect')
def login(self):
self._logger.trace(__name__, f'Started {__name__}.login')
try:
self._logger.debug(__name__, f'Try to login {self._mail_settings.user_name}@{self._mail_settings.host}:{self._mail_settings.port}')
self._server.login(self._mail_settings.user_name, CredentialManager.decrypt(self._mail_settings.credentials))
self._logger.info(__name__, f'Logged on as {self._mail_settings.user_name} to {self._mail_settings.host}:{self._mail_settings.port}')
except Exception as e:
self._logger.error(__name__, 'Cannot login to mail server', e)
self._logger.trace(__name__, f'Stopped {__name__}.login')
def send_mail(self, email: EMail):
self._logger.trace(__name__, f'Started {__name__}.send_mail')
try:
self.login()
email.body += f'\n\nDies ist eine automatische E-Mail.' \
f'\nGesendet von {self._environment.application_name}-{self._environment.environment_name}@{self._environment.host_name} für ' \
f'{self._environment.customer}.'
self._logger.debug(__name__, f'Try to send email to {email.receiver_list}')
self._server.sendmail(self._mail_settings.user_name, email.receiver_list, email.get_content(self._mail_settings.user_name))
self._logger.info(__name__, f'Sent email to {email.receiver_list}')
except Exception as e:
self._logger.error(__name__, f'Cannot send mail to {email.receiver_list}', e)
self._logger.trace(__name__, f'Stopped {__name__}.send_mail')

View File

@ -1,28 +0,0 @@
# -*- coding: utf-8 -*-
"""
sh_edraft.mailing.model
~~~~~~~~~~~~~~~~~~~
:copyright: (c) 2020 sh-edraft.de
:license: MIT, see LICENSE for more details.
"""
__title__ = 'sh_edraft.mailing.model'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 sh-edraft.de'
__version__ = '2020.12.10'
from collections import namedtuple
# imports:
from .email import EMail
from .email_client_settings_name import EMailClientSettingsName
from .email_client_settings import EMailClientSettings
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=10)

View File

@ -1,86 +0,0 @@
import re
class EMail:
def __init__(self, header: list[str] = None, subject: str = None, body: str = None, transceiver: str = None, receiver: list[str] = None):
self._header: list[str] = header
self._subject: str = subject
self._body: str = body
self._transceiver: str = transceiver
self._receiver: list[str] = receiver
@property
def header(self) -> str:
return '\r\n'.join(self._header)
@property
def header_list(self) -> list[str]:
return self._header
@header.setter
def header(self, header: list[str]):
self._header = header
@property
def subject(self) -> str:
return self._subject
@subject.setter
def subject(self, subject: str):
self._subject = subject
@property
def body(self) -> str:
return self._body
@body.setter
def body(self, body: str):
self._body = body
@property
def transceiver(self) -> str:
return self._transceiver
@transceiver.setter
def transceiver(self, transceiver: str):
if self.check_mail(transceiver):
self._transceiver = transceiver
else:
raise Exception(f'Invalid email: {transceiver}')
@property
def receiver(self) -> str:
return ','.join(self._receiver)
@property
def receiver_list(self) -> list[str]:
return self._receiver
@receiver.setter
def receiver(self, receiver: list[str]):
self._receiver = receiver
@staticmethod
def check_mail(address: str) -> bool:
return bool(re.search('^\\w+([.-]?\\w+)*@\\w+([.-]?\\w+)*(.\\w{2,3})+$', address))
def add_header(self, header: str):
if self._header is None:
self._header = []
self._header.append(header)
def add_receiver(self, receiver: str):
if self._receiver is None:
self._receiver = []
if self.check_mail(receiver):
self._receiver.append(receiver)
else:
raise Exception(f'Invalid email: {receiver}')
def get_content(self, transceiver: str):
return str(f'From: {transceiver}\r\nTo: {self.receiver}\r\n{self.header}\r\nSubject: {self.subject}\r\n{self.body}').encode('utf-8')

View File

@ -1,59 +0,0 @@
import traceback
from sh_edraft.configuration.base.configuration_model_base import ConfigurationModelBase
from sh_edraft.console.console import Console
from sh_edraft.mailing.model.email_client_settings_name import EMailClientSettingsName
class EMailClientSettings(ConfigurationModelBase):
def __init__(self):
ConfigurationModelBase.__init__(self)
self._host: str = ''
self._port: int = 0
self._user_name: str = ''
self._credentials: str = ''
@property
def host(self) -> str:
return self._host
@host.setter
def host(self, host: str) -> None:
self._host = host
@property
def port(self) -> int:
return self._port
@port.setter
def port(self, port: int) -> None:
self._port = port
@property
def user_name(self) -> str:
return self._user_name
@user_name.setter
def user_name(self, user_name: str) -> None:
self._user_name = user_name
@property
def credentials(self) -> str:
return self._credentials
@credentials.setter
def credentials(self, credentials: str) -> None:
self._credentials = credentials
def from_dict(self, settings: dict):
try:
self._host = settings[EMailClientSettingsName.host.value]
self._port = settings[EMailClientSettingsName.port.value]
self._user_name = settings[EMailClientSettingsName.user_name.value]
self._credentials = settings[EMailClientSettingsName.credentials.value]
except Exception as e:
Console.error(f'[ ERROR ] [ {__name__} ]: Reading error in {self.__name__} settings')
Console.error(f'[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}')

View File

@ -1,9 +0,0 @@
from enum import Enum
class EMailClientSettingsName(Enum):
host = 'Host'
port = 'Port'
user_name = 'UserName'
credentials = 'Credentials'

View File

@ -1,30 +0,0 @@
from abc import abstractmethod
from sh_edraft.service.base.service_base import ServiceBase
class PublisherBase(ServiceBase):
@abstractmethod
def __init__(self):
ServiceBase.__init__(self)
@property
@abstractmethod
def source_path(self) -> str: pass
@property
@abstractmethod
def dist_path(self) -> str: pass
@abstractmethod
def include(self, path: str): pass
@abstractmethod
def exclude(self, path: str): pass
@abstractmethod
def build(self): pass
@abstractmethod
def publish(self): pass

View File

@ -1,90 +0,0 @@
import traceback
from typing import Optional
from sh_edraft.configuration.base.configuration_model_base import ConfigurationModelBase
from sh_edraft.publish.model.template import Template
from sh_edraft.publish.model.publish_settings_name import PublishSettingsName
from sh_edraft.console.console import Console
from sh_edraft.console.model.foreground_color import ForegroundColor
class PublishSettings(ConfigurationModelBase):
def __init__(self):
ConfigurationModelBase.__init__(self)
self._source_path: Optional[str] = None
self._dist_path: Optional[str] = None
self._templates: list[Template] = []
self._included_files: list[str] = []
self._excluded_files: list[str] = []
self._template_ending: Optional[str] = None
@property
def source_path(self) -> str:
return self._source_path
@source_path.setter
def source_path(self, source_path: str):
self._source_path = source_path
@property
def dist_path(self) -> str:
return self._dist_path
@dist_path.setter
def dist_path(self, dist_path: str):
self._dist_path = dist_path
@property
def templates(self) -> list[Template]:
return self._templates
@templates.setter
def templates(self, templates: list[Template]):
self._templates = templates
@property
def included_files(self) -> list[str]:
return self._included_files
@included_files.setter
def included_files(self, included_files: list[str]):
self._included_files = included_files
@property
def excluded_files(self) -> list[str]:
return self._excluded_files
@excluded_files.setter
def excluded_files(self, excluded_files: list[str]):
self._excluded_files = excluded_files
@property
def template_ending(self) -> str:
return self._template_ending
@template_ending.setter
def template_ending(self, template_ending: str):
self._template_ending = template_ending
def from_dict(self, settings: dict):
try:
self._source_path = settings[PublishSettingsName.source_path.value]
self._dist_path = settings[PublishSettingsName.dist_path.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._excluded_files = settings[PublishSettingsName.excluded_files.value]
self._template_ending = settings[PublishSettingsName.template_ending.value]
except Exception as e:
Console.set_foreground_color(ForegroundColor.red)
Console.write_line(
f'[ ERROR ] [ {__name__} ]: Reading error in {PublishSettingsName.publish.value} settings')
Console.write_line(f'[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}')
Console.set_foreground_color(ForegroundColor.default)

View File

@ -1,12 +0,0 @@
from enum import Enum
class PublishSettingsName(Enum):
publish = 'Publish'
source_path = 'SourcePath'
dist_path = 'DistPath'
templates = 'Templates'
included_files = 'IncludedFiles'
excluded_files = 'ExcludedFiles'
template_ending = 'TemplateEnding'

View File

@ -1,122 +0,0 @@
from typing import Optional
from sh_edraft.coding.model.version import Version
from sh_edraft.configuration.base.configuration_model_base import ConfigurationModelBase
from sh_edraft.publish.model.template_enum import TemplateEnum
class Template(ConfigurationModelBase):
def __init__(
self,
template_path: Optional[str] = None,
name: Optional[str] = None,
description: Optional[str] = None,
long_description: Optional[str] = None,
copyright_date: Optional[str] = None,
copyright_name: Optional[str] = None,
license_name: Optional[str] = None,
license_description: Optional[str] = None,
title: Optional[str] = None,
author: Optional[str] = None,
version: Optional[Version] = Version()
):
ConfigurationModelBase.__init__(self)
self._template_path: Optional[str] = template_path
self._name: Optional[str] = name
self._description: Optional[str] = description
self._long_description: Optional[str] = long_description
self._copyright_date: Optional[str] = copyright_date
self._copyright_name: Optional[str] = copyright_name
self._license_name: Optional[str] = license_name
self._license_description: Optional[str] = license_description
self._title: Optional[str] = title
self._author: Optional[str] = author
self._version: Optional[Version] = version
self._file_content: Optional[str] = None
@property
def template_path(self) -> Optional[str]:
return self._template_path
@property
def name(self) -> Optional[str]:
return self._name
@property
def description(self) -> Optional[str]:
return self._description
@property
def long_description(self) -> Optional[str]:
return self._long_description
@property
def copyright_date(self) -> Optional[str]:
return self._copyright_date
@property
def copyright_name(self) -> Optional[str]:
return self._copyright_name
@property
def license_name(self) -> Optional[str]:
return self._license_name
@property
def license_description(self) -> Optional[str]:
return self._license_description
@property
def title(self) -> Optional[str]:
return self._title
@property
def author(self) -> Optional[str]:
return self._author
@property
def version(self) -> Optional[Version]:
return self._version
@property
def file_content(self) -> Optional[str]:
return self._file_content
@file_content.setter
def file_content(self, file_content: Optional[str]):
self._file_content = file_content
def from_dict(self, settings: dict):
self._template_path = settings[TemplateEnum.TemplatePath.value]
self._name = settings[TemplateEnum.Name.value]
self._description = settings[TemplateEnum.Description.value]
self._long_description = settings[TemplateEnum.LongDescription.value]
self._copyright_date = settings[TemplateEnum.CopyrightDate.value]
self._copyright_name = settings[TemplateEnum.CopyrightName.value]
self._license_name = settings[TemplateEnum.LicenseName.value]
self._license_description = settings[TemplateEnum.LicenseDescription.value]
self._title = settings[TemplateEnum.Title.value]
self._author = settings[TemplateEnum.Author.value]
self._version.from_dict(settings[TemplateEnum.Version.value])
def to_dict(self) -> dict:
version: Optional[dict] = None
if self._version is not None:
version = self._version.to_dict()
return {
TemplateEnum.TemplatePath.value: self._template_path,
TemplateEnum.Name.value: self._name,
TemplateEnum.Description.value: self._description,
TemplateEnum.LongDescription.value: self._long_description,
TemplateEnum.CopyrightDate.value: self._copyright_date,
TemplateEnum.CopyrightName.value: self._copyright_name,
TemplateEnum.LicenseName.value: self._license_name,
TemplateEnum.LicenseDescription.value: self._license_description,
TemplateEnum.Title.value: self._title,
TemplateEnum.Author.value: self._author,
TemplateEnum.Version.value: version
}

View File

@ -1,16 +0,0 @@
from enum import Enum
class TemplateEnum(Enum):
TemplatePath = 'TemplatePath'
Name = 'Name'
Description = 'Description'
LongDescription = 'LongDescription'
CopyrightDate = 'CopyrightDate'
CopyrightName = 'CopyrightName'
LicenseName = 'LicenseName'
LicenseDescription = 'LicenseDescription'
Title = 'Title'
Author = 'Author'
Version = 'Version'

View File

@ -1,279 +0,0 @@
import os
import shutil
from string import Template as stringTemplate
from setuptools import sandbox
from sh_edraft.logging.base.logger_base import LoggerBase
from sh_edraft.publish.base.publisher_base import PublisherBase
from sh_edraft.publish.model.publish_settings_model import PublishSettings
from sh_edraft.publish.model.template import Template
class Publisher(PublisherBase):
def __init__(self, logger: LoggerBase, publish_settings: PublishSettings):
PublisherBase.__init__(self)
self._logger: LoggerBase = logger
self._publish_settings: PublishSettings = publish_settings
self._included_files: list[str] = []
@property
def source_path(self) -> str:
return self._publish_settings.source_path
@property
def dist_path(self):
return self._publish_settings.dist_path
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,
LongDescription=t.long_description,
CopyrightDate=t.copyright_date,
CopyrightName=t.copyright_name,
LicenseName=t.license_name,
LicenseDescription=t.license_description,
Title=t.title if t.title is not None and t.title != '' else name,
Author=t.author,
Version=t.version.to_str(),
Major=t.version.major,
Minor=t.version.minor,
Micro=t.version.micro,
Imports=imports
)
except Exception as e:
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')
included_files = self._publish_settings.included_files
for included in included_files:
if os.path.isdir(included):
self._publish_settings.included_files.remove(included)
for r, d, f in os.walk(included):
for file in f:
rel_path = os.path.relpath(r)
if not rel_path.startswith('.'):
rel_path = f'./{rel_path}'
file_path = os.path.join(self._publish_settings.source_path, r, file)
if os.path.isfile(file_path):
self._included_files.append(file_path)
elif os.path.isfile(os.path.join(rel_path, file)):
self._included_files.append(os.path.join(rel_path, file))
else:
self._logger.fatal(__name__, f'File not found: {file}')
elif os.path.isfile(included):
self._included_files.append(included)
else:
self._logger.fatal(__name__, f'File not found: {included}')
for r, d, f in os.walk(self._publish_settings.source_path):
for file in f:
is_file_excluded = False
if os.path.join(r, file) in self._publish_settings.excluded_files:
is_file_excluded = True
else:
for excluded in self._publish_settings.excluded_files:
if os.path.join(r, file).__contains__(excluded):
is_file_excluded = True
if not is_file_excluded and file.endswith('.py') or file in self._publish_settings.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._publish_settings.templates:
output_template: str = ''
if not os.path.isfile(t.template_path):
self._logger.fatal(__name__, f'Template not found: {t.template_path}')
with open(t.template_path) as template:
t.file_content = template.read()
template.close()
if t.file_content == '':
self._logger.fatal(__name__, 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._publish_settings.dist_path):
try:
shutil.rmtree(self._publish_settings.dist_path)
self._logger.info(__name__, f'Deleted {self._publish_settings.dist_path}')
except Exception as e:
self._logger.fatal(__name__, f'Cannot delete old dist directory', e)
if not os.path.isdir(self._publish_settings.dist_path):
try:
os.makedirs(self._publish_settings.dist_path)
self._logger.debug(__name__, f'Created directories: {self._publish_settings.dist_path}')
self._logger.info(__name__, f'Created dist directory')
except Exception as e:
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:
dirs = os.path.dirname(file).split('/')
for d in dirs:
if d.__contains__('.'):
dirs.remove(d)
if len(dirs) == 0:
return os.path.basename(file)
else:
return '.'.join(dirs)
def _write_templates(self):
self._logger.trace(__name__, f'Started {__name__}._write_templates')
for template in self._publish_settings.templates:
for file in self._included_files:
if os.path.basename(file) == '__init__.py' and file not in self._publish_settings.excluded_files:
template_name = template.name
if template.name == 'all' or template.name == '':
template_name = self._get_template_name_from_dirs(file)
else:
name = self._get_template_name_from_dirs(file)
if name.__contains__('.'):
if template.name != name.split('.')[len(name.split('.')) - 1]:
continue
else:
if template.name != name:
continue
try:
module_file_lines: list[str] = []
module_py_lines: list[str] = []
imports = ''
with open(file, 'r') as py_file:
module_file_lines = py_file.readlines()
py_file.close()
if len(module_file_lines) == 0:
with open(file, 'w+') as py_file:
py_file.write(self._get_template_output(template, template_name, '# imports:'))
py_file.close()
self._logger.debug(__name__, f'Written to {file}')
else:
is_started = False
for line in module_file_lines:
if line.__contains__('# imports'):
is_started = True
if (line.__contains__('from') or line.__contains__('import')) and is_started:
module_py_lines.append(line.replace('\n', ''))
if len(module_py_lines) > 0:
imports = '\n'.join(module_py_lines)
with open(file, 'w+') as py_file:
py_file.write(self._get_template_output(template, template_name, imports))
py_file.close()
self._logger.debug(__name__, f'Written to {file}')
except Exception as e:
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._publish_settings.dist_path
if self._publish_settings.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._publish_settings.excluded_files:
is_file_excluded = True
else:
for excluded in self._publish_settings.excluded_files:
if file.__contains__(excluded):
is_file_excluded = True
if not is_file_excluded:
output_file = ''
if file.startswith('..'):
output_file = file.replace('..', '')
elif file.startswith('.'):
output_file = file.replace('.', '', 1)
if output_file.__contains__('..'):
output_file = os.path.join(dist_path, os.path.basename(file))
else:
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, exist_ok=True)
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:
self._logger.error(__name__, f'Cannot copy file: {file} to {output_path}', e)
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._publish_settings.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._publish_settings.excluded_files.append(path)
self._logger.trace(__name__, f'Stopped {__name__}.exclude')
def create(self):
self._logger.trace(__name__, f'Started {__name__}.create')
if not self._publish_settings.dist_path.endswith('/'):
self._publish_settings.dist_path += '/'
self._read_source_path()
self._read_templates()
self._create_dist_path()
self._logger.trace(__name__, f'Stopped {__name__}.create')
def build(self):
self._logger.trace(__name__, f'Started {__name__}.build')
self._write_templates()
self._copy_all_included_files()
self._logger.trace(__name__, f'Stopped {__name__}.build')
def publish(self):
self._logger.trace(__name__, f'Started {__name__}.publish')
setup_py = os.path.join(self._publish_settings.dist_path, 'setup.py')
if not os.path.isfile(setup_py):
self._logger.fatal(__name__, f'setup.py not found in {self._publish_settings.dist_path}')
sandbox.run_setup(os.path.abspath(setup_py), ['sdist', 'bdist_wheel'])
self._logger.trace(__name__, f'Stopped {__name__}.publish')

View File

@ -1,25 +0,0 @@
# -*- coding: utf-8 -*-
"""
sh_edraft.service
~~~~~~~~~~~~~~~~~~~
:copyright: (c) 2020 sh-edraft.de
:license: MIT, see LICENSE for more details.
"""
__title__ = 'sh_edraft.service'
__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,26 +0,0 @@
# -*- coding: utf-8 -*-
"""
sh_edraft.service.base
~~~~~~~~~~~~~~~~~~~
:copyright: (c) 2020 sh-edraft.de
:license: MIT, see LICENSE for more details.
"""
__title__ = 'sh_edraft.service.base'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 sh-edraft.de'
__version__ = '2020.12.9'
from collections import namedtuple
# imports:
from .service_base import ServiceBase
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

@ -1,10 +0,0 @@
from abc import ABC, abstractmethod
class ServiceBase(ABC):
@abstractmethod
def __init__(self): pass
@abstractmethod
def create(self): pass

View File

@ -1,27 +0,0 @@
# -*- 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.10'
from collections import namedtuple
# imports:
from .service_provider import ServiceProvider
from .service_provider import ServiceProviderBase
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=10)

View File

@ -1,26 +0,0 @@
# -*- 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
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

@ -1,33 +0,0 @@
from abc import abstractmethod, ABC
from collections import Callable
from typing import Type
from sh_edraft.database.context.base.database_context_base import DatabaseContextBase
from sh_edraft.service.base.service_base import ServiceBase
class ServiceProviderBase(ABC):
@abstractmethod
def __init__(self): pass
@abstractmethod
def add_db_context(self, db_context: Type[DatabaseContextBase]): pass
@abstractmethod
def get_db_context(self) -> Callable[DatabaseContextBase]: pass
@abstractmethod
def add_transient(self, service_type: Type[ServiceBase], service: Type[ServiceBase]): pass
@abstractmethod
def add_scoped(self, service_type: Type[ServiceBase], service: Type[ServiceBase]): pass
@abstractmethod
def add_singleton(self, service_type: Type[ServiceBase], service: Callable[ServiceBase]): pass
@abstractmethod
def get_service(self, instance_type: Type[ServiceBase]) -> Callable[ServiceBase]: pass
@abstractmethod
def remove_service(self, instance_type: type): pass

View File

@ -1,26 +0,0 @@
# -*- 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
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

@ -1,18 +0,0 @@
from typing import Type
from sh_edraft.service.base.service_base import ServiceBase
class ProvideState:
def __init__(self, service: Type[ServiceBase] = None, args: tuple = None):
self._service: Type[ServiceBase] = service
self._args: tuple = args
@property
def service(self):
return self._service
@property
def args(self) -> tuple:
return self._args

View File

@ -1,95 +0,0 @@
from collections import Callable
from inspect import signature, Parameter
from typing import Type, Optional
from sh_edraft.configuration.base.configuration_model_base import ConfigurationModelBase
from sh_edraft.database.context.base.database_context_base import DatabaseContextBase
from sh_edraft.environment.base import EnvironmentBase
from sh_edraft.hosting.base.application_runtime_base import ApplicationRuntimeBase
from sh_edraft.service.providing.base.service_provider_base import ServiceProviderBase
from sh_edraft.service.base.service_base import ServiceBase
class ServiceProvider(ServiceProviderBase):
def __init__(self, app_runtime: ApplicationRuntimeBase):
ServiceProviderBase.__init__(self)
self._app_runtime: ApplicationRuntimeBase = app_runtime
self._database_context: Optional[DatabaseContextBase] = None
self._transient_services: dict[Type[ServiceBase], Type[ServiceBase]] = {}
self._scoped_services: dict[Type[ServiceBase], Type[ServiceBase]] = {}
self._singleton_services: dict[Type[ServiceBase], ServiceBase] = {}
def create(self): pass
def _create_instance(self, service: Callable[ServiceBase]) -> ServiceBase:
sig = signature(service.__init__)
params = []
for param in sig.parameters.items():
parameter = param[1]
if parameter.name != 'self' and parameter.annotation != Parameter.empty:
if issubclass(parameter.annotation, ApplicationRuntimeBase):
params.append(self._app_runtime)
elif issubclass(parameter.annotation, EnvironmentBase):
params.append(self._app_runtime.configuration.environment)
elif issubclass(parameter.annotation, DatabaseContextBase):
params.append(self._database_context)
elif issubclass(parameter.annotation, ServiceBase):
params.append(self.get_service(parameter.annotation))
elif issubclass(parameter.annotation, ConfigurationModelBase):
params.append(self._app_runtime.configuration.get_configuration(parameter.annotation))
return service(*params)
def add_db_context(self, db_context: Type[DatabaseContextBase]):
self._database_context = self._create_instance(db_context)
def get_db_context(self) -> Callable[DatabaseContextBase]:
return self._database_context
def add_transient(self, service_type: Type[ServiceBase], service: Type[ServiceBase]):
self._transient_services[service_type] = service
def add_scoped(self, service_type: Type[ServiceBase], service: Type[ServiceBase]):
self._scoped_services[service_type] = service
def add_singleton(self, service_type: Type[ServiceBase], service: Callable[ServiceBase]):
for known_service in self._singleton_services:
if type(known_service) == service_type:
raise Exception(f'Service with type {service_type} already exists')
self._singleton_services[service_type] = self._create_instance(service)
def get_service(self, instance_type: Type[ServiceBase]) -> Callable[ServiceBase]:
for service in self._transient_services:
if service == instance_type and isinstance(self._transient_services[service], type(instance_type)):
return self._create_instance(self._transient_services[service])
for service in self._scoped_services:
if service == instance_type and isinstance(self._scoped_services[service], type(instance_type)):
return self._create_instance(self._scoped_services[service])
for service in self._singleton_services:
if service == instance_type and isinstance(self._singleton_services[service], instance_type):
return self._singleton_services[service]
def remove_service(self, instance_type: Type[ServiceBase]):
for service in self._transient_services:
if service == instance_type and isinstance(self._transient_services[service], type(instance_type)):
del self._transient_services[service]
return
for service in self._scoped_services:
if service == instance_type and isinstance(self._scoped_services[service], type(instance_type)):
del self._scoped_services[service]
return
for service in self._singleton_services:
if service == instance_type and isinstance(self._singleton_services[service], instance_type):
del self._singleton_services[service]
return

View File

@ -1,25 +0,0 @@
# -*- coding: utf-8 -*-
"""
sh_edraft.time
~~~~~~~~~~~~~~~~~~~
:copyright: (c) 2020 sh-edraft.de
:license: MIT, see LICENSE for more details.
"""
__title__ = 'sh_edraft.time'
__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,27 +0,0 @@
# -*- coding: utf-8 -*-
"""
sh_edraft.time.model
~~~~~~~~~~~~~~~~~~~
:copyright: (c) 2020 sh-edraft.de
:license: MIT, see LICENSE for more details.
"""
__title__ = 'sh_edraft.time.model'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 sh-edraft.de'
__version__ = '2020.12.9'
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=9)

View File

@ -1,61 +0,0 @@
import traceback
from typing import Optional
from sh_edraft.configuration.base.configuration_model_base import ConfigurationModelBase
from sh_edraft.time.model.time_format_settings_names import TimeFormatSettingsNames
from sh_edraft.console.console import Console
from sh_edraft.console.model.foreground_color import ForegroundColor
class TimeFormatSettings(ConfigurationModelBase):
def __init__(self):
ConfigurationModelBase.__init__(self)
self._date_format: Optional[str] = None
self._time_format: Optional[str] = None
self._date_time_format: Optional[str] = None
self._date_time_log_format: Optional[str] = None
@property
def date_format(self) -> str:
return self._date_format
@date_format.setter
def date_format(self, date_format: str) -> None:
self._date_format = date_format
@property
def time_format(self) -> str:
return self._time_format
@time_format.setter
def time_format(self, time_format: str):
self._time_format = time_format
@property
def date_time_format(self) -> str:
return self._date_time_format
@date_time_format.setter
def date_time_format(self, date_time_format: str) -> None:
self._date_time_format = date_time_format
@property
def date_time_log_format(self):
return self._date_time_log_format
@date_time_log_format.setter
def date_time_log_format(self, date_time_now_format: str) -> None:
self._date_time_log_format = date_time_now_format
def from_dict(self, settings: dict):
try:
self._date_format = settings[TimeFormatSettingsNames.date_format.value]
self._time_format = settings[TimeFormatSettingsNames.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]
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'[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}')
Console.set_foreground_color(ForegroundColor.default)

View File

@ -1,9 +0,0 @@
from enum import Enum
class TimeFormatSettingsNames(Enum):
date_format = 'DateFormat'
time_format = 'TimeFormat'
date_time_format = 'DateTimeFormat'
date_time_log_format = 'DateTimeLogFormat'

View File

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

View File

@ -1,17 +0,0 @@
import base64
class CredentialManager:
@staticmethod
def encrypt(string: str) -> str:
return base64.b64encode(string.encode('utf-8')).decode('utf-8')
@staticmethod
def decrypt(string: str) -> str:
return base64.b64decode(string).decode('utf-8')
@staticmethod
def build_string(string: str, credentials: str):
return string.replace('$credentials', CredentialManager.decrypt(credentials))

View File

@ -1,25 +0,0 @@
# -*- coding: utf-8 -*-
"""
tests
~~~~~~~~~~~~~~~~~~~
:copyright: (c) 2020 sh-edraft.de
:license: MIT, see LICENSE for more details.
"""
__title__ = 'tests'
__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,20 +0,0 @@
{
"TimeFormatSettings": {
"DateFormat": "%Y-%m-%d",
"TimeFormat": "%H:%M:%S",
"DateTimeFormat": "%Y-%m-%d %H:%M:%S.%f",
"DateTimeLogFormat": "%Y-%m-%d_%H-%M-%S"
},
"LoggingSettings": {
"Path": "logs/",
"Filename": "log_$start_time.log",
"ConsoleLogLevel": "TRACE",
"FileLogLevel": "TRACE"
},
"EMailClientSettings": {
"Host": "mail.sh-edraft.de",
"Port": "587",
"UserName": "dev-srv@sh-edraft.de",
"Credentials": "RmBOQX1eNFYiYjgsSid3fV1nelc2WA=="
}
}

View File

@ -1,20 +0,0 @@
{
"TimeFormatSettings": {
"DateFormat": "%Y-%m-%d",
"TimeFormat": "%H:%M:%S",
"DateTimeFormat": "%Y-%m-%d %H:%M:%S.%f",
"DateTimeLogFormat": "%Y-%m-%d_%H-%M-%S"
},
"LoggingSettings": {
"Path": "logs/",
"Filename": "log_$start_time.log",
"ConsoleLogLevel": "TRACE",
"FileLogLevel": "TRACE"
},
"EMailClientSettings": {
"Host": "mail.sh-edraft.de",
"Port": "587",
"UserName": "dev-srv@sh-edraft.de",
"Credentials": "RmBOQX1eNFYiYjgsSid3fV1nelc2WA=="
}
}

View File

@ -1,15 +0,0 @@
{
"TimeFormatSettings": {
"DateFormat": "%Y-%m-%d",
"TimeFormat": "%H:%M:%S",
"DateTimeFormat": "%Y-%m-%d %H:%M:%S.%f",
"DateTimeLogFormat": "%Y-%m-%d_%H-%M-%S"
},
"LoggingSettings": {
"Path": "logs/",
"Filename": "log_$start_time.log",
"ConsoleLogLevel": "ERROR",
"FileLogLevel": "WARN"
}
}

View File

@ -1,14 +0,0 @@
{
"LoggingSettings": {
"Path": "logs/",
"Filename": "log_$start_time.log",
"ConsoleLogLevel": "TRACE",
"FileLogLevel": "TRACE"
},
"DatabaseSettings": {
"ConnectionString": "mysql+mysqlconnector://sh_cpl:$credentials@localhost/sh_cpl",
"Credentials": "MHZhc0Y2bjhKc1VUMWV0Qw==",
"Encoding": "utf8mb4"
}
}

View File

@ -1,59 +0,0 @@
{
"TimeFormatSettings": {
"DateFormat": "%Y-%m-%d",
"TimeFormat": "%H:%M:%S",
"DateTimeFormat": "%Y-%m-%d %H:%M:%S.%f",
"DateTimeLogFormat": "%Y-%m-%d_%H-%M-%S"
},
"LoggingSettings": {
"Path": "../../build_test/logs/",
"Filename": "log_$start_time.log",
"ConsoleLogLevel": "INFO",
"FileLogLevel": "TRACE"
},
"PublishSettings": {
"SourcePath": "./",
"DistPath": "../../build_test/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": 10
}
},
{
"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": 10
}
}
],
"IncludedFiles": [
],
"ExcludedFiles": [
],
"TemplateEnding": "_template.txt"
}
}

View File

@ -1,52 +0,0 @@
import os
import unittest
from sh_edraft.console import Console
from sh_edraft.hosting import ApplicationHost
from sh_edraft.logging import Logger
from sh_edraft.logging.base import LoggerBase
from sh_edraft.publish import Publisher
from sh_edraft.publish.base import PublisherBase
from sh_edraft.publish.model import PublishSettings
class PublisherTest(unittest.TestCase):
def setUp(self):
Console.disable()
self._app_host = ApplicationHost()
self._configuration = self._app_host.configuration
self._services = self._app_host.services
self._configuration.add_environment_variables('CPL_')
self._configuration.add_argument_variables()
self._configuration.add_json_file(f'build.json')
self._services.add_singleton(LoggerBase, Logger)
self._services.add_singleton(PublisherBase, Publisher)
self._publisher: Publisher = self._services.get_service(PublisherBase)
def test_include(self):
value = './test.py'
self._publisher.include(value)
self.assertTrue(value in self._publisher._publish_settings.included_files)
def test_exclude(self):
value = './test.py'
self._publisher.exclude(value)
self.assertTrue(value in self._publisher._publish_settings.excluded_files)
def test_create(self):
self._publisher.create()
self.assertTrue(os.path.isdir(self._configuration.get_configuration(PublishSettings).dist_path))
def test_build(self):
self._publisher.create()
self._publisher.build()
self.assertTrue(os.path.isdir(self._configuration.get_configuration(PublishSettings).dist_path))
def test_publish(self):
self._publisher.create()
self._publisher.build()
self._publisher.publish()
self.assertTrue(os.path.isdir(self._configuration.get_configuration(PublishSettings).dist_path))

View File

@ -1,79 +0,0 @@
import unittest
from sh_edraft.console import Console
from sh_edraft.database.context import DatabaseContext
from sh_edraft.hosting import ApplicationHost
from sh_edraft.logging import Logger
from sh_edraft.logging.base import LoggerBase
class ProviderTest(unittest.TestCase):
def setUp(self):
Console.disable()
self._app_host = ApplicationHost()
self._configuration = self._app_host.configuration
self._services = self._app_host.services
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 test_get_db_context(self):
self._services.add_db_context(DatabaseContext)
db: DatabaseContext = self._services.get_db_context()
self.assertIsNotNone(db)
def test_get_service_singleton(self):
self._services.add_singleton(LoggerBase, Logger)
logger = self._services.get_service(LoggerBase)
self.assertIsNotNone(logger)
def test_get_service_scoped(self):
self._services.add_scoped(LoggerBase, Logger)
logger = self._services.get_service(LoggerBase)
self.assertIsNotNone(logger)
def test_get_service_transient(self):
self._services.add_transient(LoggerBase, Logger)
logger = self._services.get_service(LoggerBase)
self.assertIsNotNone(logger)
def test_remove_service_singleton(self):
self._services.add_singleton(LoggerBase, Logger)
logger = self._services.get_service(LoggerBase)
self.assertIsNotNone(logger)
self._services.remove_service(LoggerBase)
logger = self._services.get_service(LoggerBase)
self.assertIsNone(logger)
def test_remove_service_scoped(self):
self._services.add_scoped(LoggerBase, Logger)
logger = self._services.get_service(LoggerBase)
self.assertIsNotNone(logger)
self._services.remove_service(LoggerBase)
logger = self._services.get_service(LoggerBase)
self.assertIsNone(logger)
def test_remove_service_transient(self):
self._services.add_transient(LoggerBase, Logger)
logger = self._services.get_service(LoggerBase)
self.assertIsNotNone(logger)
self._services.remove_service(LoggerBase)
logger = self._services.get_service(LoggerBase)
self.assertIsNone(logger)

View File

@ -1,24 +0,0 @@
import setuptools
setuptools.setup(
name='sh_edraft_unittests',
version='2020.0.1',
packages=setuptools.find_packages(exclude=["tests*"]),
url='https://www.sh-edraft.de',
license='MIT',
author='Sven Heidemann',
author_email='edraft.sh@gmail.com',
include_package_data=True,
description='sh-edraft python common lib unittest',
python_requires='>=3.8',
install_requires=[
'discord.py',
'flask',
'mysql-connector',
'SQLAlchemy',
'termcolor',
'pyfiglet',
'tabulate',
'smtplib'
]
)

View File

@ -1,26 +0,0 @@
import unittest
from sh_edraft.time.model import TimeFormatSettingsNames, TimeFormatSettings
class TimeFormatSettingsTest(unittest.TestCase):
def setUp(self): pass
def test_from_dict(self):
test_dict = {
TimeFormatSettingsNames.date_format.value: '%H:%M:%S',
TimeFormatSettingsNames.time_format.value: '%Y-%m-%d',
TimeFormatSettingsNames.date_time_format.value: '%Y-%m-%d %H:%M:%S.%f',
TimeFormatSettingsNames.date_time_log_format.value: '%Y-%m-%d_%H-%M-%S'
}
settings = TimeFormatSettings()
settings.from_dict(test_dict)
self.assertIsNotNone(settings)
self.assertEqual(test_dict[TimeFormatSettingsNames.date_format.value], settings.date_format)
self.assertEqual(test_dict[TimeFormatSettingsNames.time_format.value], settings.time_format)
self.assertEqual(test_dict[TimeFormatSettingsNames.date_time_format.value], settings.date_time_format)
self.assertEqual(test_dict[TimeFormatSettingsNames.date_time_log_format.value], settings.date_time_log_format)

View File

@ -1,37 +0,0 @@
import base64
import unittest
from sh_edraft.utils import CredentialManager
class CredentialManagerTest(unittest.TestCase):
def setUp(self): pass
def test_encode(self):
test_string = 'Hello World'
expected_test_result = base64.b64encode(test_string.encode('utf-8')).decode('utf-8')
test_result = CredentialManager.encrypt(test_string)
self.assertIsNotNone(test_result)
self.assertEqual(expected_test_result, test_result)
def test_decode(self):
test_string = 'SGVsbG8gV29ybGQ='
expected_test_result = base64.b64decode(test_string).decode('utf-8')
test_result = CredentialManager.decrypt(test_string)
self.assertIsNotNone(test_result)
self.assertEqual(expected_test_result, test_result)
def test_build_string(self):
test_string = 'String is $credentials'
test_credentials = 'SGVsbG8gV29ybGQ='
expected_test_result = test_string.replace('$credentials', base64.b64decode(test_credentials).decode('utf-8'))
test_result = CredentialManager.build_string(test_string, test_credentials)
self.assertIsNotNone(test_result)
self.assertEqual(expected_test_result, test_result)

Some files were not shown because too many files have changed in this diff Show More