dda-devops-build/version_repository.py
bom 1ce4bd9c55 Remove release_type as requirement for Version
Require it in functions that actually use it instead
2023-02-23 14:38:54 +01:00

32 lines
948 B
Python

from file_handlers import FileHandler
from version import Version
class VersionRepository():
def __init__(self, file):
self.file = file
self.file_handler = None
def load_file(self):
self.file_handler = FileHandler.from_file_path(self.file)
return self.file_handler
def write_file(self, version_string):
if self.file_handler is None:
raise Exception('Version was not created by load_file method.')
else:
self.file_handler.write(version_string)
def parse_file(self):
version_list, is_snapshot = self.file_handler.parse()
return version_list, is_snapshot
def get_version(self):
self.file_handler = self.load_file()
version_list, is_snapshot = self.parse_file()
version = Version(version_list)
version.is_snapshot = is_snapshot
return version