_filefinder2.py 文件源码

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

项目:filefinder2 作者: asmodehn 项目源码 文件源码
def find_spec(cls, fullname, path=None, target=None):
            """find the module on sys.path or 'path' based on sys.path_hooks and
            sys.path_importer_cache."""
            if path is None:
                path = sys.path
            spec = cls._get_spec(fullname, path, target)
            if spec is None:
                return None
            elif spec.loader is None:
                namespace_path = spec.submodule_search_locations
                if namespace_path:
                    # We found at least one namespace path.  Return a
                    #  spec which can create the namespace package.
                    spec.origin = 'namespace'
                    spec.submodule_search_locations = _NamespacePath(fullname, namespace_path, cls._get_spec)
                    return spec
                else:
                    return None
            else:
                return spec

    # to match importlib API
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号