def __init__(self, message, astobj = None):
self.message = message
self.line_info = {}
try:
if astobj is not None:
if issubclass(type(astobj), (_ast.Module, _ast.Expression)):
astobj = astobj.body
if isinstance(astobj, list) and len(astobj) > 0:
start = astobj[0]
end = astobj[-1]
else:
start = astobj
end = astobj
if hasattr(start, "lineno") and \
hasattr(start, "col_offset") and \
hasattr(end, "end_lineno") and \
hasattr(end, "end_col_offset"):
self.line_info["line_start"] = start.lineno
self.line_info["column_start"] = start.col_offset
self.line_info["line_end"] = end.end_lineno
self.line_info["column_end"] = end.end_col_offset
except:
pass
# TODO FILIP: No used for now, come back to this later.
评论列表
文章目录