Package oort :: Package util :: Module queries
[hide private]
[frames] | no frames]

Source Code for Module oort.util.queries

 1  #======================================================================= 
 2  from rdflib import URIRef, RDF, RDFS 
 3  from oort.rdfview import RdfQuery, one, localized, i18n_dict 
 4  from oort.util.code import SlotStruct 
 5  #======================================================================= 
 6   
7 -class Typed(RdfQuery):
8 rdfType = one(RDF.type)
9
10 -class Labelled(RdfQuery):
11 label = localized(RDFS)
12
13 -class Annotated(Labelled):
14 comment = localized(RDFS)
15
16 -class Resource(Annotated, Typed):
17 pass
18 19 #----------------------------------------------------------------------- 20
21 -class HasLabel(RdfQuery):
22 label = localized(RDFS.RDFSNS)
23
24 -def make_label_query(uriBase, *uriTails):
25 def labels(graph, lang, resource, **kwargs): 26 labelBase = uriBase + "%s" 27 class Labels(SlotStruct): 28 __slots__ = uriTails
29 return Labels( 30 *[HasLabel(graph, lang, URIRef(labelBase % tail)).label 31 for tail in Labels.__slots__] ) 32 return labels 33
34 -class Lang(RdfQuery):
35 value = one(RDF.RDFNS) 36 label = i18n_dict(RDFS.RDFSNS)
37