本文整理汇总了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
示例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)
示例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
示例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
示例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