def __init__(self): """Create the command line interface.""" self.archive_selected = self.version_selected = None """:type archive_selected: ArchiveAgent :type version_selected: VersionAgent""" self.archives = Abundant.get_all_archives() self.VERB_TO_FUNCTION = { 'list': self.list, 'list-exact': self.list_exact, 'select': self.select, 'detail': self.detail, 'quit': self.quit, 'create': self.create, 'remove': self.remove, 'migrate': self.migrate, 'export': self.export, 'export-exact': self.export_exact }
def validate_selected_archive_and_version(self): """Make sure selected archive and version are valid.""" if self.archive_selected is None: self.version_selected = None else: all_archives = Abundant.get_all_archives() found_match = False for archive in all_archives: if archive['UUID'] == self.archive_selected.uuid: found_match = True if not found_match: self.archive_selected = None else: if self.version_selected is not None: found_match = False for version in self.archive_selected.versions: if version == self.version_selected: found_match = True if not found_match: self.version_selected = None