当前位置: 首页>>代码示例>>Python>>正文


Python Result.vars方法代码示例

本文整理汇总了Python中rdflib.query.Result.vars方法的典型用法代码示例。如果您正苦于以下问题:Python Result.vars方法的具体用法?Python Result.vars怎么用?Python Result.vars使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rdflib.query.Result的用法示例。


在下文中一共展示了Result.vars方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: parse

# 需要导入模块: from rdflib.query import Result [as 别名]
# 或者: from rdflib.query.Result import vars [as 别名]
    def parse(self, source):

        try:
            r = Result('SELECT')

            header = source.readline()

            r.vars = list(HEADER.parseString(header.strip(), parseAll=True))
            r.bindings = []
            while True:
                line = source.readline()
                if not line:
                    break
                line = line.strip()
                if line == "":
                    continue

                row = ROW.parseString(line, parseAll=True)
                r.bindings.append(
                    dict(zip(r.vars, (self.convertTerm(x) for x in row))))

            return r

        except ParseException, err:
            print err.line
            print " " * (err.column - 1) + "^"
            print err
开发者ID:benrosemeyer-wf,项目名称:rdflib-sparql,代码行数:29,代码来源:tsvresults.py

示例2: parse

# 需要导入模块: from rdflib.query import Result [as 别名]
# 或者: from rdflib.query.Result import vars [as 别名]
    def parse(self, source):

        if isinstance(source.read(0), bytestype):
            # if reading from source returns bytes do utf-8 decoding
            source = codecs.getreader('utf-8')(source)

        try:
            r = Result('SELECT')

            header = source.readline()

            r.vars = list(HEADER.parseString(header.strip(), parseAll=True))
            r.bindings = []
            while True:
                line = source.readline()
                if not line:
                    break
                line = line.strip('\n')
                if line == "":
                    continue

                row = ROW.parseString(line, parseAll=True)
                r.bindings.append(
                    dict(list(zip(r.vars, (self.convertTerm(x) for x in row)))))

            return r

        except ParseException as err:
            print(err.line)
            print(" " * (err.column - 1) + "^")
            print(err)
开发者ID:0038lana,项目名称:Test-Task,代码行数:33,代码来源:tsvresults.py

示例3: parse

# 需要导入模块: from rdflib.query import Result [as 别名]
# 或者: from rdflib.query.Result import vars [as 别名]
    def parse(self, source):

        r = Result('SELECT')

        reader = csv.reader(source, delimiter=self.delim)
        r.vars = [Variable(x) for x in next(reader)]
        r.bindings = []

        for row in reader:
            r.bindings.append(self.parseRow(row, r.vars))

        return r
开发者ID:pkuyken,项目名称:RDFTranslator,代码行数:14,代码来源:csvresults.py

示例4: parse

# 需要导入模块: from rdflib.query import Result [as 别名]
# 或者: from rdflib.query.Result import vars [as 别名]
    def parse(self, source):

        r = Result("SELECT")

        if hasattr(source, "mode") and "b" in source.mode:
            source = codecs.getreader("utf-8")(source)

        reader = csv.reader(source, delimiter=self.delim)
        r.vars = [Variable(x) for x in reader.next()]
        r.bindings = []

        for row in reader:
            r.bindings.append(self.parseRow(row, r.vars))

        return r
开发者ID:jmahmud,项目名称:rdflib,代码行数:17,代码来源:csvresults.py

示例5: parse

# 需要导入模块: from rdflib.query import Result [as 别名]
# 或者: from rdflib.query.Result import vars [as 别名]
    def parse(self, source):

        r = Result('SELECT')

        if isinstance(source.read(0), py3compat.bytestype):
            # if reading from source returns bytes do utf-8 decoding
            source = codecs.getreader('utf-8')(source)

        reader = csv.reader(source, delimiter=self.delim)
        r.vars = [Variable(x) for x in reader.next()]
        r.bindings = []

        for row in reader:
            r.bindings.append(self.parseRow(row, r.vars))

        return r
开发者ID:3mcorp,项目名称:schemaorg,代码行数:18,代码来源:csvresults.py


注:本文中的rdflib.query.Result.vars方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。