def checkGlobalIds(a, l):
if not isinstance(a, ast.AST):
return
elif type(a) in [ ast.Load, ast.Store, ast.Del, ast.AugLoad, ast.AugStore, ast.Param ]:
return
if not hasattr(a, "global_id"):
addedNodes = ["propagatedVariable", "orderedBinOp",
"augAssignVal", "augAssignBinOp",
"combinedConditional", "combinedConditionalOp",
"multiCompPart", "multiCompOp",
"second_global_id", "moved_line",
# above this line has individualize functions. below does not.
"addedNot", "addedNotOp", "addedOther", "addedOtherOp",
"collapsedExpr", "removedLines",
"helperVar", "helperReturn",
"typeCastFunction", ]
for t in addedNodes:
if hasattr(a, t):
break
else: # only enter the else if none of the provided types are an attribute of a
log("canonicalize\tcheckGlobalIds\tNo global id: " + str(l) + "," + str(a.__dict__) + "," + printFunction(a, 0), "bug")
for f in ast.iter_child_nodes(a):
checkGlobalIds(f, l + [type(a)])
评论列表
文章目录