Added publish logic
This commit is contained in:
25
src/cpl_cli/configuration/__init__.py
Normal file
25
src/cpl_cli/configuration/__init__.py
Normal file
@@ -0,0 +1,25 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
sh_cpl sh-edraft Common Python library
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
sh-edraft Common Python library
|
||||
|
||||
:copyright: (c) 2020 sh-edraft.de
|
||||
:license: MITMIT, see LICENSE for more details.
|
||||
|
||||
"""
|
||||
|
||||
__title__ = 'src.cpl_cli.configuration'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2020 sh-edraft.de'
|
||||
__version__ = '2021.4.1'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major=2021, minor=4, micro=1)
|
65
src/cpl_cli/configuration/build_settings.py
Normal file
65
src/cpl_cli/configuration/build_settings.py
Normal file
@@ -0,0 +1,65 @@
|
||||
import traceback
|
||||
from typing import Optional
|
||||
|
||||
from cpl.configuration.configuration_model_abc import ConfigurationModelABC
|
||||
from cpl.console.console import Console
|
||||
from cpl.console.foreground_color import ForegroundColor
|
||||
from cpl_cli.configuration.build_settings_name import BuildSettingsName
|
||||
|
||||
|
||||
class BuildSettings(ConfigurationModelABC):
|
||||
|
||||
def __init__(self):
|
||||
ConfigurationModelABC.__init__(self)
|
||||
|
||||
self._source_path: Optional[str] = None
|
||||
self._output_path: Optional[str] = None
|
||||
self._main: Optional[str] = None
|
||||
self._entry_point: Optional[str] = None
|
||||
self._include_package_data: Optional[bool] = None
|
||||
self._included: Optional[list[str]] = None
|
||||
self._excluded: Optional[list[str]] = None
|
||||
|
||||
@property
|
||||
def source_path(self) -> str:
|
||||
return self._source_path
|
||||
|
||||
@property
|
||||
def output_path(self) -> str:
|
||||
return self._output_path
|
||||
|
||||
@property
|
||||
def main(self) -> str:
|
||||
return self._main
|
||||
|
||||
@property
|
||||
def entry_point(self) -> str:
|
||||
return self._entry_point
|
||||
|
||||
@property
|
||||
def include_package_data(self) -> bool:
|
||||
return self._include_package_data
|
||||
|
||||
@property
|
||||
def included(self) -> list[str]:
|
||||
return self._included
|
||||
|
||||
@property
|
||||
def excluded(self) -> list[str]:
|
||||
return self._excluded
|
||||
|
||||
def from_dict(self, settings: dict):
|
||||
try:
|
||||
self._source_path = settings[BuildSettingsName.sourcePath.value]
|
||||
self._output_path = settings[BuildSettingsName.outputPath.value]
|
||||
self._include_package_data = bool(settings[BuildSettingsName.include_package_data.value])
|
||||
self._main = settings[BuildSettingsName.main.value]
|
||||
self._entry_point = settings[BuildSettingsName.entry_point.value]
|
||||
self._included = settings[BuildSettingsName.included.value]
|
||||
self._excluded = settings[BuildSettingsName.excluded.value]
|
||||
except Exception as e:
|
||||
Console.set_foreground_color(ForegroundColor.red)
|
||||
Console.write_line(
|
||||
f'[ ERROR ] [ {__name__} ]: Reading error in {BuildSettings.__name__} settings')
|
||||
Console.write_line(f'[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}')
|
||||
Console.set_foreground_color(ForegroundColor.default)
|
12
src/cpl_cli/configuration/build_settings_name.py
Normal file
12
src/cpl_cli/configuration/build_settings_name.py
Normal file
@@ -0,0 +1,12 @@
|
||||
from enum import Enum
|
||||
|
||||
|
||||
class BuildSettingsName(Enum):
|
||||
|
||||
sourcePath = 'sourcePath'
|
||||
outputPath = 'outputPath'
|
||||
main = 'main'
|
||||
entry_point = 'entryPoint'
|
||||
include_package_data = 'includePackageData'
|
||||
included = 'included'
|
||||
excluded = 'excluded'
|
102
src/cpl_cli/configuration/project_settings.py
Normal file
102
src/cpl_cli/configuration/project_settings.py
Normal file
@@ -0,0 +1,102 @@
|
||||
import traceback
|
||||
from typing import Optional
|
||||
|
||||
from cpl.configuration.configuration_model_abc import ConfigurationModelABC
|
||||
from cpl.console.console import Console
|
||||
from cpl.console.foreground_color import ForegroundColor
|
||||
from cpl_cli.configuration.version import Version
|
||||
from cpl_cli.configuration.project_settings_name import ProjectSettingsName
|
||||
|
||||
|
||||
class ProjectSettings(ConfigurationModelABC):
|
||||
|
||||
def __init__(self):
|
||||
ConfigurationModelABC.__init__(self)
|
||||
|
||||
self._name: Optional[str] = None
|
||||
self._version: Optional[Version] = Version()
|
||||
self._author: Optional[str] = None
|
||||
self._author_email: Optional[str] = None
|
||||
self._description: Optional[str] = None
|
||||
self._long_description: Optional[str] = None
|
||||
self._url: Optional[str] = None
|
||||
self._copyright_date: Optional[str] = None
|
||||
self._copyright_name: Optional[str] = None
|
||||
self._license_name: Optional[str] = None
|
||||
self._license_description: Optional[str] = None
|
||||
self._dependencies: Optional[list[str]] = None
|
||||
self._python_version: Optional[str] = None
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def version(self) -> Version:
|
||||
return self._version
|
||||
|
||||
@property
|
||||
def author(self) -> str:
|
||||
return self._author
|
||||
|
||||
@property
|
||||
def author_email(self) -> str:
|
||||
return self._author_email
|
||||
|
||||
@property
|
||||
def description(self) -> str:
|
||||
return self._description
|
||||
|
||||
@property
|
||||
def long_description(self) -> str:
|
||||
return self._long_description
|
||||
|
||||
@property
|
||||
def url(self) -> str:
|
||||
return self._url
|
||||
|
||||
@property
|
||||
def copyright_date(self) -> str:
|
||||
return self._copyright_date
|
||||
|
||||
@property
|
||||
def copyright_name(self) -> str:
|
||||
return self._copyright_name
|
||||
|
||||
@property
|
||||
def license_name(self) -> str:
|
||||
return self._license_name
|
||||
|
||||
@property
|
||||
def license_description(self) -> str:
|
||||
return self._license_description
|
||||
|
||||
@property
|
||||
def dependencies(self) -> list[str]:
|
||||
return self._dependencies
|
||||
|
||||
@property
|
||||
def python_version(self) -> str:
|
||||
return self._python_version
|
||||
|
||||
def from_dict(self, settings: dict):
|
||||
try:
|
||||
self._name = settings[ProjectSettingsName.name.value]
|
||||
self._version.from_dict(settings[ProjectSettingsName.version.value])
|
||||
self._author = settings[ProjectSettingsName.author.value]
|
||||
self._author_email = settings[ProjectSettingsName.author_email.value]
|
||||
self._description = settings[ProjectSettingsName.description.value]
|
||||
self._long_description = settings[ProjectSettingsName.long_description.value]
|
||||
self._url = settings[ProjectSettingsName.url.value]
|
||||
self._copyright_date = settings[ProjectSettingsName.copyright_date.value]
|
||||
self._copyright_name = settings[ProjectSettingsName.copyright_name.value]
|
||||
self._license_name = settings[ProjectSettingsName.license_name.value]
|
||||
self._license_description = settings[ProjectSettingsName.license_description.value]
|
||||
self._dependencies = settings[ProjectSettingsName.dependencies.value]
|
||||
self._python_version = settings[ProjectSettingsName.python_version.value]
|
||||
except Exception as e:
|
||||
Console.set_foreground_color(ForegroundColor.red)
|
||||
Console.write_line(
|
||||
f'[ ERROR ] [ {__name__} ]: Reading error in {ProjectSettings.__name__} settings')
|
||||
Console.write_line(f'[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}')
|
||||
Console.set_foreground_color(ForegroundColor.default)
|
18
src/cpl_cli/configuration/project_settings_name.py
Normal file
18
src/cpl_cli/configuration/project_settings_name.py
Normal file
@@ -0,0 +1,18 @@
|
||||
from enum import Enum
|
||||
|
||||
|
||||
class ProjectSettingsName(Enum):
|
||||
|
||||
name = 'name'
|
||||
version = 'version'
|
||||
author = 'author'
|
||||
author_email = 'authorEmail'
|
||||
description = 'description'
|
||||
long_description = 'longDescription'
|
||||
url = 'url'
|
||||
copyright_date = 'copyrightDate'
|
||||
copyright_name = 'copyrightName'
|
||||
license_name = 'licenseName'
|
||||
license_description = 'licenseDescription'
|
||||
dependencies = 'dependencies'
|
||||
python_version = 'pythonVersion'
|
46
src/cpl_cli/configuration/version.py
Normal file
46
src/cpl_cli/configuration/version.py
Normal file
@@ -0,0 +1,46 @@
|
||||
from typing import Optional
|
||||
|
||||
from cpl.configuration.configuration_model_abc import ConfigurationModelABC
|
||||
from cpl_cli.configuration.version_settings_name import VersionSettingsName
|
||||
|
||||
|
||||
class Version(ConfigurationModelABC):
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
major: int = None,
|
||||
minor: int = None,
|
||||
micro: float = None
|
||||
):
|
||||
ConfigurationModelABC.__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[VersionSettingsName.major.value])
|
||||
self._minor = int(settings[VersionSettingsName.minor.value])
|
||||
self._micro = int(settings[VersionSettingsName.micro.value])
|
||||
|
||||
def to_dict(self) -> dict:
|
||||
return {
|
||||
VersionSettingsName.major.value: self._major,
|
||||
VersionSettingsName.minor.value: self._minor,
|
||||
VersionSettingsName.micro.value: self._micro
|
||||
}
|
8
src/cpl_cli/configuration/version_settings_name.py
Normal file
8
src/cpl_cli/configuration/version_settings_name.py
Normal file
@@ -0,0 +1,8 @@
|
||||
from enum import Enum
|
||||
|
||||
|
||||
class VersionSettingsName(Enum):
|
||||
|
||||
major = 'major'
|
||||
minor = 'minor'
|
||||
micro = 'micro'
|
Reference in New Issue
Block a user