Added cpl_cli docs & moved cpl_cli/templates -> cpl_cli/_templates
This commit is contained in:
25
src/cpl_cli/_templates/__init__.py
Normal file
25
src/cpl_cli/_templates/__init__.py
Normal file
@@ -0,0 +1,25 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
sh_cpl-cli sh-edraft Common Python library CLI
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
sh-edraft Common Python library Command Line Interface
|
||||
|
||||
:copyright: (c) 2020 - 2021 sh-edraft.de
|
||||
:license: MIT, see LICENSE for more details.
|
||||
|
||||
"""
|
||||
|
||||
__title__ = 'cpl_cli._templates'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||
__version__ = '2021.4'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='2021', minor='4', micro='None')
|
25
src/cpl_cli/_templates/build/__init__.py
Normal file
25
src/cpl_cli/_templates/build/__init__.py
Normal file
@@ -0,0 +1,25 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
sh_cpl-cli sh-edraft Common Python library CLI
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
sh-edraft Common Python library Command Line Interface
|
||||
|
||||
:copyright: (c) 2020 - 2021 sh-edraft.de
|
||||
:license: MIT, see LICENSE for more details.
|
||||
|
||||
"""
|
||||
|
||||
__title__ = 'cpl_cli._templates.build'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||
__version__ = '2021.4'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='2021', minor='4', micro='None')
|
36
src/cpl_cli/_templates/build/init_template.py
Normal file
36
src/cpl_cli/_templates/build/init_template.py
Normal file
@@ -0,0 +1,36 @@
|
||||
import textwrap
|
||||
|
||||
|
||||
class InitTemplate:
|
||||
|
||||
@staticmethod
|
||||
def get_init_py() -> str:
|
||||
string = textwrap.dedent("""\
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
\"\"\"
|
||||
$Name $Description
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
$LongDescription
|
||||
|
||||
:copyright: (c) $CopyrightDate $CopyrightName
|
||||
:license: $LicenseDescription
|
||||
|
||||
\"\"\"
|
||||
|
||||
__title__ = '$Title'
|
||||
__author__ = '$Author'
|
||||
__license__ = '$LicenseName'
|
||||
__copyright__ = 'Copyright (c) $CopyrightDate $CopyrightName'
|
||||
__version__ = '$Version'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
$Imports
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='$Major', minor='$Minor', micro='$Micro')
|
||||
""")
|
||||
|
||||
return string
|
25
src/cpl_cli/_templates/generate/__init__.py
Normal file
25
src/cpl_cli/_templates/generate/__init__.py
Normal file
@@ -0,0 +1,25 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
sh_cpl-cli sh-edraft Common Python library CLI
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
sh-edraft Common Python library Command Line Interface
|
||||
|
||||
:copyright: (c) 2020 - 2021 sh-edraft.de
|
||||
:license: MIT, see LICENSE for more details.
|
||||
|
||||
"""
|
||||
|
||||
__title__ = 'cpl_cli._templates.generate'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||
__version__ = '2021.4'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='2021', minor='4', micro='None')
|
38
src/cpl_cli/_templates/generate/abc_template.py
Normal file
38
src/cpl_cli/_templates/generate/abc_template.py
Normal file
@@ -0,0 +1,38 @@
|
||||
import textwrap
|
||||
from string import Template
|
||||
|
||||
from cpl.utils.string import String
|
||||
from cpl_cli._templates.template_file_abc import TemplateFileABC
|
||||
|
||||
|
||||
class ABCTemplate(TemplateFileABC):
|
||||
|
||||
def __init__(self, name: str, schematic: str, schematic_upper: str, path: str):
|
||||
TemplateFileABC.__init__(self)
|
||||
|
||||
self._name = f'{String.convert_to_snake_case(name)}_{schematic}.py'
|
||||
self._class_name = f'{String.first_to_upper(name)}{schematic_upper}'
|
||||
self._path = path
|
||||
self._value = textwrap.dedent("""\
|
||||
from abc import ABC, abstractmethod
|
||||
|
||||
|
||||
class $Name(ABC):
|
||||
|
||||
@abstractmethod
|
||||
def __init__(self): pass
|
||||
""")
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def path(self) -> str:
|
||||
return self._path
|
||||
|
||||
@property
|
||||
def value(self) -> str:
|
||||
return Template(self._value).substitute(
|
||||
Name=self._class_name
|
||||
)
|
35
src/cpl_cli/_templates/generate/class_template.py
Normal file
35
src/cpl_cli/_templates/generate/class_template.py
Normal file
@@ -0,0 +1,35 @@
|
||||
import textwrap
|
||||
from string import Template
|
||||
|
||||
from cpl.utils.string import String
|
||||
from cpl_cli._templates.template_file_abc import TemplateFileABC
|
||||
|
||||
|
||||
class ClassTemplate(TemplateFileABC):
|
||||
|
||||
def __init__(self, name: str, schematic: str, schematic_upper: str, path: str):
|
||||
TemplateFileABC.__init__(self)
|
||||
|
||||
self._name = f'{String.convert_to_snake_case(name)}.py'
|
||||
self._class_name = f'{String.first_to_upper(name)}'
|
||||
self._path = path
|
||||
self._value = textwrap.dedent("""\
|
||||
class $Name:
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
""")
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def path(self) -> str:
|
||||
return self._path
|
||||
|
||||
@property
|
||||
def value(self) -> str:
|
||||
return Template(self._value).substitute(
|
||||
Name=self._class_name
|
||||
)
|
54
src/cpl_cli/_templates/generate/configmodel_template.py
Normal file
54
src/cpl_cli/_templates/generate/configmodel_template.py
Normal file
@@ -0,0 +1,54 @@
|
||||
import textwrap
|
||||
from string import Template
|
||||
|
||||
from cpl.utils.string import String
|
||||
from cpl_cli._templates.template_file_abc import TemplateFileABC
|
||||
|
||||
|
||||
class ConfigModelTemplate(TemplateFileABC):
|
||||
|
||||
def __init__(self, name: str, schematic: str, schematic_upper: str, path: str):
|
||||
TemplateFileABC.__init__(self)
|
||||
|
||||
self._name = f'{String.convert_to_snake_case(name)}_{schematic}.py'
|
||||
self._class_name = f'{String.first_to_upper(name)}{schematic_upper}'
|
||||
self._path = path
|
||||
self._value = textwrap.dedent("""\
|
||||
import traceback
|
||||
|
||||
from cpl.configuration.configuration_model_abc import ConfigurationModelABC
|
||||
from cpl.console import Console
|
||||
|
||||
|
||||
class $Name(ConfigurationModelABC):
|
||||
|
||||
def __init__(self):
|
||||
ConfigurationModelABC.__init__(self)
|
||||
|
||||
self._atr = ''
|
||||
|
||||
@property
|
||||
def atr(self) -> str:
|
||||
return self._atr
|
||||
|
||||
def from_dict(self, settings: dict):
|
||||
try:
|
||||
self._atr = settings['atr']
|
||||
except Exception as e:
|
||||
Console.error(f'[ ERROR ] [ {__name__} ]: Reading error in {self.__name__} settings')
|
||||
Console.error(f'[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}')
|
||||
""")
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def path(self) -> str:
|
||||
return self._path
|
||||
|
||||
@property
|
||||
def value(self) -> str:
|
||||
return Template(self._value).substitute(
|
||||
Name=self._class_name
|
||||
)
|
37
src/cpl_cli/_templates/generate/enum_template.py
Normal file
37
src/cpl_cli/_templates/generate/enum_template.py
Normal file
@@ -0,0 +1,37 @@
|
||||
import textwrap
|
||||
from string import Template
|
||||
|
||||
from cpl.utils.string import String
|
||||
from cpl_cli._templates.template_file_abc import TemplateFileABC
|
||||
|
||||
|
||||
class EnumTemplate(TemplateFileABC):
|
||||
|
||||
def __init__(self, name: str, schematic: str, schematic_upper: str, path: str):
|
||||
TemplateFileABC.__init__(self)
|
||||
|
||||
self._name = f'{String.convert_to_snake_case(name)}_{schematic}.py'
|
||||
self._class_name = f'{String.first_to_upper(name)}{schematic_upper}'
|
||||
self._path = path
|
||||
self._value = textwrap.dedent("""\
|
||||
from enum import Enum
|
||||
|
||||
|
||||
class $Name(Enum):
|
||||
|
||||
atr = 0
|
||||
""")
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def path(self) -> str:
|
||||
return self._path
|
||||
|
||||
@property
|
||||
def value(self) -> str:
|
||||
return Template(self._value).substitute(
|
||||
Name=self._class_name
|
||||
)
|
32
src/cpl_cli/_templates/generate/init_template.py
Normal file
32
src/cpl_cli/_templates/generate/init_template.py
Normal file
@@ -0,0 +1,32 @@
|
||||
import textwrap
|
||||
from string import Template
|
||||
|
||||
from cpl.utils.string import String
|
||||
from cpl_cli._templates.template_file_abc import TemplateFileABC
|
||||
|
||||
|
||||
class InitTemplate(TemplateFileABC):
|
||||
|
||||
def __init__(self, name: str, schematic: str, schematic_upper: str, path: str):
|
||||
TemplateFileABC.__init__(self)
|
||||
|
||||
self._name = f'__init__.py'
|
||||
self._class_name = f'{String.first_to_upper(name)}{schematic_upper}'
|
||||
self._path = path
|
||||
self._value = textwrap.dedent("""\
|
||||
# imports
|
||||
""")
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def path(self) -> str:
|
||||
return self._path
|
||||
|
||||
@property
|
||||
def value(self) -> str:
|
||||
return Template(self._value).substitute(
|
||||
Name=self._class_name
|
||||
)
|
35
src/cpl_cli/_templates/generate/service_template.py
Normal file
35
src/cpl_cli/_templates/generate/service_template.py
Normal file
@@ -0,0 +1,35 @@
|
||||
import textwrap
|
||||
from string import Template
|
||||
|
||||
from cpl.utils.string import String
|
||||
from cpl_cli._templates.template_file_abc import TemplateFileABC
|
||||
|
||||
|
||||
class ServiceTemplate(TemplateFileABC):
|
||||
|
||||
def __init__(self, name: str, schematic: str, schematic_upper: str, path: str):
|
||||
TemplateFileABC.__init__(self)
|
||||
|
||||
self._name = f'{String.convert_to_snake_case(name)}_{schematic}.py'
|
||||
self._class_name = f'{String.first_to_upper(name)}{schematic_upper}'
|
||||
self._path = path
|
||||
self._value = textwrap.dedent("""\
|
||||
class $Name:
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
""")
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def path(self) -> str:
|
||||
return self._path
|
||||
|
||||
@property
|
||||
def value(self) -> str:
|
||||
return Template(self._value).substitute(
|
||||
Name=self._class_name
|
||||
)
|
41
src/cpl_cli/_templates/generate/thread_template.py
Normal file
41
src/cpl_cli/_templates/generate/thread_template.py
Normal file
@@ -0,0 +1,41 @@
|
||||
import textwrap
|
||||
from string import Template
|
||||
|
||||
from cpl.utils.string import String
|
||||
from cpl_cli._templates.template_file_abc import TemplateFileABC
|
||||
|
||||
|
||||
class ThreadTemplate(TemplateFileABC):
|
||||
|
||||
def __init__(self, name: str, schematic: str, schematic_upper: str, path: str):
|
||||
TemplateFileABC.__init__(self)
|
||||
|
||||
self._name = f'{String.convert_to_snake_case(name)}_{schematic}.py'
|
||||
self._class_name = f'{String.first_to_upper(name)}{schematic_upper}'
|
||||
self._path = path
|
||||
self._value = textwrap.dedent("""\
|
||||
import threading
|
||||
|
||||
|
||||
class $Name(threading.Thread):
|
||||
|
||||
def __init__(self):
|
||||
threading.Thread.__init__(self)
|
||||
|
||||
def run(self) -> None:
|
||||
pass
|
||||
""")
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def path(self) -> str:
|
||||
return self._path
|
||||
|
||||
@property
|
||||
def value(self) -> str:
|
||||
return Template(self._value).substitute(
|
||||
Name=self._class_name
|
||||
)
|
25
src/cpl_cli/_templates/new/__init__.py
Normal file
25
src/cpl_cli/_templates/new/__init__.py
Normal file
@@ -0,0 +1,25 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
sh_cpl-cli sh-edraft Common Python library CLI
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
sh-edraft Common Python library Command Line Interface
|
||||
|
||||
:copyright: (c) 2020 - 2021 sh-edraft.de
|
||||
:license: MIT, see LICENSE for more details.
|
||||
|
||||
"""
|
||||
|
||||
__title__ = 'cpl_cli._templates.new'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||
__version__ = '2021.4'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='2021', minor='4', micro='None')
|
25
src/cpl_cli/_templates/new/console/__init__.py
Normal file
25
src/cpl_cli/_templates/new/console/__init__.py
Normal file
@@ -0,0 +1,25 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
sh_cpl-cli sh-edraft Common Python library CLI
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
sh-edraft Common Python library Command Line Interface
|
||||
|
||||
:copyright: (c) 2020 - 2021 sh-edraft.de
|
||||
:license: MIT, see LICENSE for more details.
|
||||
|
||||
"""
|
||||
|
||||
__title__ = 'cpl_cli._templates.new.console'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||
__version__ = '2021.4'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='2021', minor='4', micro='None')
|
41
src/cpl_cli/_templates/new/console/appsettings_json.py
Normal file
41
src/cpl_cli/_templates/new/console/appsettings_json.py
Normal file
@@ -0,0 +1,41 @@
|
||||
import textwrap
|
||||
|
||||
from cpl_cli._templates.template_file_abc import TemplateFileABC
|
||||
|
||||
|
||||
class AppsettingsTemplate(TemplateFileABC):
|
||||
|
||||
def __init__(self):
|
||||
TemplateFileABC.__init__(self)
|
||||
|
||||
self._name = 'appsettings.json'
|
||||
self._path = ''
|
||||
self._value = textwrap.dedent("""\
|
||||
{
|
||||
"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"
|
||||
}
|
||||
}
|
||||
""")
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def path(self) -> str:
|
||||
return self._path
|
||||
|
||||
@property
|
||||
def value(self) -> str:
|
||||
return self._value
|
23
src/cpl_cli/_templates/new/console/license.py
Normal file
23
src/cpl_cli/_templates/new/console/license.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from cpl_cli._templates.template_file_abc import TemplateFileABC
|
||||
|
||||
|
||||
class LicenseTemplate(TemplateFileABC):
|
||||
|
||||
def __init__(self):
|
||||
TemplateFileABC.__init__(self)
|
||||
|
||||
self._name = 'LICENSE'
|
||||
self._path = ''
|
||||
self._value = """"""
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def path(self) -> str:
|
||||
return self._path
|
||||
|
||||
@property
|
||||
def value(self) -> str:
|
||||
return self._value
|
23
src/cpl_cli/_templates/new/console/readme_py.py
Normal file
23
src/cpl_cli/_templates/new/console/readme_py.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from cpl_cli._templates.template_file_abc import TemplateFileABC
|
||||
|
||||
|
||||
class ReadmeTemplate(TemplateFileABC):
|
||||
|
||||
def __init__(self):
|
||||
TemplateFileABC.__init__(self)
|
||||
|
||||
self._name = 'README.md'
|
||||
self._path = ''
|
||||
self._value = """"""
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def path(self) -> str:
|
||||
return self._path
|
||||
|
||||
@property
|
||||
def value(self) -> str:
|
||||
return self._value
|
25
src/cpl_cli/_templates/new/console/source/__init__.py
Normal file
25
src/cpl_cli/_templates/new/console/source/__init__.py
Normal file
@@ -0,0 +1,25 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
sh_cpl-cli sh-edraft Common Python library CLI
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
sh-edraft Common Python library Command Line Interface
|
||||
|
||||
:copyright: (c) 2020 - 2021 sh-edraft.de
|
||||
:license: MIT, see LICENSE for more details.
|
||||
|
||||
"""
|
||||
|
||||
__title__ = 'cpl_cli._templates.new.console.source'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||
__version__ = '2021.4'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='2021', minor='4', micro='None')
|
25
src/cpl_cli/_templates/new/console/source/name/__init__.py
Normal file
25
src/cpl_cli/_templates/new/console/source/name/__init__.py
Normal file
@@ -0,0 +1,25 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
sh_cpl-cli sh-edraft Common Python library CLI
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
sh-edraft Common Python library Command Line Interface
|
||||
|
||||
:copyright: (c) 2020 - 2021 sh-edraft.de
|
||||
:license: MIT, see LICENSE for more details.
|
||||
|
||||
"""
|
||||
|
||||
__title__ = 'cpl_cli._templates.new.console.source.name'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||
__version__ = '2021.4'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='2021', minor='4', micro='None')
|
@@ -0,0 +1,45 @@
|
||||
import os.path
|
||||
import textwrap
|
||||
|
||||
from cpl.utils.string import String
|
||||
from cpl_cli._templates.template_file_abc import TemplateFileABC
|
||||
|
||||
|
||||
class ApplicationTemplate(TemplateFileABC):
|
||||
|
||||
def __init__(self, name: str, path: str):
|
||||
TemplateFileABC.__init__(self)
|
||||
|
||||
name = String.convert_to_snake_case(name)
|
||||
self._name = 'application.py'
|
||||
self._path = os.path.join(path, name)
|
||||
self._value = textwrap.dedent("""\
|
||||
from cpl.application import ApplicationABC
|
||||
from cpl.configuration import ConfigurationABC
|
||||
from cpl.console import Console
|
||||
from cpl.dependency_injection import ServiceProviderABC
|
||||
|
||||
|
||||
class Application(ApplicationABC):
|
||||
|
||||
def __init__(self, config: ConfigurationABC, services: ServiceProviderABC):
|
||||
ApplicationABC.__init__(self, config, services)
|
||||
|
||||
def configure(self):
|
||||
pass
|
||||
|
||||
def main(self):
|
||||
Console.write_line('Hello World')
|
||||
""")
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def path(self) -> str:
|
||||
return self._path
|
||||
|
||||
@property
|
||||
def value(self) -> str:
|
||||
return self._value
|
30
src/cpl_cli/_templates/new/console/source/name/init.py
Normal file
30
src/cpl_cli/_templates/new/console/source/name/init.py
Normal file
@@ -0,0 +1,30 @@
|
||||
import os.path
|
||||
import textwrap
|
||||
|
||||
from cpl.utils.string import String
|
||||
from cpl_cli._templates.template_file_abc import TemplateFileABC
|
||||
|
||||
|
||||
class MainInitTemplate(TemplateFileABC):
|
||||
|
||||
def __init__(self, name: str, path: str):
|
||||
TemplateFileABC.__init__(self)
|
||||
|
||||
name = String.convert_to_snake_case(name)
|
||||
self._name = '__init__.py'
|
||||
self._path = os.path.join(path, name)
|
||||
self._value = textwrap.dedent("""\
|
||||
# imports:
|
||||
""")
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def path(self) -> str:
|
||||
return self._path
|
||||
|
||||
@property
|
||||
def value(self) -> str:
|
||||
return self._value
|
179
src/cpl_cli/_templates/new/console/source/name/main.py
Normal file
179
src/cpl_cli/_templates/new/console/source/name/main.py
Normal file
@@ -0,0 +1,179 @@
|
||||
import os.path
|
||||
import textwrap
|
||||
|
||||
from cpl.utils.string import String
|
||||
from cpl_cli._templates.template_file_abc import TemplateFileABC
|
||||
|
||||
|
||||
class MainWithApplicationHostAndStartupTemplate(TemplateFileABC):
|
||||
|
||||
def __init__(self, name: str, path: str):
|
||||
TemplateFileABC.__init__(self)
|
||||
|
||||
name = String.convert_to_snake_case(name)
|
||||
self._name = 'main.py'
|
||||
self._path = os.path.join(path, name)
|
||||
|
||||
import_pkg = f'{name}.'
|
||||
if name == '':
|
||||
import_pkg = ''
|
||||
|
||||
self._value = textwrap.dedent(f"""\
|
||||
from cpl.application import ApplicationBuilder
|
||||
|
||||
from {import_pkg}application import Application
|
||||
from {import_pkg}startup import Startup
|
||||
|
||||
|
||||
def main():
|
||||
app_builder = ApplicationBuilder(Application)
|
||||
app_builder.use_startup(Startup)
|
||||
app_builder.build().run()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
""")
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def path(self) -> str:
|
||||
return self._path
|
||||
|
||||
@property
|
||||
def value(self) -> str:
|
||||
return self._value
|
||||
|
||||
|
||||
class MainWithApplicationBaseTemplate(TemplateFileABC):
|
||||
|
||||
def __init__(self, name: str, path: str):
|
||||
TemplateFileABC.__init__(self)
|
||||
|
||||
name = String.convert_to_snake_case(name)
|
||||
self._name = 'main.py'
|
||||
self._path = os.path.join(path, name)
|
||||
|
||||
import_pkg = f'{name}.'
|
||||
if name == '':
|
||||
import_pkg = ''
|
||||
|
||||
self._value = textwrap.dedent(f"""\
|
||||
from cpl.application import ApplicationBuilder
|
||||
|
||||
from {import_pkg}application import Application
|
||||
|
||||
|
||||
def main():
|
||||
app_builder = ApplicationBuilder(Application)
|
||||
app_builder.build().run()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
""")
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def path(self) -> str:
|
||||
return self._path
|
||||
|
||||
@property
|
||||
def value(self) -> str:
|
||||
return self._value
|
||||
|
||||
|
||||
class MainWithoutApplicationBaseTemplate(TemplateFileABC):
|
||||
|
||||
def __init__(self, name: str, path: str):
|
||||
TemplateFileABC.__init__(self)
|
||||
|
||||
name = String.convert_to_snake_case(name)
|
||||
self._name = 'main.py'
|
||||
self._path = os.path.join(path, name)
|
||||
|
||||
import_pkg = f'{name}.'
|
||||
if name == '':
|
||||
import_pkg = ''
|
||||
|
||||
self._value = textwrap.dedent("""\
|
||||
from cpl.console import Console
|
||||
|
||||
|
||||
def main():
|
||||
Console.write_line('Hello World')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
""")
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def path(self) -> str:
|
||||
return self._path
|
||||
|
||||
@property
|
||||
def value(self) -> str:
|
||||
return self._value
|
||||
|
||||
|
||||
class MainWithDependencyInjection(TemplateFileABC):
|
||||
|
||||
def __init__(self, name: str, path: str):
|
||||
TemplateFileABC.__init__(self)
|
||||
|
||||
name = String.convert_to_snake_case(name)
|
||||
self._name = 'main.py'
|
||||
self._path = os.path.join(path, name)
|
||||
|
||||
import_pkg = f'{name}.'
|
||||
if name == '':
|
||||
import_pkg = ''
|
||||
|
||||
self._value = textwrap.dedent("""\
|
||||
from cpl.configuration import Configuration, ConfigurationABC
|
||||
from cpl.console import Console
|
||||
from cpl.dependency_injection import ServiceCollection, ServiceProviderABC
|
||||
|
||||
|
||||
def configure_configuration() -> ConfigurationABC:
|
||||
config = Configuration()
|
||||
return config
|
||||
|
||||
|
||||
def configure_services(config: ConfigurationABC) -> ServiceProviderABC:
|
||||
services = ServiceCollection(config)
|
||||
return services.build_service_provider()
|
||||
|
||||
|
||||
def main():
|
||||
config = configure_configuration()
|
||||
provider = configure_services(config)
|
||||
Console.write_line('Hello World')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
""")
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def path(self) -> str:
|
||||
return self._path
|
||||
|
||||
@property
|
||||
def value(self) -> str:
|
||||
return self._value
|
48
src/cpl_cli/_templates/new/console/source/name/startup.py
Normal file
48
src/cpl_cli/_templates/new/console/source/name/startup.py
Normal file
@@ -0,0 +1,48 @@
|
||||
import os.path
|
||||
import textwrap
|
||||
|
||||
from cpl.utils.string import String
|
||||
from cpl_cli._templates.template_file_abc import TemplateFileABC
|
||||
|
||||
|
||||
class StartupTemplate(TemplateFileABC):
|
||||
|
||||
def __init__(self, name: str, path: str):
|
||||
TemplateFileABC.__init__(self)
|
||||
|
||||
name = String.convert_to_snake_case(name)
|
||||
self._name = 'startup.py'
|
||||
self._path = os.path.join(path, name)
|
||||
self._value = textwrap.dedent("""\
|
||||
from cpl.application import StartupABC
|
||||
from cpl.configuration import ConfigurationABC
|
||||
from cpl.dependency_injection import ServiceProviderABC, ServiceCollectionABC
|
||||
|
||||
|
||||
class Startup(StartupABC):
|
||||
|
||||
def __init__(self, config: ConfigurationABC, services: ServiceCollectionABC):
|
||||
StartupABC.__init__(self)
|
||||
|
||||
self._configuration = config
|
||||
self._environment = self._configuration.environment
|
||||
self._services = services
|
||||
|
||||
def configure_configuration(self) -> ConfigurationABC:
|
||||
return self._configuration
|
||||
|
||||
def configure_services(self) -> ServiceProviderABC:
|
||||
return self._services.build_service_provider()
|
||||
""")
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def path(self) -> str:
|
||||
return self._path
|
||||
|
||||
@property
|
||||
def value(self) -> str:
|
||||
return self._value
|
25
src/cpl_cli/_templates/new/console/source/tests/__init__.py
Normal file
25
src/cpl_cli/_templates/new/console/source/tests/__init__.py
Normal file
@@ -0,0 +1,25 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
sh_cpl-cli sh-edraft Common Python library CLI
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
sh-edraft Common Python library Command Line Interface
|
||||
|
||||
:copyright: (c) 2020 - 2021 sh-edraft.de
|
||||
:license: MIT, see LICENSE for more details.
|
||||
|
||||
"""
|
||||
|
||||
__title__ = 'cpl_cli.templates.new.console.source.tests'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||
__version__ = '2021.4'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='2021', minor='4', micro='None')
|
27
src/cpl_cli/_templates/new/console/source/tests/init.py
Normal file
27
src/cpl_cli/_templates/new/console/source/tests/init.py
Normal file
@@ -0,0 +1,27 @@
|
||||
import textwrap
|
||||
|
||||
from cpl_cli._templates.template_file_abc import TemplateFileABC
|
||||
|
||||
|
||||
class TestsInitTemplate(TemplateFileABC):
|
||||
|
||||
def __init__(self):
|
||||
TemplateFileABC.__init__(self)
|
||||
|
||||
self._name = '__init__.py'
|
||||
self._path = 'src/tests/'
|
||||
self._value = textwrap.dedent("""\
|
||||
# imports:
|
||||
""")
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def path(self) -> str:
|
||||
return self._path
|
||||
|
||||
@property
|
||||
def value(self) -> str:
|
||||
return self._value
|
25
src/cpl_cli/_templates/new/library/__init__.py
Normal file
25
src/cpl_cli/_templates/new/library/__init__.py
Normal file
@@ -0,0 +1,25 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
sh_cpl-cli sh-edraft Common Python library CLI
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
sh-edraft Common Python library Command Line Interface
|
||||
|
||||
:copyright: (c) 2020 - 2021 sh-edraft.de
|
||||
:license: MIT, see LICENSE for more details.
|
||||
|
||||
"""
|
||||
|
||||
__title__ = 'cpl_cli._templates.new.library'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||
__version__ = '2021.4'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='2021', minor='4', micro='None')
|
41
src/cpl_cli/_templates/new/library/appsettings_json.py
Normal file
41
src/cpl_cli/_templates/new/library/appsettings_json.py
Normal file
@@ -0,0 +1,41 @@
|
||||
import textwrap
|
||||
|
||||
from cpl_cli._templates.template_file_abc import TemplateFileABC
|
||||
|
||||
|
||||
class AppsettingsTemplate(TemplateFileABC):
|
||||
|
||||
def __init__(self):
|
||||
TemplateFileABC.__init__(self)
|
||||
|
||||
self._name = 'appsettings.json'
|
||||
self._path = ''
|
||||
self._value = textwrap.dedent("""\
|
||||
{
|
||||
"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"
|
||||
}
|
||||
}
|
||||
""")
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def path(self) -> str:
|
||||
return self._path
|
||||
|
||||
@property
|
||||
def value(self) -> str:
|
||||
return self._value
|
23
src/cpl_cli/_templates/new/library/license.py
Normal file
23
src/cpl_cli/_templates/new/library/license.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from cpl_cli._templates.template_file_abc import TemplateFileABC
|
||||
|
||||
|
||||
class LicenseTemplate(TemplateFileABC):
|
||||
|
||||
def __init__(self):
|
||||
TemplateFileABC.__init__(self)
|
||||
|
||||
self._name = 'LICENSE'
|
||||
self._path = ''
|
||||
self._value = """"""
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def path(self) -> str:
|
||||
return self._path
|
||||
|
||||
@property
|
||||
def value(self) -> str:
|
||||
return self._value
|
23
src/cpl_cli/_templates/new/library/readme_py.py
Normal file
23
src/cpl_cli/_templates/new/library/readme_py.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from cpl_cli._templates.template_file_abc import TemplateFileABC
|
||||
|
||||
|
||||
class ReadmeTemplate(TemplateFileABC):
|
||||
|
||||
def __init__(self):
|
||||
TemplateFileABC.__init__(self)
|
||||
|
||||
self._name = 'README.md'
|
||||
self._path = ''
|
||||
self._value = """"""
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def path(self) -> str:
|
||||
return self._path
|
||||
|
||||
@property
|
||||
def value(self) -> str:
|
||||
return self._value
|
25
src/cpl_cli/_templates/new/library/source/__init__.py
Normal file
25
src/cpl_cli/_templates/new/library/source/__init__.py
Normal file
@@ -0,0 +1,25 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
sh_cpl-cli sh-edraft Common Python library CLI
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
sh-edraft Common Python library Command Line Interface
|
||||
|
||||
:copyright: (c) 2020 - 2021 sh-edraft.de
|
||||
:license: MIT, see LICENSE for more details.
|
||||
|
||||
"""
|
||||
|
||||
__title__ = 'cpl_cli._templates.new.library.source'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||
__version__ = '2021.4'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='2021', minor='4', micro='None')
|
25
src/cpl_cli/_templates/new/library/source/name/__init__.py
Normal file
25
src/cpl_cli/_templates/new/library/source/name/__init__.py
Normal file
@@ -0,0 +1,25 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
sh_cpl-cli sh-edraft Common Python library CLI
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
sh-edraft Common Python library Command Line Interface
|
||||
|
||||
:copyright: (c) 2020 - 2021 sh-edraft.de
|
||||
:license: MIT, see LICENSE for more details.
|
||||
|
||||
"""
|
||||
|
||||
__title__ = 'cpl_cli._templates.new.library.source.name'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||
__version__ = '2021.4'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='2021', minor='4', micro='None')
|
@@ -0,0 +1,45 @@
|
||||
import os
|
||||
import textwrap
|
||||
|
||||
from cpl.utils.string import String
|
||||
from cpl_cli._templates.template_file_abc import TemplateFileABC
|
||||
|
||||
|
||||
class ApplicationTemplate(TemplateFileABC):
|
||||
|
||||
def __init__(self, name: str, path: str):
|
||||
TemplateFileABC.__init__(self)
|
||||
|
||||
name = String.convert_to_snake_case(name)
|
||||
self._name = 'application.py'
|
||||
self._path = os.path.join(path, name)
|
||||
self._value = textwrap.dedent("""\
|
||||
from cpl.application import ApplicationABC
|
||||
from cpl.configuration import ConfigurationABC
|
||||
from cpl.console import Console
|
||||
from cpl.dependency_injection import ServiceProviderABC
|
||||
|
||||
|
||||
class Application(ApplicationABC):
|
||||
|
||||
def __init__(self, config: ConfigurationABC, services: ServiceProviderABC):
|
||||
ApplicationABC.__init__(self, config, services)
|
||||
|
||||
def configure(self):
|
||||
pass
|
||||
|
||||
def main(self):
|
||||
Console.write_line('Hello World')
|
||||
""")
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def path(self) -> str:
|
||||
return self._path
|
||||
|
||||
@property
|
||||
def value(self) -> str:
|
||||
return self._value
|
30
src/cpl_cli/_templates/new/library/source/name/init.py
Normal file
30
src/cpl_cli/_templates/new/library/source/name/init.py
Normal file
@@ -0,0 +1,30 @@
|
||||
import os
|
||||
import textwrap
|
||||
|
||||
from cpl.utils.string import String
|
||||
from cpl_cli._templates.template_file_abc import TemplateFileABC
|
||||
|
||||
|
||||
class NameInitTemplate(TemplateFileABC):
|
||||
|
||||
def __init__(self, name: str, path: str):
|
||||
TemplateFileABC.__init__(self)
|
||||
|
||||
name = String.convert_to_snake_case(name)
|
||||
self._name = '__init__.py'
|
||||
self._path = os.path.join(path, name)
|
||||
self._value = textwrap.dedent("""\
|
||||
# imports:
|
||||
""")
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def path(self) -> str:
|
||||
return self._path
|
||||
|
||||
@property
|
||||
def value(self) -> str:
|
||||
return self._value
|
177
src/cpl_cli/_templates/new/library/source/name/main.py
Normal file
177
src/cpl_cli/_templates/new/library/source/name/main.py
Normal file
@@ -0,0 +1,177 @@
|
||||
import os.path
|
||||
import textwrap
|
||||
|
||||
from cpl.utils.string import String
|
||||
from cpl_cli._templates.template_file_abc import TemplateFileABC
|
||||
|
||||
|
||||
class MainWithApplicationHostAndStartupTemplate(TemplateFileABC):
|
||||
|
||||
def __init__(self, name: str, path: str):
|
||||
TemplateFileABC.__init__(self)
|
||||
|
||||
name = String.convert_to_snake_case(name)
|
||||
self._name = 'main.py'
|
||||
self._path = os.path.join(path, name)
|
||||
|
||||
import_pkg = f'{name}.'
|
||||
if name == '':
|
||||
import_pkg = ''
|
||||
|
||||
self._value = textwrap.dedent(f"""\
|
||||
from cpl.application import ApplicationBuilder
|
||||
|
||||
from {import_pkg}application import Application
|
||||
from {import_pkg}startup import Startup
|
||||
|
||||
|
||||
def main():
|
||||
app_builder = ApplicationBuilder(Application)
|
||||
app_builder.use_startup(Startup)
|
||||
app_builder.build().run()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
""")
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def path(self) -> str:
|
||||
return self._path
|
||||
|
||||
@property
|
||||
def value(self) -> str:
|
||||
return self._value
|
||||
|
||||
|
||||
class MainWithApplicationBaseTemplate(TemplateFileABC):
|
||||
|
||||
def __init__(self, name: str, path: str):
|
||||
TemplateFileABC.__init__(self)
|
||||
|
||||
name = String.convert_to_snake_case(name)
|
||||
self._name = 'main.py'
|
||||
self._path = os.path.join(path, name)
|
||||
|
||||
import_pkg = f'{name}.'
|
||||
if name == '':
|
||||
import_pkg = ''
|
||||
|
||||
self._value = textwrap.dedent(f"""\
|
||||
from cpl.application import ApplicationBuilder
|
||||
|
||||
from {import_pkg}application import Application
|
||||
|
||||
|
||||
def main():
|
||||
app_builder = ApplicationBuilder(Application)
|
||||
app_builder.build().run()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
""")
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def path(self) -> str:
|
||||
return self._path
|
||||
|
||||
@property
|
||||
def value(self) -> str:
|
||||
return self._value
|
||||
|
||||
|
||||
class MainWithoutApplicationBaseTemplate(TemplateFileABC):
|
||||
|
||||
def __init__(self, name: str, path: str):
|
||||
TemplateFileABC.__init__(self)
|
||||
|
||||
self._name = 'main.py'
|
||||
self._path = os.path.join(path, name)
|
||||
|
||||
import_pkg = f'{name}.'
|
||||
if name == '':
|
||||
import_pkg = ''
|
||||
|
||||
self._value = textwrap.dedent("""\
|
||||
from cpl.console import Console
|
||||
|
||||
|
||||
def main():
|
||||
Console.write_line('Hello World')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
""")
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def path(self) -> str:
|
||||
return self._path
|
||||
|
||||
@property
|
||||
def value(self) -> str:
|
||||
return self._value
|
||||
|
||||
|
||||
class MainWithDependencyInjection(TemplateFileABC):
|
||||
|
||||
def __init__(self, name: str, path: str):
|
||||
TemplateFileABC.__init__(self)
|
||||
|
||||
self._name = 'main.py'
|
||||
self._path = os.path.join(path, name)
|
||||
|
||||
import_pkg = f'{name}.'
|
||||
if name == '':
|
||||
import_pkg = ''
|
||||
|
||||
self._value = textwrap.dedent("""\
|
||||
from cpl.configuration import Configuration, ConfigurationABC
|
||||
from cpl.console import Console
|
||||
from cpl.dependency_injection import ServiceCollection, ServiceProviderABC
|
||||
|
||||
|
||||
def configure_configuration() -> ConfigurationABC:
|
||||
config = Configuration()
|
||||
return config
|
||||
|
||||
|
||||
def configure_services(config: ConfigurationABC) -> ServiceProviderABC:
|
||||
services = ServiceCollection(config)
|
||||
return services.build_service_provider()
|
||||
|
||||
|
||||
def main():
|
||||
config = configure_configuration()
|
||||
provider = configure_services(config)
|
||||
Console.write_line('Hello World')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
""")
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def path(self) -> str:
|
||||
return self._path
|
||||
|
||||
@property
|
||||
def value(self) -> str:
|
||||
return self._value
|
48
src/cpl_cli/_templates/new/library/source/name/startup.py
Normal file
48
src/cpl_cli/_templates/new/library/source/name/startup.py
Normal file
@@ -0,0 +1,48 @@
|
||||
import os
|
||||
import textwrap
|
||||
|
||||
from cpl.utils.string import String
|
||||
from cpl_cli._templates.template_file_abc import TemplateFileABC
|
||||
|
||||
|
||||
class StartupTemplate(TemplateFileABC):
|
||||
|
||||
def __init__(self, name: str, path: str):
|
||||
TemplateFileABC.__init__(self)
|
||||
|
||||
name = String.convert_to_snake_case(name)
|
||||
self._name = 'startup.py'
|
||||
self._path = os.path.join(path, name)
|
||||
self._value = textwrap.dedent("""\
|
||||
from cpl.application import StartupABC
|
||||
from cpl.configuration import ConfigurationABC
|
||||
from cpl.dependency_injection import ServiceProviderABC, ServiceCollectionABC
|
||||
|
||||
|
||||
class Startup(StartupABC):
|
||||
|
||||
def __init__(self, config: ConfigurationABC, services: ServiceCollectionABC):
|
||||
StartupABC.__init__(self)
|
||||
|
||||
self._configuration = config
|
||||
self._environment = self._configuration.environment
|
||||
self._services = services
|
||||
|
||||
def configure_configuration(self) -> ConfigurationABC:
|
||||
return self._configuration
|
||||
|
||||
def configure_services(self) -> ServiceProviderABC:
|
||||
return self._services.build_service_provider()
|
||||
""")
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def path(self) -> str:
|
||||
return self._path
|
||||
|
||||
@property
|
||||
def value(self) -> str:
|
||||
return self._value
|
25
src/cpl_cli/_templates/new/library/source/tests/__init__.py
Normal file
25
src/cpl_cli/_templates/new/library/source/tests/__init__.py
Normal file
@@ -0,0 +1,25 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
sh_cpl-cli sh-edraft Common Python library CLI
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
sh-edraft Common Python library Command Line Interface
|
||||
|
||||
:copyright: (c) 2020 - 2021 sh-edraft.de
|
||||
:license: MIT, see LICENSE for more details.
|
||||
|
||||
"""
|
||||
|
||||
__title__ = 'cpl_cli.templates.new.library.source.tests'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||
__version__ = '2021.4'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='2021', minor='4', micro='None')
|
27
src/cpl_cli/_templates/new/library/source/tests/init.py
Normal file
27
src/cpl_cli/_templates/new/library/source/tests/init.py
Normal file
@@ -0,0 +1,27 @@
|
||||
import textwrap
|
||||
|
||||
from cpl_cli._templates.template_file_abc import TemplateFileABC
|
||||
|
||||
|
||||
class TestsInitTemplate(TemplateFileABC):
|
||||
|
||||
def __init__(self):
|
||||
TemplateFileABC.__init__(self)
|
||||
|
||||
self._name = '__init__.py'
|
||||
self._path = 'src/tests/'
|
||||
self._value = textwrap.dedent("""\
|
||||
# imports:
|
||||
""")
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def path(self) -> str:
|
||||
return self._path
|
||||
|
||||
@property
|
||||
def value(self) -> str:
|
||||
return self._value
|
25
src/cpl_cli/_templates/publish/__init__.py
Normal file
25
src/cpl_cli/_templates/publish/__init__.py
Normal file
@@ -0,0 +1,25 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
sh_cpl-cli sh-edraft Common Python library CLI
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
sh-edraft Common Python library Command Line Interface
|
||||
|
||||
:copyright: (c) 2020 - 2021 sh-edraft.de
|
||||
:license: MIT, see LICENSE for more details.
|
||||
|
||||
"""
|
||||
|
||||
__title__ = 'cpl_cli._templates.publish'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||
__version__ = '2021.4'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='2021', minor='4', micro='None')
|
32
src/cpl_cli/_templates/publish/setup_template.py
Normal file
32
src/cpl_cli/_templates/publish/setup_template.py
Normal file
@@ -0,0 +1,32 @@
|
||||
import textwrap
|
||||
|
||||
|
||||
class SetupTemplate:
|
||||
|
||||
@staticmethod
|
||||
def get_setup_py() -> str:
|
||||
string = textwrap.dedent("""\
|
||||
\"\"\"
|
||||
This file is generated by CPL CLI
|
||||
\"\"\"
|
||||
|
||||
import setuptools
|
||||
|
||||
setuptools.setup(
|
||||
name='$Name',
|
||||
version='$Version',
|
||||
packages=$Packages,
|
||||
url='$URL',
|
||||
license='$LicenseName',
|
||||
author='$Author',
|
||||
author_email='$AuthorMail',
|
||||
include_package_data=$IncludePackageData,
|
||||
description='$Description',
|
||||
python_requires='$PyRequires',
|
||||
install_requires=$Dependencies,
|
||||
entry_points=$EntryPoints,
|
||||
package_data=$PackageData
|
||||
)
|
||||
""")
|
||||
|
||||
return string
|
19
src/cpl_cli/_templates/template_file_abc.py
Normal file
19
src/cpl_cli/_templates/template_file_abc.py
Normal file
@@ -0,0 +1,19 @@
|
||||
from abc import ABC, abstractmethod
|
||||
|
||||
|
||||
class TemplateFileABC(ABC):
|
||||
|
||||
@abstractmethod
|
||||
def __init__(self): pass
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def name(self) -> str: pass
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def path(self) -> str: pass
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def value(self) -> str: pass
|
Reference in New Issue
Block a user