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


Python RDF.type方法代码示例

本文整理汇总了Python中rdflib.namespace.RDF.type方法的典型用法代码示例。如果您正苦于以下问题:Python RDF.type方法的具体用法?Python RDF.type怎么用?Python RDF.type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rdflib.namespace.RDF的用法示例。


在下文中一共展示了RDF.type方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: validate

# 需要导入模块: from rdflib.namespace import RDF [as 别名]
# 或者: from rdflib.namespace.RDF import type [as 别名]
def validate(self, value, row_number=None, source="", node=None, nodeid=None):
        errors = []

        try:
            if value == "":
                value = None
            if value is not None:
                decimal.Decimal(value)
        except Exception:
            dt = self.datatype_model.datatype
            errors.append(
                {
                    "type": "ERROR",
                    "message": "datatype: {0}, value: {1} {2} {3} - {4}. {5}".format(
                        dt, value, source, row_number, "not a properly formatted number", "This data was not saved."
                    ),
                }
            )
        return errors 
开发者ID:archesproject,项目名称:arches,代码行数:21,代码来源:datatypes.py

示例2: get_rdf_uri

# 需要导入模块: from rdflib.namespace import RDF [as 别名]
# 或者: from rdflib.namespace.RDF import type [as 别名]
def get_rdf_uri(self, node, data, which="r"):
        if type(data) == list:
            l = []
            for x in data:
                if x["url"].startswith("/"):
                    l.append(URIRef(archesproject[x["url"][1:]]))
                else:
                    l.append(URIRef(archesproject[x["url"]]))
            return l
        elif data:
            if data["url"].startswith("/"):
                return URIRef(archesproject[data["url"][1:]])
            else:
                return URIRef(archesproject[data["url"]])
        else:
            return node 
开发者ID:archesproject,项目名称:arches,代码行数:18,代码来源:datatypes.py

示例3: to_rdf

# 需要导入模块: from rdflib.namespace import RDF [as 别名]
# 或者: from rdflib.namespace.RDF import type [as 别名]
def to_rdf(self, edge_info, edge):
        g = Graph()

        def _add_resource(d, p, r, r_type):
            if r_type is not None:
                g.add((r, RDF.type, URIRef(r_type)))
            g.add((d, URIRef(p), r))

        if edge_info["range_tile_data"] is not None:
            res_insts = edge_info["range_tile_data"]
            if not isinstance(res_insts, list):
                res_insts = [res_insts]

            for res_inst in res_insts:
                rangenode = self.get_rdf_uri(None, res_inst)
                try:
                    res_inst_obj = models.ResourceInstance.objects.get(pk=res_inst["resourceId"])
                    r_type = res_inst_obj.graph.node_set.get(istopnode=True).ontologyclass
                except models.ResourceInstance.DoesNotExist:
                    # This should never happen excpet if trying to export when the
                    # referenced resource hasn't been saved to the database yet
                    r_type = edge.rangenode.ontologyclass
                _add_resource(edge_info["d_uri"], edge.ontologyproperty, rangenode, r_type)
        return g 
开发者ID:archesproject,项目名称:arches,代码行数:26,代码来源:datatypes.py

示例4: __init__

# 需要导入模块: from rdflib.namespace import RDF [as 别名]
# 或者: from rdflib.namespace.RDF import type [as 别名]
def __init__(self, node, sht_graph, result_node, data_graph, shapes_graph, label=None, status=None):
        """

        :param sht_graph:
        :type sht_graph: rdflib.Graph
        :param data_graph:
        :type data_graph: rdflib.Graph
        :param shapes_graph:
        :type shapes_graph: rdflib.Graph
        :param label:
        """
        self.node = node
        self.sht_graph = sht_graph
        self.sht_result = result_node
        self.data_graph = data_graph
        self.shapes_graph = shapes_graph
        self.label = label
        self.status = status 
开发者ID:RDFLib,项目名称:pySHACL,代码行数:20,代码来源:helpers.py

