add setters for properties

This commit is contained in:
Maximilian Keßler 2022-02-08 19:24:48 +01:00
parent 4aaec9fc3d
commit b00e62c017

View file

@ -94,12 +94,12 @@ class FileVersionInfo(Config):
class VersionInfo(Config):
def __init__(self):
self._pytex_dir_type: Optional[PyTeXRootDirType] = None
self._file_versions: Optional[List[FileVersionInfo]] = None
self._files: Optional[List[FileVersionInfo]] = None
def set_from_json(self, content: Optional[Dict]):
filled_content: Dict = self._fill_keys(content)
self._pytex_dir_type = None # TODO
self._file_versions = [
self._files = [
FileVersionInfo.from_json(entry)
for entry in filled_content[JSON_FILE_VERSIONS]
]
@ -108,7 +108,7 @@ class VersionInfo(Config):
return {
JSON_FILE_VERSIONS: [
file_version_info.to_json()
for file_version_info in self.file_versions
for file_version_info in self.files
]
}
@ -119,9 +119,18 @@ class VersionInfo(Config):
else:
return self._pytex_dir_type
@pytex_dir_type.setter
def pytex_dir_type(self, pytex_dir_type: PyTeXRootDirType):
self._pytex_dir_type = pytex_dir_type
@property
def file_versions(self) -> List[FileVersionInfo]:
if self._file_versions is None:
def files(self) -> List[FileVersionInfo]:
if self._files is None:
return []
else:
return self._file_versions
return self._files
@files.setter
def files(self, files: List[FileVersionInfo]):
self._files = files