implement VersionInfo
This commit is contained in:
parent
b53b3be39a
commit
e93e69d771
2 changed files with 39 additions and 1 deletions
|
@ -22,3 +22,5 @@ JSON_REPO_STATUS_INFO = 'repo_info'
|
||||||
|
|
||||||
NO_RELATIVE_NAME = 'NO_NAME'
|
NO_RELATIVE_NAME = 'NO_NAME'
|
||||||
NO_BUILD_TIME = 'no_build_time'
|
NO_BUILD_TIME = 'no_build_time'
|
||||||
|
|
||||||
|
JSON_FILE_VERSIONS = 'file_versions'
|
||||||
|
|
|
@ -3,7 +3,7 @@ from typing import Optional, List, Dict
|
||||||
from PyTeX.format.repo_status_info import RepoStatusInfo
|
from PyTeX.format.repo_status_info import RepoStatusInfo
|
||||||
from .constants import *
|
from .constants import *
|
||||||
from ....format.config import Config
|
from ....format.config import Config
|
||||||
|
from ...build.enums import *
|
||||||
|
|
||||||
class FileVersionInfo(Config):
|
class FileVersionInfo(Config):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -88,3 +88,39 @@ class FileVersionInfo(Config):
|
||||||
@build_time.setter
|
@build_time.setter
|
||||||
def build_time(self, build_time: str):
|
def build_time(self, build_time: str):
|
||||||
self._build_time = build_time
|
self._build_time = build_time
|
||||||
|
|
||||||
|
|
||||||
|
class VersionInfo(Config):
|
||||||
|
def __init__(self):
|
||||||
|
self._pytex_dir_type: Optional[PyTeXRootDirType] = None
|
||||||
|
self._file_versions: Optional[List[FileVersionInfo]] = None
|
||||||
|
|
||||||
|
def set_from_json(self, content: Optional[Dict]):
|
||||||
|
content = self._fill_keys(content)
|
||||||
|
self._pytex_dir_type = None # TODO
|
||||||
|
self._file_versions = [
|
||||||
|
FileVersionInfo.from_json(entry)
|
||||||
|
for entry in content[JSON_FILE_VERSIONS]
|
||||||
|
]
|
||||||
|
|
||||||
|
def to_json(self) -> Dict:
|
||||||
|
return {
|
||||||
|
JSON_FILE_VERSIONS: [
|
||||||
|
file_version_info.to_json()
|
||||||
|
for file_version_info in self._file_versions
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
@property
|
||||||
|
def pytex_dir_type(self) -> PyTeXRootDirType:
|
||||||
|
if self._pytex_dir_type is None:
|
||||||
|
return PyTeXRootDirType.PYTEX_SOURCE
|
||||||
|
else:
|
||||||
|
return self._pytex_dir_type
|
||||||
|
|
||||||
|
@property
|
||||||
|
def file_versions(self) -> List[FileVersionInfo]:
|
||||||
|
if self._file_versions is None:
|
||||||
|
return []
|
||||||
|
else:
|
||||||
|
return self._file_versions
|
||||||
|
|
Loading…
Reference in a new issue