Changeset - 4098f5f244ea
[Not reviewed]
default
0 1 0
drewp@bigasterisk.com - 9 years ago 2016-06-11 04:29:38
drewp@bigasterisk.com
cache Namespace term creation.
Ignore-this: 21eb17fc1fbf1a229029f6981d79458d
1 file changed with 13 insertions and 1 deletions:
0 comments (0 inline, 0 general)
light9/namespaces.py
Show inline comments
 
from rdflib import Namespace, RDF, RDFS
 

	
 
L9 = Namespace("http://light9.bigasterisk.com/")
 

	
 
# Namespace was showing up in profiles
 
class FastNs(object):
 
    def __init__(self, base):
 
        self.ns = Namespace(base)
 
        self.cache = {}
 
    def __getitem__(self, term):
 
        if term not in self.cache:
 
            self.cache[term] = self.ns[term]
 
        return self.cache[term]
 
    __getattr__ = __getitem__
 

	
 
L9 = FastNs("http://light9.bigasterisk.com/")
 
MUS = Namespace("http://light9.bigasterisk.com/music/")
 
XSD = Namespace("http://www.w3.org/2001/XMLSchema#")
 
DCTERMS = Namespace("http://purl.org/dc/terms/")
0 comments (0 inline, 0 general)