def test_rdf(self): global RESOURCES RESOURCES = _RESOURCES qname_as_resource = re.compile('rdf:[a-z]+=\"\w+:\w+\"') for rsc in _RESOURCES: if not hasattr(rsc.model, 'first'): continue ctx = rsc.model.first() res = render('%s/rdf.mako' % rsc.name, dict(ctx=ctx), request=self.env['request']) assert not qname_as_resource.search(res) g = Graph() g.load(StringIO(res.encode('utf8') if PY2 else res)) for predicate in ['void:inDataset', 'skos:prefLabel']: if predicate == 'void:inDataset' and rsc.name == 'dataset': continue subject = URIRef(self.env['request'].resource_url(ctx)) predicate = URIRef(rdf.url_for_qname(predicate)) assert (subject, predicate, None) in g p = Parameter.get('parameter') res = render('parameter/rdf.mako', dict(ctx=p), request=self.env['request']) assert p.domain[0].name in res
def test_rdf(self): qname_as_resource = re.compile('rdf:[a-z]+=\"\w+:\w+\"') for rsc in _RESOURCES: if not hasattr(rsc.model, 'first'): continue ctx = rsc.model.first() res = render( '%s/rdf.mako' % rsc.name, dict(ctx=ctx), request=self.env['request']) assert not qname_as_resource.search(res) g = Graph() g.load(StringIO(res)) for predicate in ['void:inDataset', 'skos:prefLabel']: if predicate == 'void:inDataset' and rsc.name == 'dataset': continue subject = URIRef(self.env['request'].resource_url(ctx)) predicate = URIRef(rdf.url_for_qname(predicate)) assert (subject, predicate, None) in g p = Parameter.get('parameter') res = render('parameter/rdf.mako', dict(ctx=p), request=self.env['request']) assert p.domain[0].name in res
def __rdf__(self, request): if self.omegawiki: yield 'owl:sameAs', self.omegawiki_url yield 'dcterms:type', self.ontological_category yield 'rdf:type', url_for_qname('skos:Collection') for vs in self.valuesets: yield 'skos:member', request.resource_url(vs.values[0]) for rel in self.rel_to: if rel.description == 'broader': yield 'skos:broader', request.resource_url(rel.target) elif rel.description == 'narrower': yield 'skos:narrower', request.resource_url(rel.target) else: yield 'skos:related', request.resource_url(rel.target) for rel in self.rel_from: if rel.description == 'broader': yield 'skos:narrower', request.resource_url(rel.source) elif rel.description == 'narrower': yield 'skos:broader', request.resource_url(rel.source) else: yield 'skos:related', request.resource_url(rel.source)
def __rdf__(self, request): yield 'dcterms:type', self.ontological_category yield 'rdf:type', url_for_qname('skos:Collection') for vs in self.valuesets: yield 'skos:member', request.resource_url(vs.values[0]) for rel in self.rel_to: if rel.description == 'broader': yield 'skos:broader', request.resource_url(rel.target) elif rel.description == 'narrower': yield 'skos:narrower', request.resource_url(rel.target) else: yield 'skos:related', request.resource_url(rel.target) for rel in self.rel_from: if rel.description == 'broader': yield 'skos:narrower', request.resource_url(rel.source) elif rel.description == 'narrower': yield 'skos:broader', request.resource_url(rel.source) else: yield 'skos:related', request.resource_url(rel.source) for meta in self.meta: if meta.propertyUrl and meta.valueUrl: yield meta.propertyUrl, meta.valueUrl
def test_url_for_qname(): from clld.lib.rdf import url_for_qname assert url_for_qname('dcterms:title') == 'http://purl.org/dc/terms/title'
def test_url_for_qname(self): from clld.lib.rdf import url_for_qname assert url_for_qname('dcterms:title') == 'http://purl.org/dc/terms/title'
def __rdf__(self, request): cls = self.segment_class.capitalize() \ if self.segment_class in ['consonant', 'vowel'] else 'Segment' yield 'rdf:type', url_for_qname('gold:' + cls) if self.segment_class: yield 'dcterms:description', self.segment_class
def __rdf__(self, request): yield 'rdf:type', url_for_qname('skos:Concept') yield 'skos:topConceptOf', request.resource_url( self.valueset.contribution)
def __rdf__(self, request): yield 'rdf:type', url_for_qname('skos:ConceptScheme') for vs in self.valuesets: yield 'skos:hasTopConcept', request.resource_url(vs.values[0]) for ref in self.references: yield 'dcterms:source', request.resource_url(ref.source)
def __rdf__(self, request): yield 'rdf:type', url_for_qname('skos:Concept') yield 'skos:topConceptOf', request.resource_url(self.valueset.contribution)