changeset 832:231a8b3aedc3

showconfig still reads n3 files on its own for legacy code. reads anything in top dir, not just config.n3 and patch.n3 Ignore-this: c510095c0c05e7508161fd4adc75449a
author Drew Perttula <drewp@bigasterisk.com>
date Tue, 04 Jun 2013 23:18:46 +0000
parents 0f7e99d02dc6
children bdfdfea84510
files light9/showconfig.py
diffstat 1 files changed, 12 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/light9/showconfig.py	Tue Jun 04 23:17:06 2013 +0000
+++ b/light9/showconfig.py	Tue Jun 04 23:18:46 2013 +0000
@@ -1,38 +1,23 @@
-import time, logging
+import time, logging, warnings
+from twisted.python.filepath import FilePath
 from os import path, getenv
 from rdflib import Graph
 from rdflib import URIRef
 from namespaces import MUS, L9
 log = logging.getLogger('showconfig')
 
-_config = (None, None, None) # graph, mtime, len
+_config = None # graph
 def getGraph():
+    warnings.warn("code that's using showconfig.getGraph should be "
+                  "converted to use the sync graph", stacklevel=2)
     global _config
-    configPath = path.join(root(), 'config.n3')
-
-    # file patch.n3 mtime is not currently being checked
-    
-    now = time.time()
-    diskMtime = path.getmtime(configPath)
-    if diskMtime <= _config[1]:
-        log.debug("config.n3 hasn't changed")
-        graph = _config[0]
-        # i'm scared of some program modifying the graph, and then i
-        # return that from a new getGraph call. Maybe I should be
-        # copying it right here, or doing something clever with
-        # contexts
-        assert len(graph) == _config[2]
-        return _config[0]
-
-    graph = Graph()
-    log.info("reading %s", configPath)
-    graph.parse(configPath, format='n3')
-    patchPath = path.join(root(), "patch.n3")
-    log.info("reading %s", patchPath)
-    graph.parse(patchPath, format="n3")
-    
-    _config = (graph, diskMtime, len(graph))
-    return graph
+    if _config is None:
+        graph = Graph()
+        for f in FilePath(root()).globChildren("*.n3"):
+            log.info("reading %s", f)
+            graph.parse(location=f.path, format='n3')
+        _config = graph
+    return _config
 
 def root():
     r = getenv("LIGHT9_SHOW")