Changeset - 1929e0e1053e
[Not reviewed]
default
0 1 0
drewp@bigasterisk.com - 15 years ago 2010-06-13 07:57:00
drewp@bigasterisk.com
showconfig logs about what n3 files it's reading
Ignore-this: 12ed745bfe471e7070ad93ec1e1c6dde
1 file changed with 7 insertions and 2 deletions:
0 comments (0 inline, 0 general)
light9/showconfig.py
Show inline comments
 
import time
 
import time, logging
 
from os import path, getenv
 
from rdflib.Graph import Graph
 
from rdflib import URIRef
 
from namespaces import MUS, L9
 
log = logging.getLogger('showconfig')
 

	
 
_config = (None, None, None) # graph, mtime, len
 
def getGraph():
 
@@ -14,6 +15,7 @@ def getGraph():
 
    now = time.time()
 
    diskMtime = path.getmtime(configPath)
 
    if diskMtime <= _config[1]:
 
        log.info("reuse graph")
 
        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
 
@@ -23,8 +25,11 @@ def getGraph():
 
        return _config[0]
 

	
 
    graph = Graph()
 
    log.info("reading %s", configPath)
 
    graph.parse(configPath, format='n3')
 
    graph.parse(path.join(root(), "patch.n3"), 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
0 comments (0 inline, 0 general)