示例5: test_dataset_license_from_distribution_by_uri

# 需要导入模块: from rdflib.namespace import RDF [as 别名]
# 或者: from rdflib.namespace.RDF import type [as 别名]
def test_dataset_license_from_distribution_by_uri(self):
        # license_id retrieved from the URI of dcat:license object
        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))
        g.add((distribution, DCT.license,
               URIRef("http://www.opendefinition.org/licenses/cc-by")))

        p = RDFParser(profiles=['euro_dcat_ap'])

        p.g = g

        dataset = [d for d in p.datasets()][0]
        eq_(dataset['license_id'], 'cc-by') 
开发者ID:italia,项目名称:daf-recipes,代码行数:21,代码来源:test_euro_dcatap_profile_parse.py

示例6: test_dataset_license_from_distribution_by_title

# 需要导入模块: from rdflib.namespace import RDF [as 别名]
# 或者: from rdflib.namespace.RDF import type [as 别名]
def test_dataset_license_from_distribution_by_title(self):
        # license_id retrieved from dct:title of dcat:license object
        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((distribution, RDF.type, DCAT.Distribution))
        g.add((dataset, DCAT.distribution, distribution))
        license = BNode()
        g.add((distribution, DCT.license, license))
        g.add((license, DCT.title, Literal("Creative Commons Attribution")))

        p = RDFParser(profiles=['euro_dcat_ap'])

        p.g = g

        dataset = [d for d in p.datasets()][0]
        eq_(dataset['license_id'], 'cc-by') 
开发者ID:italia,项目名称:daf-recipes,代码行数:22,代码来源:test_euro_dcatap_profile_parse.py

示例7: test_distribution_access_url

# 需要导入模块: from rdflib.namespace import RDF [as 别名]
# 或者: from rdflib.namespace.RDF import type [as 别名]
def test_distribution_access_url(self):
        g = Graph()

        dataset1 = URIRef("http://example.org/datasets/1")
        g.add((dataset1, RDF.type, DCAT.Dataset))

        distribution1_1 = URIRef("http://example.org/datasets/1/ds/1")
        g.add((distribution1_1, RDF.type, DCAT.Distribution))
        g.add((distribution1_1, DCAT.accessURL, Literal('http://access.url.org')))
        g.add((dataset1, DCAT.distribution, distribution1_1))

        p = RDFParser(profiles=['euro_dcat_ap'])

        p.g = g

        datasets = [d for d in p.datasets()]

        resource = datasets[0]['resources'][0]

        eq_(resource['url'], u'http://access.url.org')
        assert 'download_url' not in resource 
开发者ID:italia,项目名称:daf-recipes,代码行数:23,代码来源:test_euro_dcatap_profile_parse.py

示例8: test_distribution_download_url

# 需要导入模块: from rdflib.namespace import RDF [as 别名]
# 或者: from rdflib.namespace.RDF import type [as 别名]
def test_distribution_download_url(self):
        g = Graph()

        dataset1 = URIRef("http://example.org/datasets/1")
        g.add((dataset1, RDF.type, DCAT.Dataset))

        distribution1_1 = URIRef("http://example.org/datasets/1/ds/1")
        g.add((distribution1_1, RDF.type, DCAT.Distribution))
        g.add((distribution1_1, DCAT.downloadURL, Literal('http://download.url.org')))
        g.add((dataset1, DCAT.distribution, distribution1_1))

        p = RDFParser(profiles=['euro_dcat_ap'])

        p.g = g

        datasets = [d for d in p.datasets()]

        resource = datasets[0]['resources'][0]

        eq_(resource['url'], u'http://download.url.org')
        eq_(resource['download_url'], u'http://download.url.org') 
开发者ID:italia,项目名称:daf-recipes,代码行数:23,代码来源:test_euro_dcatap_profile_parse.py

示例9: test_distribution_both_access_and_download_url

