diff --git a/src/sh_edraft/publishing/model/publish_settings_model.py b/src/sh_edraft/publishing/model/publish_settings_model.py index 4111d7fc..9412be5b 100644 --- a/src/sh_edraft/publishing/model/publish_settings_model.py +++ b/src/sh_edraft/publishing/model/publish_settings_model.py @@ -74,7 +74,7 @@ class PublishSettings(ConfigurationModelBase): try: self._source_path = settings[PublishSettingsName.source_path.value] self._dist_path = settings[PublishSettingsName.dist_path.value] - self._templates = settings[PublishSettingsName.templates.value] + self._templates = Template().from_dict(settings[PublishSettingsName.templates.value]) self._included_files = settings[PublishSettingsName.included_files.value] self._excluded_files = settings[PublishSettingsName.excluded_files.value] self._template_ending = settings[PublishSettingsName.template_ending.value] diff --git a/src/tests_dev/appsettings.development.json b/src/tests_dev/appsettings.development.json index 3a54f3cc..d134912e 100644 --- a/src/tests_dev/appsettings.development.json +++ b/src/tests_dev/appsettings.development.json @@ -5,6 +5,7 @@ "ConsoleLogLevel": "TRACE", "FileLogLevel": "TRACE" }, + "DatabaseSettings": { "ConnectionString": "mysql+mysqlconnector://sh_cpl:$credentials@localhost/sh_cpl", "Credentials": "MHZhc0Y2bjhKc1VUMWV0Qw==", diff --git a/src/tests_dev/appsettings.edrafts-pc.json b/src/tests_dev/appsettings.edrafts-pc.json new file mode 100644 index 00000000..e73add9f --- /dev/null +++ b/src/tests_dev/appsettings.edrafts-pc.json @@ -0,0 +1,57 @@ +{ + "TimeFormatSettings": { + "DateFormat": "%Y-%m-%d", + "TimeFormat": "%H:%M:%S", + "DateTimeFormat": "%Y-%m-%d %H:%M:%S.%f", + "DateTimeLogFormat": "%Y-%m-%d_%H-%M-%S" + }, + "LoggingSettings": { + "Path": "logs/", + "Filename": "log_$start_time.log", + "ConsoleLogLevel": "TRACE", + "FileLogLevel": "TRACE" + }, + "PublisherSettings": { + "SourcePath": "../", + "DistPath": "../../dist", + "Templates": [ + { + "TemplatePath": "../../publish_templates/all_template.txt", + "Name": "all", + "Description": "", + "LongDescription": "", + "CopyrightDate": "2020", + "CopyrightName": "sh-edraft.de", + "LicenseName": "MIT", + "LicenseDescription": ", see LICENSE for more details.", + "Title": "", + "Author": "Sven Heidemann", + "Version": { + "major": 2020, + "minor": 12, + "micro": 9 + } + }, + { + "TemplatePath": "../../publish_templates/all_template.txt", + "Name": "sh_edraft", + "Description": "common python library", + "LongDescription": "Library to share common classes and models used at sh-edraft.de", + "CopyrightDate": "2020", + "CopyrightName": "sh-edraft.de", + "LicenseName": "MIT", + "LicenseDescription": ", see LICENSE for more details.", + "Title": "", + "Author": "Sven Heidemann", + "Version": { + "major": 2020, + "minor": 12, + "micro": 9 + } + } + ], + "IncludedFiles": [], + "ExcludedFiles": [], + "TemplateEnding": "_template.txt" + } +} \ No newline at end of file diff --git a/src/tests_dev/publisher.py b/src/tests_dev/publisher.py new file mode 100644 index 00000000..842e1d86 --- /dev/null +++ b/src/tests_dev/publisher.py @@ -0,0 +1,62 @@ +from typing import Optional + +from sh_edraft.configuration.base import ConfigurationBase +from sh_edraft.hosting import ApplicationHost +from sh_edraft.hosting.base import ApplicationBase +from sh_edraft.logging import Logger +from sh_edraft.logging.base import LoggerBase +from sh_edraft.publishing import Publisher +from sh_edraft.publishing.base import PublisherBase +from sh_edraft.service.providing.base import ServiceProviderBase + + +class Program(ApplicationBase): + + def __init__(self): + ApplicationBase.__init__(self) + + self._app_host: Optional[ApplicationHost] = None + self._services: Optional[ServiceProviderBase] = None + self._configuration: Optional[ConfigurationBase] = None + self._logger: Optional[LoggerBase] = None + self._publisher: Optional[PublisherBase] = None + + def create_application_host(self): + self._app_host = ApplicationHost() + self._configuration = self._app_host.configuration + self._services = self._app_host.services + + def create_configuration(self): + self._configuration.add_environment_variables('PYTHON_') + self._configuration.add_environment_variables('CPL_') + self._configuration.add_argument_variables() + self._configuration.add_json_file(f'appsettings.json') + self._configuration.add_json_file(f'appsettings.{self._configuration.environment.environment_name}.json') + self._configuration.add_json_file(f'appsettings.{self._configuration.environment.host_name}.json', optional=True) + + def create_services(self): + # Add and create logger + self._services.add_singleton(LoggerBase, Logger) + self._logger = self._services.get_service(LoggerBase) + + # Add and create publisher + self._services.add_singleton(PublisherBase, Publisher) + self._publisher: Publisher = self._services.get_service(PublisherBase) + + def main(self): + self._logger.header(f'{self._configuration.environment.application_name}:') + self._logger.debug(__name__, f'Host: {self._configuration.environment.host_name}') + self._logger.debug(__name__, f'Environment: {self._configuration.environment.environment_name}') + self._logger.debug(__name__, f'Customer: {self._configuration.environment.customer}') + #self._publisher.exclude() + #self._publisher.include() + # self._publisher.create() + print(self._publisher) + + +if __name__ == '__main__': + program = Program() + program.create_application_host() + program.create_configuration() + program.create_services() + program.main()