terraformDummyRepo/version_repository.py

31 lines
1 KiB
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 file_handler
def write_file(self, version_string):
if self.file_handler is None:
raise Exception('Version was not created by load_file method.')
if self.version_list is None or self.is_snapshot is None:
raise Exception('Version or is_snapshot attribute not set.')
else:
self.file_handler.write(version_string)
def parse_file(self, file_handler):
version_list, is_snapshot = file_handler.parse()
return version_list, is_snapshot
def get_version(self, release_type):
self.file_handler = self.load_file(self.file)
version_list, is_snapshot = self.parse_file(file_handler)
return Version(version_list, release_type)