paul@1069 | 1 | #!/usr/bin/env python |
paul@1069 | 2 | |
paul@1069 | 3 | """ |
paul@1069 | 4 | General support for calendar data storage. |
paul@1069 | 5 | |
paul@1206 | 6 | Copyright (C) 2016, 2017 Paul Boddie <paul@boddie.org.uk> |
paul@1069 | 7 | |
paul@1069 | 8 | This program is free software; you can redistribute it and/or modify it under |
paul@1069 | 9 | the terms of the GNU General Public License as published by the Free Software |
paul@1069 | 10 | Foundation; either version 3 of the License, or (at your option) any later |
paul@1069 | 11 | version. |
paul@1069 | 12 | |
paul@1069 | 13 | This program is distributed in the hope that it will be useful, but WITHOUT |
paul@1069 | 14 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
paul@1069 | 15 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
paul@1069 | 16 | details. |
paul@1069 | 17 | |
paul@1069 | 18 | You should have received a copy of the GNU General Public License along with |
paul@1069 | 19 | this program. If not, see <http://www.gnu.org/licenses/>. |
paul@1069 | 20 | """ |
paul@1069 | 21 | |
paul@1338 | 22 | from imiptools.config import settings |
paul@1206 | 23 | from imiptools.stores.manifest import stores |
paul@1071 | 24 | |
paul@1088 | 25 | # Access functions. |
paul@1069 | 26 | |
paul@1338 | 27 | def get_store(store_type=None, store_dir=None): |
paul@1338 | 28 | |
paul@1338 | 29 | """ |
paul@1338 | 30 | Return a store object for the given 'store_type' and 'store_dir', using |
paul@1338 | 31 | configuration defaults where the parameters are given as None. |
paul@1338 | 32 | """ |
paul@1338 | 33 | |
paul@1338 | 34 | return stores[store_type or settings["STORE_TYPE"]].Store( |
paul@1338 | 35 | store_dir or settings["STORE_DIR"]) |
paul@1338 | 36 | |
paul@1338 | 37 | def get_publisher(publishing_dir=None): |
paul@1069 | 38 | |
paul@1338 | 39 | """ |
paul@1338 | 40 | Return a publisher object for the given 'publishing_dir', using |
paul@1338 | 41 | configuration defaults where the parameter is given as None. |
paul@1338 | 42 | """ |
paul@1338 | 43 | |
paul@1338 | 44 | return stores["file"].Publisher( |
paul@1338 | 45 | publishing_dir or settings["PUBLISHING_DIR"]) |
paul@1069 | 46 | |
paul@1338 | 47 | def get_journal(store_type=None, journal_dir=None): |
paul@1338 | 48 | |
paul@1338 | 49 | """ |
paul@1338 | 50 | Return a journal object for the given 'store_type' and 'journal_dir', using |
paul@1338 | 51 | configuration defaults where the parameters are given as None. |
paul@1338 | 52 | """ |
paul@1338 | 53 | |
paul@1338 | 54 | return stores[store_type or settings["STORE_TYPE"]].Journal( |
paul@1338 | 55 | journal_dir or settings["JOURNAL_DIR"]) |
paul@1069 | 56 | |
paul@1069 | 57 | # vim: tabstop=4 expandtab shiftwidth=4 |