本文整理匯總了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
示例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
示例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
示例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
示例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')
示例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')
示例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
示例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')
示例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')
示例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')
示例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')
示例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')
示例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
示例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')
示例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')