merge latest confit

This commit is contained in:
Adrian Sampson 2012-10-26 20:47:21 -07:00
parent ac8109bb5f
commit 56a2d41183

View file

@ -151,6 +151,16 @@ class ConfigView(object):
"""
self.overlay[key] = value
def add_args(self, namespace):
"""Add parsed command-line arguments, generated by a library
like argparse or optparse, to this view's overlay.
"""
args = {}
for key, value in namespace.__dict__.items():
if value is not None: # Avoid unset options.
args[key] = value
self.overlay.update(args)
# Magical conversions. These special methods make it possible to use
# View objects somewhat transparently in certain circumstances. For
# example, rather than using ``view.get(bool)``, it's possible to
@ -482,17 +492,6 @@ class Configuration(RootView):
for filename in self._filenames():
self.sources.append(load_yaml(filename))
def add_args(self, namespace):
"""Add parsed command-line arguments, generated by a library
like argparse or optparse, as an overlay to the configuration
sources.
"""
arg_source = {}
for key, value in namespace.__dict__.items():
if value is not None: # Avoid unset options.
arg_source[key] = value
self.sources.insert(0, arg_source)
def config_dir(self):
"""Get the path to the directory containing the highest-priority
user configuration. If no user configuration is present, create a