Skip to content

Commit

Permalink
Fix CLI override report
Browse files Browse the repository at this point in the history
In cases here

+ an option was set on the CLI
+ the same option had a setting in some config file

the configuration display erroneously reported that the option was set
in the file rather than on the CLI.

This is fixed here.
  • Loading branch information
jacg committed Sep 9, 2017
1 parent b896129 commit 063dc7d
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions invisible_cities/core/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def configure(input_options=sys.argv):
CLI = parser.parse_args(args)
options = read_config_file(CLI.config_file)

options.update((opt, val) for opt, val in vars(CLI).items() if val is not None)
options.add_cli((opt, val) for opt, val in vars(CLI).items() if val is not None)
logger.setLevel(options.get("verbosity", "info"))

return options
Expand Down Expand Up @@ -145,8 +145,11 @@ def __delitem__(self, key): raise NotImplementedError
def __len__ (self): return len (self._data)
def __iter__ (self): return iter(self._data)

def update(self, *others):
self._data.update(*others)
def add_cli(self, keys_and_vals):
self.push_file('<command line>')
for k,v in keys_and_vals:
self[k] = v
self.pop_file()

def push_file(self, file_name):
self._file_stack.append(file_name)
Expand Down Expand Up @@ -175,5 +178,5 @@ def style_filename(file_name):
exval = str(exval)
file_name = style_filename(file_name)
print(fmt_overridden.format(**locals()))
file_name = style_filename(self._file.get(key, '<command line>'))
file_name = style_filename(self._file[key])
print(fmt.format(**locals()))

0 comments on commit 063dc7d

Please sign in to comment.