def extract_text_from_node(dastring, astobj):
try:
if issubclass(type(astobj), _ast.Module):
astobj = astobj.body
if isinstance(astobj, list) and len(astobj) > 0:
rangeobj = TextRange(lineno=astobj[0].lineno,
col_offset=astobj[0].col_offset,
end_lineno=astobj[-1].end_lineno,
end_col_offset=astobj[-1].end_col_offset)
else:
rangeobj = TextRange(lineno=astobj.lineno,
col_offset=astobj.col_offset,
end_lineno=astobj.end_lineno,
end_col_offset=astobj.end_col_offset)
return(extract_text_range(dastring, rangeobj))
except:
return("")
## PRETTY PRINT FROM GREEN TREE SNAKES
评论列表
文章目录