dda-devops-build/version_repository.py
2023-02-21 16:14:47 +01:00

32 lines
976 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, release_type):
self.file_handler = self.load_file()
version_list, is_snapshot = self.parse_file()
version = Version(version_list, release_type)
version.is_snapshot = is_snapshot
return version