# 需要导入模块: from rdflib.namespace import RDF [as 别名]
# 或者: from rdflib.namespace.RDF import type [as 别名]
def test_distribution_both_access_and_download_url(self):
        g = Graph()

        dataset1 = URIRef("http://example.org/datasets/1")
        g.add((dataset1, RDF.type, DCAT.Dataset))

        distribution1_1 = URIRef("http://example.org/datasets/1/ds/1")
        g.add((distribution1_1, RDF.type, DCAT.Distribution))
        g.add((distribution1_1, DCAT.accessURL, Literal('http://access.url.org')))
        g.add((distribution1_1, DCAT.downloadURL, Literal('http://download.url.org')))
        g.add((dataset1, DCAT.distribution, distribution1_1))

        p = RDFParser(profiles=['euro_dcat_ap'])

        p.g = g

        datasets = [d for d in p.datasets()]

        resource = datasets[0]['resources'][0]

        eq_(resource['url'], u'http://access.url.org')
        eq_(resource['download_url'], u'http://download.url.org') 
开发者ID:italia,项目名称:daf-recipes,代码行数:24,代码来源:test_euro_dcatap_profile_parse.py

示例10: test_distribution_format_format_only

# 需要导入模块: from rdflib.namespace import RDF [as 别名]
# 或者: from rdflib.namespace.RDF import type [as 别名]
def test_distribution_format_format_only(self):
        g = Graph()

        dataset1 = URIRef("http://example.org/datasets/1")
        g.add((dataset1, RDF.type, DCAT.Dataset))

        distribution1_1 = URIRef("http://example.org/datasets/1/ds/1")
        g.add((distribution1_1, RDF.type, DCAT.Distribution))
        g.add((distribution1_1, DCT['format'], Literal('CSV')))
        g.add((dataset1, DCAT.distribution, distribution1_1))

        p = RDFParser(profiles=['euro_dcat_ap'])

        p.g = g

        datasets = [d for d in p.datasets()]

        resource = datasets[0]['resources'][0]

        eq_(resource['format'], u'CSV') 
开发者ID:italia,项目名称:daf-recipes,代码行数:22,代码来源:test_euro_dcatap_profile_parse.py

示例11: test_distribution_format_imt_only

# 需要导入模块: from rdflib.namespace import RDF [as 别名]
# 或者: from rdflib.namespace.RDF import type [as 别名]
def test_distribution_format_imt_only(self):
        g = Graph()

        dataset1 = URIRef("http://example.org/datasets/1")
        g.add((dataset1, RDF.type, DCAT.Dataset))

        distribution1_1 = URIRef("http://example.org/datasets/1/ds/1")
        g.add((distribution1_1, RDF.type, DCAT.Distribution))
        g.add((distribution1_1, DCAT.mediaType, Literal('text/csv')))
        g.add((dataset1, DCAT.distribution, distribution1_1))

        p = RDFParser(profiles=['euro_dcat_ap'])

        p.g = g

        datasets = [d for d in p.datasets()]

        resource = datasets[0]['resources'][0]
        if toolkit.check_ckan_version(min_version='2.3'):
            eq_(resource['format'], u'CSV')
            eq_(resource['mimetype'], u'text/csv')
        else:
            eq_(resource['format'], u'text/csv') 
开发者ID:italia,项目名称:daf-recipes,代码行数:25,代码来源:test_euro_dcatap_profile_parse.py

示例12: test_distribution_format_imt_only_normalize_false

# 需要导入模块: from rdflib.namespace import RDF [as 别名]
# 或者: from rdflib.namespace.RDF import type [as 别名]
def test_distribution_format_imt_only_normalize_false(self):
        g = Graph()

        dataset1 = URIRef("http://example.org/datasets/1")
        g.add((dataset1, RDF.type, DCAT.Dataset))

        distribution1_1 = URIRef("http://example.org/datasets/1/ds/1")
        g.add((distribution1_1, RDF.type, DCAT.Distribution))
        g.add((distribution1_1, DCAT.mediaType, Literal('text/csv')))
        g.add((dataset1, DCAT.distribution, distribution1_1))

        p = RDFParser(profiles=['euro_dcat_ap'])

        p.g = g

        datasets = [d for d in p.datasets()]

        resource = datasets[0]['resources'][0]

        eq_(resource['format'], u'text/csv')
        eq_(resource['mimetype'], u'text/csv') 
