FunctionMapper.py 文件源码

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

项目:turtle 作者: icse-turtle 项目源码 文件源码
def load_file(self, filename):
        # Saves the name and the extension of the file. It assumes that the class
        # to be loaded has the same name of the module (.py or .pyc file).
        mod_name, file_ext = os.path.splitext(os.path.split(filename)[-1])

        py_mod = None

        # If the file has .py extension, then it loads that module.
        if file_ext.lower() == '.py':
            py_mod = imp.load_source(mod_name, filename)

        # If the file has .pyc extension, then it loads that module.
        elif file_ext.lower() == '.pyc':
            py_mod = imp.load_compiled(mod_name, filename)

        else:
            raise EvaluateException('Unable to find the file ' + filename + '!')

        # Builds the list of the classes contained in the module.
        classes = [u for (v, u) in getmembers(py_mod, isclass) if v.startswith(mod_name)]

        # Loads the classes contained in the module.
        for c in classes:
            self.load_class(c)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号