framework.py 文件源码

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

项目:myBFF 作者: MooseDojo 项目源码 文件源码
def loadFingerprint(self, type, dirpath, filename):
        finger_dict = {}
        mod_name = filename.split('.')[0]
        mod_dispname = '/'.join(re.split('/modules/' + type, dirpath)[-1].split('/') + [mod_name])
        mod_loadname = mod_dispname.replace('/', '_')
        mod_loadpath = os.path.join(dirpath, filename)
        mod_file = open(mod_loadpath)
        try:
            # import the module into memory
            imp.load_source(mod_loadname, mod_loadpath, mod_file)
            # find the module and make an instace of it
            _module = __import__(mod_loadname)
            _class = getattr(_module, mod_name)
            _instance = _class(self.config, self.display, self.modulelock)
            finger_dict = {'fingerprint': _instance.getFingerprint(), mod_name: 'name'}


        except Exception as e:
            # notify the user of errors
            print e
            return None
        return finger_dict
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号