Improved publisher
This commit is contained in:
parent
6f82bd8b35
commit
7ee2eff483
@ -3,6 +3,6 @@ from enum import Enum
|
||||
|
||||
class VersionEnum(Enum):
|
||||
|
||||
Major = 'major'
|
||||
Minor = 'minor'
|
||||
Micro = 'micro'
|
||||
Major = 'Major'
|
||||
Minor = 'Minor'
|
||||
Micro = 'Micro'
|
||||
|
@ -11,6 +11,7 @@ class Console:
|
||||
_foreground_color: ForegroundColor = ForegroundColor.default
|
||||
_x: Optional[int] = None
|
||||
_y: Optional[int] = None
|
||||
_disabled: bool = False
|
||||
|
||||
"""
|
||||
Properties
|
||||
@ -60,6 +61,9 @@ class Console:
|
||||
|
||||
@classmethod
|
||||
def _output(cls, string: str, x: int = None, y: int = None, end='\n'):
|
||||
if cls._disabled:
|
||||
return
|
||||
|
||||
args = []
|
||||
colored_args = []
|
||||
|
||||
@ -95,6 +99,14 @@ class Console:
|
||||
Console.read_line()
|
||||
exit()
|
||||
|
||||
@classmethod
|
||||
def disable(cls):
|
||||
cls._disabled = True
|
||||
|
||||
@classmethod
|
||||
def enable(cls):
|
||||
cls._disabled = False
|
||||
|
||||
@classmethod
|
||||
def read(cls, output: str = None) -> str:
|
||||
if output is not None:
|
||||
|
@ -15,10 +15,10 @@ class PublishSettings(ConfigurationModelBase):
|
||||
|
||||
self._source_path: Optional[str] = None
|
||||
self._dist_path: Optional[str] = None
|
||||
self._templates: Optional[list[Template]] = None
|
||||
self._templates: list[Template] = []
|
||||
|
||||
self._included_files: Optional[list[str]] = None
|
||||
self._excluded_files: Optional[list[str]] = None
|
||||
self._included_files: list[str] = []
|
||||
self._excluded_files: list[str] = []
|
||||
|
||||
self._template_ending: Optional[str] = None
|
||||
|
||||
@ -74,7 +74,11 @@ class PublishSettings(ConfigurationModelBase):
|
||||
try:
|
||||
self._source_path = settings[PublishSettingsName.source_path.value]
|
||||
self._dist_path = settings[PublishSettingsName.dist_path.value]
|
||||
self._templates = Template().from_dict(settings[PublishSettingsName.templates.value])
|
||||
for template in settings[PublishSettingsName.templates.value]:
|
||||
temp = Template()
|
||||
temp.from_dict(template)
|
||||
self._templates.append(temp)
|
||||
|
||||
self._included_files = settings[PublishSettingsName.included_files.value]
|
||||
self._excluded_files = settings[PublishSettingsName.excluded_files.value]
|
||||
self._template_ending = settings[PublishSettingsName.template_ending.value]
|
||||
|
@ -19,7 +19,7 @@ class Template(ConfigurationModelBase):
|
||||
license_description: Optional[str] = None,
|
||||
title: Optional[str] = None,
|
||||
author: Optional[str] = None,
|
||||
version: Optional[dict] = None
|
||||
version: Optional[Version] = Version()
|
||||
):
|
||||
ConfigurationModelBase.__init__(self)
|
||||
self._template_path: Optional[str] = template_path
|
||||
@ -33,8 +33,7 @@ class Template(ConfigurationModelBase):
|
||||
self._title: Optional[str] = title
|
||||
self._author: Optional[str] = author
|
||||
|
||||
self._version: Optional[Version] = Version()
|
||||
self._version.from_dict(version)
|
||||
self._version: Optional[Version] = version
|
||||
|
||||
self._file_content: Optional[str] = None
|
||||
|
||||
|
@ -15,7 +15,7 @@ from sh_edraft.time.model import TimeFormatSettings
|
||||
class PublisherTest(unittest.TestCase):
|
||||
|
||||
def _configure(self):
|
||||
self._version = Version(2020, 12, 5).to_dict()
|
||||
self._version = Version(2020, 12, 5)
|
||||
templates = [
|
||||
Template(
|
||||
'../../publish_templates/all_template.txt',
|
||||
|
@ -11,7 +11,7 @@
|
||||
"ConsoleLogLevel": "TRACE",
|
||||
"FileLogLevel": "TRACE"
|
||||
},
|
||||
"PublisherSettings": {
|
||||
"PublishSettings": {
|
||||
"SourcePath": "../",
|
||||
"DistPath": "../../dist",
|
||||
"Templates": [
|
||||
@ -27,9 +27,9 @@
|
||||
"Title": "",
|
||||
"Author": "Sven Heidemann",
|
||||
"Version": {
|
||||
"major": 2020,
|
||||
"minor": 12,
|
||||
"micro": 9
|
||||
"Major": 2020,
|
||||
"Minor": 12,
|
||||
"Micro": 9
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -44,9 +44,9 @@
|
||||
"Title": "",
|
||||
"Author": "Sven Heidemann",
|
||||
"Version": {
|
||||
"major": 2020,
|
||||
"minor": 12,
|
||||
"micro": 9
|
||||
"Major": 2020,
|
||||
"Minor": 12,
|
||||
"Micro": 9
|
||||
}
|
||||
}
|
||||
],
|
||||
|
@ -1,6 +1,7 @@
|
||||
from typing import Optional
|
||||
|
||||
from sh_edraft.configuration.base import ConfigurationBase
|
||||
from sh_edraft.console import Console
|
||||
from sh_edraft.hosting import ApplicationHost
|
||||
from sh_edraft.hosting.base import ApplicationBase
|
||||
from sh_edraft.logging import Logger
|
||||
@ -20,6 +21,7 @@ class Program(ApplicationBase):
|
||||
self._configuration: Optional[ConfigurationBase] = None
|
||||
self._logger: Optional[LoggerBase] = None
|
||||
self._publisher: Optional[PublisherBase] = None
|
||||
# Console.disable()
|
||||
|
||||
def create_application_host(self):
|
||||
self._app_host = ApplicationHost()
|
||||
@ -36,6 +38,7 @@ class Program(ApplicationBase):
|
||||
|
||||
def create_services(self):
|
||||
# Add and create logger
|
||||
Console.enable()
|
||||
self._services.add_singleton(LoggerBase, Logger)
|
||||
self._logger = self._services.get_service(LoggerBase)
|
||||
|
||||
@ -48,10 +51,12 @@ class Program(ApplicationBase):
|
||||
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.exclude('../tests')
|
||||
self._publisher.exclude('../tests_dev')
|
||||
# self._publisher.include()
|
||||
# self._publisher.create()
|
||||
print(self._publisher)
|
||||
self._publisher.create()
|
||||
self._publisher.publish()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
Loading…
Reference in New Issue
Block a user