def _set_command_flag(self, option: Flag, command: str): if not option: return # command specific flags if option.key == constants.PARAMETER_SOURCE: if isinstance(option.value, str) and option.value: self._source.append(option.value) elif isinstance(option.value, list) and option.value: self._source.extend(option.value) elif option.key == constants.PARAMETER_INITIALIZE: if isinstance(option.value, bool): self.initialize = option.value elif option.key == constants.PARAMETER_HOST: # specific to 'host': if the value is a boolean True, then we replace it with the hostname if isinstance(option.value, bool) and option.value: option.value = self._gethostname() option.type = 'str' elif option.key == constants.PARAMETER_CHECK_BEFORE: if isinstance(option.value, bool) and option.value: self.check_before = True elif option.key == constants.PARAMETER_CHECK_AFTER: if isinstance(option.value, bool) and option.value: self.check_after = True elif option.key == constants.PARAMETER_RUN_BEFORE: if option.value: self.run_before = option.value elif option.key == constants.PARAMETER_RUN_AFTER: if option.value: self.run_after = option.value elif option.key == constants.PARAMETER_STDIN: if option.value: self.stdin = option.value if command not in self._command_flags: self._command_flags[command] = {} if not self._is_special_flag(option.key): self._command_flags[command][option.key] = option
def _set_retention_flag(self, option: Flag): if not option: return if option.key == constants.PARAMETER_FORGET_BEFORE_BACKUP: if isinstance(option.value, bool): self.forget_before = option.value elif option.key == constants.PARAMETER_FORGET_AFTER_BACKUP: if isinstance(option.value, bool): self.forget_after = option.value elif option.key == constants.PARAMETER_HOST: # specific to 'host': if the value is a boolean True, then we replace it with the hostname if isinstance(option.value, bool) and option.value: option.value = self._gethostname() option.type = 'str' # adds it to the list of flags if not self._is_special_flag(option.key): self._retention_flags[option.key] = option