Skip to content
Snippets Groups Projects
Commit fd96b046 authored by Eva Schiffer's avatar Eva Schiffer
Browse files

warn the user if we're discarding their command line input in favor of a config file

parent 943ffdc2
No related branches found
No related tags found
No related merge requests found
......@@ -321,8 +321,32 @@ def _import_module(full_name, full_file_path,) :
spec.loader.exec_module(mod)
return mod
# TODO, right now this is the top level function that the library functions in
# compare.py call
# FUTURE, if we update the things that could be stomped from the command line, we have to update this as well, sadly
# the key here is the option key we expect in the optionSet and the value is the default value
_STOMPABLE_OPTIONS = {
EPSILON_KEY: 0.0,
OPTIONS_FILL_VALUE_KEY: None,
OPTIONS_LAT_VAR_NAME_KEY: 'pixel_latitude',
OPTIONS_LON_VAR_NAME_KEY: 'pixel_longitude',
OPTIONS_LONLAT_EPSILON_KEY: 0.0,
OPTIONS_IMAGES_ON_FAIL_KEY: False,
DO_MAKE_FORKS_KEY: False,
}
def _warn_for_stomped_commandline_options(optionSet) :
"""
Given the optionSet that the user's input created, warn them if a config file is going to stomp some of these
"""
for option_key in sorted(_STOMPABLE_OPTIONS.keys()) :
if ( option_key in optionSet and
optionSet[option_key] is not None and
optionSet[option_key] != _STOMPABLE_OPTIONS[option_key] ) :
LOG.warn("User provided input for the option \"" + option_key + "\" on the command line that "
"will be overridden by the requested config file. "
"This part of the command line input will be ignored.")
LOG.debug("User value for " + option_key + ": " + str(optionSet[option_key]))
# TODO, right now this is the top level function that the library functions in compare.py call
def load_config_or_options(aPath, bPath, optionsSet, requestedVars = [ ]) :
"""
load information on how the user wants to run the command from a dictionary of options
......@@ -368,7 +392,10 @@ def load_config_or_options(aPath, bPath, optionsSet, requestedVars = [ ]) :
else :
LOG.info ("Using Config File Settings")
# if the user entered stuff in the command line options that we're going to be ignoring, let's warn them
_warn_for_stomped_commandline_options(optionsSet)
# this will handle relative paths
requestedConfigFile = os.path.abspath(os.path.expanduser(requestedConfigFile))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment