Skip to content

Commit

Permalink
Adding an initialise function so we don't need an existing config fil…
Browse files Browse the repository at this point in the history
…e to use schemas.
  • Loading branch information
rob committed Dec 17, 2014
1 parent 8401f57 commit b4debf0
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion confix.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ def parse(conf_file, parser=None, type_check=True):
specified in the configuration file has a different type than
the one defined in the configuration class.
"""
global _conf_file
if _conf_file is not None:
raise Error('already configured (you may want to use discard() '
'then call parse() again')
Expand All @@ -227,6 +226,11 @@ def parse(conf_file, parser=None, type_check=True):
# TODO: use a copy of _conf_map and set it at the end of this
# procedure?
# TODO: should we use threading.[R]Lock (probably safer)?
initialise(conf, file, type_check=type_check)


def initialise(conf=None, file=None, type_check=True):
global _conf_file
if isinstance(conf, dict):
for section, values in conf.items():
inst = _conf_map.get(section, None)
Expand Down

0 comments on commit b4debf0

Please sign in to comment.