def importedName(id, importList):
for imp in importList:
if type(imp) == ast.Import:
for name in imp.names:
if hasattr(name, "asname") and name.asname != None:
if id == name.asname:
return True
else:
if id == name.name:
return True
elif type(imp) == ast.ImportFrom:
if hasattr(imp, "module"):
if imp.module in supportedLibraries:
libMap = libraryMap[imp.module]
for name in imp.names:
if hasattr(name, "asname") and name.asname != None:
if id == name.asname:
return True
else:
if id == name.name:
return True
else:
log("astTools\timportedName\tUnsupported library: " + printFunction(imp), "bug")
else:
log("astTools\timportedName\tWhy no module? " + printFunction(imp), "bug")
return False
评论列表
文章目录