From: Oleg Broytman Date: Sun, 5 Jun 2016 14:35:19 +0000 (+0300) Subject: Cache config X-Git-Tag: 0.0.11~7 X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=2792dae0b23c3fe2f982651cdb31db622615ec81;p=m_librarian.git Cache config --- diff --git a/m_librarian/config.py b/m_librarian/config.py index 04e64e0..d896bf5 100755 --- a/m_librarian/config.py +++ b/m_librarian/config.py @@ -35,12 +35,17 @@ def find_config_file(config_dirs=None): raise IOError("Cannot find m_librarian.conf in %s" % config_dirs) +_ml_config = None + + def get_config(config_filename=None): - if config_filename is None: - config_filename = find_config_file() - ml_conf = SafeConfigParser() - ml_conf.read(config_filename) - return ml_conf + global _ml_config + if _ml_config is None: + if config_filename is None: + config_filename = find_config_file() + _ml_config = SafeConfigParser() + _ml_config.read(config_filename) + return _ml_config def test():