1.1 --- a/imiptools/stores/__init__.py Tue Oct 17 17:43:42 2017 +0200
1.2 +++ b/imiptools/stores/__init__.py Tue Oct 17 22:58:26 2017 +0200
1.3 @@ -19,38 +19,39 @@
1.4 this program. If not, see <http://www.gnu.org/licenses/>.
1.5 """
1.6
1.7 +from imiptools.config import settings
1.8 from imiptools.stores.manifest import stores
1.9
1.10 # Access functions.
1.11
1.12 -def get_store(store_type, store_dir):
1.13 +def get_store(store_type=None, store_dir=None):
1.14
1.15 """
1.16 - Return a store for the given 'store_type' and 'store_dir'. If 'store_dir'
1.17 - is given as a null or false value then the configured default is used.
1.18 + Return a store object for the given 'store_type' and 'store_dir', using
1.19 + configuration defaults where the parameters are given as None.
1.20 """
1.21
1.22 - return stores[store_type].Store(store_dir)
1.23 + return stores[store_type or settings["STORE_TYPE"]].Store(
1.24 + store_dir or settings["STORE_DIR"])
1.25
1.26 -def get_publisher(publishing_dir):
1.27 +def get_publisher(publishing_dir=None):
1.28
1.29 """
1.30 - Return a publishing resource employing 'publishing_dir'. If the specified
1.31 - directory is given as a null or false value, None is returned. Thus, all
1.32 - free/busy publishing can be disabled by changing the configuration to use
1.33 - None as the directory.
1.34 + Return a publisher object for the given 'publishing_dir', using
1.35 + configuration defaults where the parameter is given as None.
1.36 """
1.37
1.38 - return publishing_dir and stores["file"].Publisher(publishing_dir) or None
1.39 + return stores["file"].Publisher(
1.40 + publishing_dir or settings["PUBLISHING_DIR"])
1.41
1.42 -def get_journal(store_type, journal_dir):
1.43 +def get_journal(store_type=None, journal_dir=None):
1.44
1.45 """
1.46 - Return a journal for the given 'store_type' and 'journal_dir'. If
1.47 - 'journal_dir' is given as a null or false value then the configured default
1.48 - is used.
1.49 + Return a journal object for the given 'store_type' and 'journal_dir', using
1.50 + configuration defaults where the parameters are given as None.
1.51 """
1.52
1.53 - return stores[store_type].Journal(journal_dir)
1.54 + return stores[store_type or settings["STORE_TYPE"]].Journal(
1.55 + journal_dir or settings["JOURNAL_DIR"])
1.56
1.57 # vim: tabstop=4 expandtab shiftwidth=4