terraformDummyRepo/version_repository.py
2023-02-24 10:14:26 +01:00

32 lines
947 B
Python

from file_handlers import FileHandler
from domain 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