Add option_was_set function

This commit is contained in:
Brad Warren 2016-06-13 16:52:35 -07:00
parent 9f61424e26
commit 8f68663097

View file

@ -217,6 +217,21 @@ def set_by_cli(var):
set_by_cli.detector = None
def option_was_set(option, value):
"""Was option set by the user or does it differ from the default?
:param str option: configuration variable being considered
:param value: value of the configuration variable named option
:returns: True if the option was set, otherwise, False
:rtype: bool
"""
return (set_by_cli(option) or
option not in DEFAULTS or
DEFAULTS[option] != value)
def argparse_type(variable):
"Return our argparse type function for a config variable (default: str)"
# pylint: disable=protected-access