Commit Graph
2 Commits
Author SHA1 Message Date
Alessio Treglia 496d0afe56 Add LooseLoad - fix #33
A common practice in applications development is to allow the user
to customise/extend program's settings by overriding global defaults
set in system-wide config files (typically installed under /etc)
with site-specific copies (e.g. /usr/local/etc) and user-specific
files generally stored in the user's home directory. It must be
noticed that this cascade approach allows the user to specify only
those options that he wishes to override, whilst the other values
will keep their value already set in the other configuration
files. In general, when a program couldn't find any configuration
file rather than crashing it falls back to hardcoded default values.

These changes introduce a new function LooseLoad that allows the
caller to pass a slice of filenames without worrying about their
existence or not. LooseLoad will attempt to load them in order.
If a file doesn't just, it will just be ignored and the function
won't return any error. In case no files existed, an empty
configuration will be returned to the caller.

This functionality is inspired by the Python's standard library
configparser.RawConfigParser.read() function:

 https://docs.python.org/2/library/configparser.html#ConfigParser.RawConfigParser.read
2016-02-22 20:21:12 +00:00
Alessio Treglia e698a3b8d9 Add LooseLoad's test case 2016-02-22 20:20:43 +00:00