当前位置: 首页>>代码示例>>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;未经允许,请勿转载。