astTools.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:ITAP-django 作者: krivers 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号