本文整理匯總了Python中rdflib.URIRef.get方法的典型用法代碼示例。如果您正苦於以下問題:Python URIRef.get方法的具體用法?Python URIRef.get怎麽用?Python URIRef.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類rdflib.URIRef
的用法示例。
在下文中一共展示了URIRef.get方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _build_and_parse_format_mediatype_graph
# 需要導入模塊: from rdflib import URIRef [as 別名]
# 或者: from rdflib.URIRef import get [as 別名]
def _build_and_parse_format_mediatype_graph(self, format_item=None, mediatype_item=None):
"""
Creates a minimal graph with a distribution having the specified dct:format and dcat:mediaType
nodes. At least one of those nodes has to be given.
After creating the graph, it is parsed using the euro_dcat_ap profile.
:param format_item:
Literal or URIRef object for dct:format. None if the node should be omitted.
:param mediatype_item:
Literal or URIRef object for dcat:mediaType. None if the node should be omitted.
:returns:
The parsed resource dict
"""
g = Graph()
dataset = URIRef("http://example.org/datasets/1")
g.add((dataset, RDF.type, DCAT.Dataset))
distribution = URIRef("http://example.org/datasets/1/ds/1")
g.add((dataset, DCAT.distribution, distribution))
g.add((distribution, RDF.type, DCAT.Distribution))
if format_item:
g.add((distribution, DCT['format'], format_item))
if mediatype_item:
g.add((distribution, DCAT.mediaType, mediatype_item))
if format_item is None and mediatype_item is None:
raise AssertionError('At least one of format or mediaType is required!')
p = RDFParser(profiles=['euro_dcat_ap'])
p.g = g
dataset = [d for d in p.datasets()][0]
return dataset.get('resources')