Compare commits
No commits in common. "659d7e551efc494603685da4fb84e92714d5787b" and "062da0685cf5f94978662789d01b992ee5cf0660" have entirely different histories.
659d7e551e
...
062da0685c
|
@ -227,21 +227,6 @@ Glossary
|
||||||
:term:`config settings<config setting>`. See also
|
:term:`config settings<config setting>`. See also
|
||||||
:doc:`narr/config/table`.
|
:doc:`narr/config/table`.
|
||||||
|
|
||||||
spec
|
|
||||||
As the term is used in Wutta Project context, this refers to a
|
|
||||||
string designating the import path to a particular object (class,
|
|
||||||
function etc.).
|
|
||||||
|
|
||||||
Also the term implies a certain format, namely a dotted module
|
|
||||||
path followed by colon (``:``), then object name.
|
|
||||||
|
|
||||||
For instance, ``wuttjamaican.app:AppHandler`` is the spec string
|
|
||||||
for the :class:`wuttjamaican.app.AppHandler` class (and note, the
|
|
||||||
hyperlink does not use colon, but our "spec" always does).
|
|
||||||
|
|
||||||
See also :meth:`~wuttjamaican.app.AppHandler.load_object()` (on
|
|
||||||
the :term:`app handler`) which can return any object from spec.
|
|
||||||
|
|
||||||
subcommand
|
subcommand
|
||||||
A top-level :term:`command` may expose one or more subcommands,
|
A top-level :term:`command` may expose one or more subcommands,
|
||||||
for the overall command line interface. Subcommands are usually
|
for the overall command line interface. Subcommands are usually
|
||||||
|
|
|
@ -201,6 +201,7 @@ class WuttaConfig:
|
||||||
self.files_read = []
|
self.files_read = []
|
||||||
for path in files:
|
for path in files:
|
||||||
self._load_ini_configs(path, configs, require=True)
|
self._load_ini_configs(path, configs, require=True)
|
||||||
|
log.debug("config files were: %s", self.files_read)
|
||||||
|
|
||||||
# add config for use w/ setdefault()
|
# add config for use w/ setdefault()
|
||||||
self.defaults = configuration.Configuration(defaults)
|
self.defaults = configuration.Configuration(defaults)
|
||||||
|
@ -248,10 +249,6 @@ class WuttaConfig:
|
||||||
def _load_ini_configs(self, path, configs, require=True):
|
def _load_ini_configs(self, path, configs, require=True):
|
||||||
path = os.path.abspath(path)
|
path = os.path.abspath(path)
|
||||||
|
|
||||||
# no need to read a file twice; its first appearance sets priority
|
|
||||||
if path in self.files_read:
|
|
||||||
return
|
|
||||||
|
|
||||||
# try to load config from the given path
|
# try to load config from the given path
|
||||||
try:
|
try:
|
||||||
config = configuration.config_from_ini(path, read_from_file=True)
|
config = configuration.config_from_ini(path, read_from_file=True)
|
||||||
|
|
|
@ -109,39 +109,6 @@ baz = B
|
||||||
self.assertIsNone(config.get('foo.bar'))
|
self.assertIsNone(config.get('foo.bar'))
|
||||||
self.assertEqual(config.get('foo.baz'), 'B')
|
self.assertEqual(config.get('foo.baz'), 'B')
|
||||||
|
|
||||||
def test_files_only_read_once(self):
|
|
||||||
base = self.write_file('base.conf', """
|
|
||||||
[foo]
|
|
||||||
bar = 1
|
|
||||||
baz = A
|
|
||||||
""")
|
|
||||||
|
|
||||||
middle = self.write_file('middle.conf', """
|
|
||||||
[wutta.config]
|
|
||||||
require = %(here)s/base.conf
|
|
||||||
|
|
||||||
[foo]
|
|
||||||
baz = B
|
|
||||||
""")
|
|
||||||
|
|
||||||
top = self.write_file('top.conf', """
|
|
||||||
[wutta.config]
|
|
||||||
require = %(here)s/middle.conf
|
|
||||||
|
|
||||||
[foo]
|
|
||||||
baz = C
|
|
||||||
""")
|
|
||||||
|
|
||||||
config = conf.WuttaConfig(files=[top, middle, base])
|
|
||||||
self.assertEqual(len(config.files_read), 3)
|
|
||||||
# nb. files_read listing is in order of "priority" which is
|
|
||||||
# same the as order in which files were initially read
|
|
||||||
self.assertEqual(config.files_read[0], top)
|
|
||||||
self.assertEqual(config.files_read[1], middle)
|
|
||||||
self.assertEqual(config.files_read[2], base)
|
|
||||||
self.assertEqual(config.get('foo.bar'), '1')
|
|
||||||
self.assertEqual(config.get('foo.baz'), 'C')
|
|
||||||
|
|
||||||
def test_prioritized_files(self):
|
def test_prioritized_files(self):
|
||||||
first = self.write_file('first.conf', """\
|
first = self.write_file('first.conf', """\
|
||||||
[foo]
|
[foo]
|
||||||
|
|
Loading…
Reference in a new issue