本文整理汇总了Python中rdflib.URIRef.startswith方法的典型用法代码示例。如果您正苦于以下问题:Python URIRef.startswith方法的具体用法?Python URIRef.startswith怎么用?Python URIRef.startswith使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rdflib.URIRef
的用法示例。
在下文中一共展示了URIRef.startswith方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: relativize
# 需要导入模块: from rdflib import URIRef [as 别名]
# 或者: from rdflib.URIRef import startswith [as 别名]
def relativize(self, uri):
base = URIRef(self.base)
basedir = URIRef(self.base if base.endswith('/') else base.rsplit('/', 1)[0])
if base is not None:
if uri == base:
uri = URIRef('')
elif uri == basedir:
uri = URIRef('.')
elif uri.startswith(basedir + '/'):
uri = URIRef(uri.replace(basedir + '/', "", 1))
return uri
示例2: convert
# 需要导入模块: from rdflib import URIRef [as 别名]
# 或者: from rdflib.URIRef import startswith [as 别名]
def convert(self, name, qname, attrs):
if name[0] is None:
name = URIRef(name[1])
else:
name = URIRef("".join(name))
atts = {}
for (n, v) in attrs.items(): #attrs._attrs.iteritems(): #
if n[0] is None:
att = URIRef(n[1])
else:
att = URIRef("".join(n))
if att.startswith(XMLNS) or att[0:3].lower()=="xml":
pass
elif att in UNQUALIFIED:
#if not RDFNS[att] in atts:
atts[RDFNS[att]] = v
else:
atts[URIRef(att)] = v
return name, atts
示例3: fixit
# 需要导入模块: from rdflib import URIRef [as 别名]
# 或者: from rdflib.URIRef import startswith [as 别名]
def fixit(current_object):
"""
Read the def data structure and replace all string URIs with URIRef entities
:param current_object: the piece of the data structure to be fixed
:return current_object: the piece repaired in place
"""
from rdflib import URIRef
if isinstance(current_object, dict):
for k in current_object.keys():
current_object[k] = fixit(current_object[k])
elif isinstance(current_object, list):
for i in range(0, len(current_object)):
current_object[i] = fixit(current_object[i])
elif isinstance(current_object, basestring):
if current_object.startswith("http://"):
current_object = URIRef(current_object)
elif current_object.startswith("xsd:"):
current_object = cast_to_rdflib(current_object)
return current_object
示例4: fixit
# 需要导入模块: from rdflib import URIRef [as 别名]
# 或者: from rdflib.URIRef import startswith [as 别名]
def fixit(current_object, prefix_dictionary):
"""
Read the def data structure and replace all string URIs with URIRef entities
:param current_object: the piece of the data structure to be fixed
:return current_object: the piece repaired in place
"""
from rdflib import URIRef
if isinstance(current_object, dict):
for k in current_object.keys():
current_object[k] = fixit(current_object[k], prefix_dictionary)
elif isinstance(current_object, list):
for i in range(0, len(current_object)):
current_object[i] = fixit(current_object[i], prefix_dictionary)
elif isinstance(current_object, basestring):
if current_object.startswith("http://"):
current_object = URIRef(current_object)
elif current_object.startswith("xsd:"):
current_object = cast_to_rdflib(current_object)
elif ':' in current_object:
k = current_object.find(':')
tag = str(current_object[0:k + 1])
if tag in prefix_dictionary:
current_object = URIRef(str(current_object).replace(tag, prefix_dictionary[tag]))
return current_object