]> git.phdru.name Git - m_librarian.git/commitdiff
Cache config
authorOleg Broytman <phd@phdru.name>
Sun, 5 Jun 2016 14:35:19 +0000 (17:35 +0300)
committerOleg Broytman <phd@phdru.name>
Sun, 5 Jun 2016 14:35:19 +0000 (17:35 +0300)
m_librarian/config.py

index 04e64e0c9f99e8aa949e1500eb69d1e15b28bdae..d896bf58cdb3c3d3d3c1ba9326690b3a1ed84856 100755 (executable)
@@ -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():