开发者ID:italia,项目名称:daf-recipes,代码行数:23,代码来源:test_euro_dcatap_profile_parse.py

示例13: test_distribution_format_format_only_normalize_false

# 需要导入模块: from rdflib.namespace import RDF [as 别名]
# 或者: from rdflib.namespace.RDF import type [as 别名]
def test_distribution_format_format_only_normalize_false(self):
        g = Graph()

        dataset1 = URIRef("http://example.org/datasets/1")
        g.add((dataset1, RDF.type, DCAT.Dataset))

        distribution1_1 = URIRef("http://example.org/datasets/1/ds/1")
        g.add((distribution1_1, RDF.type, DCAT.Distribution))
        g.add((distribution1_1, DCT['format'], Literal('CSV')))
        g.add((dataset1, DCAT.distribution, distribution1_1))

        p = RDFParser(profiles=['euro_dcat_ap'])

        p.g = g

        datasets = [d for d in p.datasets()]

        resource = datasets[0]['resources'][0]

        eq_(resource['format'], u'CSV')
        assert 'mimetype' not in resource 
开发者ID:italia,项目名称:daf-recipes,代码行数:23,代码来源:test_euro_dcatap_profile_parse.py

示例14: test_distribution_format_unknown_imt

# 需要导入模块: from rdflib.namespace import RDF [as 别名]
# 或者: from rdflib.namespace.RDF import type [as 别名]
def test_distribution_format_unknown_imt(self):
        g = Graph()

        dataset1 = URIRef("http://example.org/datasets/1")
        g.add((dataset1, RDF.type, DCAT.Dataset))

        distribution1_1 = URIRef("http://example.org/datasets/1/ds/1")
        g.add((distribution1_1, RDF.type, DCAT.Distribution))
        g.add((distribution1_1, DCAT.mediaType, Literal('text/unknown-imt')))
        g.add((dataset1, DCAT.distribution, distribution1_1))

        p = RDFParser(profiles=['euro_dcat_ap'])

        p.g = g

        datasets = [d for d in p.datasets()]

        resource = datasets[0]['resources'][0]

        eq_(resource['format'], u'text/unknown-imt')
        eq_(resource['mimetype'], u'text/unknown-imt') 
开发者ID:italia,项目名称:daf-recipes,代码行数:23,代码来源:test_euro_dcatap_profile_parse.py

示例15: test_distribution_format_format_normalized

# 需要导入模块: from rdflib.namespace import RDF [as 别名]
# 或者: from rdflib.namespace.RDF import type [as 别名]
def test_distribution_format_format_normalized(self):
        g = Graph()

        dataset1 = URIRef("http://example.org/datasets/1")
        g.add((dataset1, RDF.type, DCAT.Dataset))

        distribution1_1 = URIRef("http://example.org/datasets/1/ds/1")
        g.add((distribution1_1, RDF.type, DCAT.Distribution))
        g.add((distribution1_1, DCAT.mediaType, Literal('text/csv')))
        g.add((distribution1_1, DCT['format'], Literal('Comma Separated Values')))
        g.add((dataset1, DCAT.distribution, distribution1_1))

        p = RDFParser(profiles=['euro_dcat_ap'])

        p.g = g

        datasets = [d for d in p.datasets()]

        resource = datasets[0]['resources'][0]

        if toolkit.check_ckan_version(min_version='2.3'):
            eq_(resource['format'], u'CSV')
            eq_(resource['mimetype'], u'text/csv')
        else:
            eq_(resource['format'], u'Comma Separated Values') 
开发者ID:italia,项目名称:daf-recipes,代码行数:27,代码来源:test_euro_dcatap_profile_parse.py


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