当前位置: 首页>>代码示例>>Python>>正文


Python URIRef.get方法代码示例

本文整理汇总了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')
开发者ID:ckan,项目名称:ckanext-dcat,代码行数:38,代码来源:test_euro_dcatap_profile_parse.py


注:本文中的rdflib.URIRef.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。