def __creatBlocks(self):
"""
Second part of parsing. Find blocks and creat a list.
"""
w = list(zip(self.lines, self.indentationList))
self.blocks, indentation, level = "[", 0, 0
for i in w:
if i[1] > indentation:
level = level + 1
self.blocks += ",[" + '"' + urllib.parse.quote_plus(i[0]) + '"'
elif i[1] == 0:
if len(self.blocks) > 1:
self.blocks += "]" * (level) + ','
self.blocks += '"' + urllib.parse.quote_plus(i[0]) + '"'
level = 0
elif i[1] < indentation:
if w.index(i) != len(w):
self.blocks += "]" + "," + '"' + \
urllib.parse.quote_plus(i[0]) + '"'
level += -1
elif i[1] == indentation:
self.blocks += "," + '"' + urllib.parse.quote_plus(i[0]) + '"'
indentation = i[1]
self.blocks += "]" * (level + 1)
self.blocks = ast.literal_eval(self.blocks)
评论列表
文章目录