Option validator

class katello.client.utils.option_validator.OptionValidator(option_parser, options, arguments=None)
add_option_error(error_msg)

Add option error to the error stack

Parameters:error_msg (str) – error message
all_exist(opt_dests)

Check if all the options are present

Parameters:opt_dests (iterable(str)) – option destinations to check
Returns:True if the all the options were set, otherwise False
any_exist(opt_dests)

Check if any of options is present

Parameters:opt_dests (iterable(str)) – option destinations to check
Returns:True if the any of the options was set, otherwise False
exists(opt_dest)

Check if option is present

Parameters:opt_dest (str) – option destination to check
Returns:True if the option was set, otherwise False
mutually_exclude(*opt_dest_tuples)

Allows only one of option tuples to be present.

Parameters:opt_dest_tuples (iterable(str)) – option destinations to check
reject(opt_dest, colliding_opts=None, message=None)

Add an option error if an option is present.

Parameters:
  • opt_dest (iterable(str)) – option destinations to check
  • colliding_opts (iterable(str)) – option destinations that collide with the rejected ones. Used in error message.
  • message (str) – custom error message
require(opt_dests, message=None)

Check if all the options are present and add an error to a message stack if not.

Parameters:
  • opt_dests (iterable(str)) – option destinations to check
  • message (str) – custom error message
require_all_or_none(opt_dests, message=None)

If one of the options is present, all are required. Otherwise add an error to a message stack.

Parameters:
  • opt_dests (iterable(str)) – option destinations to check
  • message (str) – custom error message
require_at_least_one_of(opt_dests, message=None)

Add an option error if there is less then one of the options present.

Parameters:
  • opt_dests (iterable(str)) – option destinations to check
  • message (str) – custom error message
require_at_most_one_of(opt_dests, message=None)

Add an option error if there is more then one of the options present.

Parameters:
  • opt_dests (iterable(str)) – option destinations to check
  • message (str) – custom error message
require_one_of(opt_dests, message=None)

Check if one and only one of the options is present. Otherwise add an error to a message stack.

Parameters:
  • opt_dests (iterable(str)) – option destinations to check
  • message (str) – custom error message

This Page