本文整理汇总了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')