hal.py 文件源码

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

项目:hal 作者: virtualanup 项目源码 文件源码
def __init__(self, configpath):
        self.configpath = configpath
        # Find libraries inside the lib directory

        dir_path = os.path.join(os.path.dirname(__file__), "libraries")
        lib_files = [f for f in os.listdir(dir_path) if
                     os.path.isfile(os.path.join(dir_path, f)) and
                     f.lower().endswith(".py")
                     ]

        self.responses = []
        self.libraries = []
        for f in lib_files:
            # Try to load the module
            try:
                module_name = "hal.libraries." + f[:-3]
                module = importlib.import_module(module_name)
                for name, obj in inspect.getmembers(module):
                    # Find classes that inherit from HalLibrary
                    if inspect.isclass(obj) and issubclass(obj, HalLibrary) and \
                            name != "HalLibrary" and not inspect.isabstract(obj):
                        self.libraries.append(obj)
            except:
                self.add_response("Error loading library {}".format(f))
                raise
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号