Improved and finished publish library

This commit is contained in:
2020-11-21 12:51:05 +01:00
parent adfef66621
commit 96d3ccd8d2
27 changed files with 787 additions and 77 deletions

View File

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

View File

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

View File

@@ -0,0 +1,44 @@
from typing import Optional
from sh_edraft.source_code.model.version_enum import VersionEnum
from sh_edraft.configuration.model.configuration_model_base import ConfigurationModelBase
class Version(ConfigurationModelBase):
def __init__(
self,
major: int = None,
minor: int = None,
micro: float = None
):
self._major: Optional[int] = major
self._minor: Optional[int] = minor
self._micro: Optional[float] = 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 = float(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

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