當前位置: 首頁>>代碼示例>>Python>>正文


Python URIRef.startswith方法代碼示例

本文整理匯總了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
開發者ID:bodleian,項目名稱:datafinder,代碼行數:13,代碼來源:serializers.py

示例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
開發者ID:AuroraSkywalker,項目名稱:watchdog,代碼行數:21,代碼來源:RDFXMLHandler.py

示例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
開發者ID:senrabc,項目名稱:vivo-pump,代碼行數:21,代碼來源:vivopump.py

示例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
開發者ID:ctsit,項目名稱:vivo-pump,代碼行數:26,代碼來源:vivopump.py


注:本文中的rdflib.URIRef.startswith方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。