From 2792dae0b23c3fe2f982651cdb31db622615ec81 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Sun, 5 Jun 2016 17:35:19 +0300 Subject: [PATCH] Cache config --- m_librarian/config.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) 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(): -- 2.39.5