2021-03-04 19:06:16 +01:00
|
|
|
from typing import Optional
|
|
|
|
|
|
|
|
from cpl.configuration.configuration_model_abc import ConfigurationModelABC
|
2021-03-12 16:10:43 +01:00
|
|
|
from cpl_cli.configuration.version_settings_name_enum import VersionSettingsNameEnum
|
2021-03-04 19:06:16 +01:00
|
|
|
|
|
|
|
|
2021-03-12 16:06:30 +01:00
|
|
|
class VersionSettings(ConfigurationModelABC):
|
2021-03-04 19:06:16 +01:00
|
|
|
|
|
|
|
def __init__(
|
|
|
|
self,
|
2021-03-13 14:25:08 +01:00
|
|
|
major: str = None,
|
|
|
|
minor: str = None,
|
|
|
|
micro: str = None
|
2021-03-04 19:06:16 +01:00
|
|
|
):
|
|
|
|
ConfigurationModelABC.__init__(self)
|
|
|
|
|
2021-03-13 14:25:08 +01:00
|
|
|
self._major: Optional[str] = major
|
|
|
|
self._minor: Optional[str] = minor
|
|
|
|
self._micro: Optional[str] = micro
|
2021-03-04 19:06:16 +01:00
|
|
|
|
|
|
|
@property
|
2021-03-13 14:25:08 +01:00
|
|
|
def major(self) -> str:
|
2021-03-04 19:06:16 +01:00
|
|
|
return self._major
|
|
|
|
|
|
|
|
@property
|
2021-03-13 14:25:08 +01:00
|
|
|
def minor(self) -> str:
|
2021-03-04 19:06:16 +01:00
|
|
|
return self._minor
|
|
|
|
|
|
|
|
@property
|
2021-03-13 14:25:08 +01:00
|
|
|
def micro(self) -> str:
|
2021-03-04 19:06:16 +01:00
|
|
|
return self._micro
|
|
|
|
|
|
|
|
def to_str(self) -> str:
|
|
|
|
return f'{self._major}.{self._minor}.{self._micro}'
|
|
|
|
|
|
|
|
def from_dict(self, settings: dict):
|
2021-03-13 14:25:08 +01:00
|
|
|
self._major = settings[VersionSettingsNameEnum.major.value]
|
|
|
|
self._minor = settings[VersionSettingsNameEnum.minor.value]
|
|
|
|
self._micro = settings[VersionSettingsNameEnum.micro.value]
|
2021-03-04 19:06:16 +01:00
|
|
|
|
|
|
|
def to_dict(self) -> dict:
|
|
|
|
return {
|
2021-03-12 16:10:43 +01:00
|
|
|
VersionSettingsNameEnum.major.value: self._major,
|
|
|
|
VersionSettingsNameEnum.minor.value: self._minor,
|
|
|
|
VersionSettingsNameEnum.micro.value: self._micro
|
2021-03-04 19:06:16 +01:00
|
|
|
}
|