loadables.py 文件源码

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

项目:Trusted-Platform-Module-nova 作者: BU-NU-CLOUD-SP16 项目源码 文件源码
def get_matching_classes(self, loadable_class_names):
        """Get loadable classes from a list of names.  Each name can be
        a full module path or the full path to a method that returns
        classes to use.  The latter behavior is useful to specify a method
        that returns a list of classes to use in a default case.
        """
        classes = []
        for cls_name in loadable_class_names:
            obj = importutils.import_class(cls_name)
            if self._is_correct_class(obj):
                classes.append(obj)
            elif inspect.isfunction(obj):
                # Get list of classes from a function
                for cls in obj():
                    classes.append(cls)
            else:
                error_str = 'Not a class of the correct type'
                raise exception.ClassNotFound(class_name=cls_name,
                                              exception=error_str)
        return classes
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号