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


Python URIRef.split方法代碼示例

本文整理匯總了Python中rdflib.URIRef.split方法的典型用法代碼示例。如果您正苦於以下問題:Python URIRef.split方法的具體用法?Python URIRef.split怎麽用?Python URIRef.split使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在rdflib.URIRef的用法示例。


在下文中一共展示了URIRef.split方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: process_journal

# 需要導入模塊: from rdflib import URIRef [as 別名]
# 或者: from rdflib.URIRef import split [as 別名]
def process_journal(records, writer, mappings):
    record, fields = majority_vote(records, ('Journal',), mappings)

    if record.get('issn'):
        uri = URIRef('urn:issn:%s' % record['issn'])
        graph_uri = URIRef('/graph/issn/%s' % record['issn'])
    elif record.get('x-nlm-ta'):
        uri = URIRef('/id/journal/%s' % sluggify(record['x-nlm-ta']))
        graph_uri = URIRef('/graph/journal/%s' % sluggify(record['x-nlm-ta']))
    elif record.get('name'):
        uri = URIRef('/id/journal/%s' % sluggify(record['name']))
        graph_uri = URIRef('/graph/journal/%s' % sluggify(record['name']))
    else:
        sys.stderr.write("Unidentifiable: %s" % record)
        return

    for id, _ in fields['id']:
        mappings['id'][id] = uri
        mappings['journal'][uri] = graph_uri.split('/', 3)[-1]

    writer.send((uri, RDF.type, FABIO.Journal, graph_uri))

    for key, predicate in JOURNAL_DATA_PROPERTIES:
        if key in record:
            writer.send((uri, predicate, Literal(record[key]), graph_uri))

    if isinstance(record.get('publisher'), URIRef):
        writer.send((uri, DCTERMS.publisher, record['publisher'], graph_uri))
開發者ID:opencitations,項目名稱:PubMed-OA-network-analysis-scripts,代碼行數:30,代碼來源:bibjson_rdf.py

示例2: post

# 需要導入模塊: from rdflib import URIRef [as 別名]
# 或者: from rdflib.URIRef import split [as 別名]
    def post(self, public=False):
        """
        post=<parent post>
        content=<html content>

        we get the user from the x-foaf-agent header
        """
        parent = self.get_argument('post', default=None) or self.get_argument("uri")
        assert parent is not None
        # maybe a legacy problem here with http/https, but blaster is still sending http
        parent = URIRef(parent)

        # this might be failing on ariblog, but that one is already safe
        ip = self.request.headers.get("X-Forwarded-For")
        if ip is not None:
            HoneypotChecker(open("priv-honeypotkey").read().strip()).check(ip)

        contentArg = self.get_argument("content", default="")
        if not contentArg.strip():
            raise ValueError("no text")

        if contentArg.strip() == 'test':
            return "not adding test comment"

        spamCheck(parent, contentArg)
            
        content = Literal(contentArg, datatype=RDF.XMLLiteral)

        stmts = [] # gathered in one list for an atomic add

        foafHeader = self.request.headers.get('X-Foaf-Agent')
        if not public:
            assert foafHeader
            user = URIRef(foafHeader)
            # make bnode-ish users for anonymous ones. need to get that username passed in here
        else:
            if foafHeader:
                user = URIRef(foafHeader)
            else:
                user, moreStmts = newPublicUser(
                    self.request.headers.get("X-Forwarded-For"),
                    self.get_argument("name", ""),
                    self.get_argument("email", ""))
                stmts.extend(moreStmts)
                
        secs = time.time()
        comment = newCommentUri(secs)

        now = literalFromUnix(secs)

        ctx = URIRef(parent + "/comments")

        stmts.extend([(parent, SIOC.has_reply, comment),
                      (comment, DCTERMS.created, now),
                      (comment, SIOC.has_creator, user),
                      ])
        stmts.extend(commentStatements(user, comment, content))

        db.writeFile(stmts, ctx, fileWords=[parent.split('/')[-1], now])

        try:
            self.sendAlerts(parent, user)
        except Exception, e:
            import traceback
            log.error(e)
            traceback.print_exc()
開發者ID:drewp,項目名稱:commentserve,代碼行數:68,代碼來源:commentServe.py


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