(name, loader, *, origin=None, is_package=None)
return ModuleSpec(name, loader, origin=origin, is_package=is_package)
Return a module spec based on various loader methods.
Return a module spec based on various loader methods.
Return a module spec based on various loader methods .
def spec_from_loader(name, loader, *, origin=None, is_package=None):
    """Return a module spec based on various loader methods."""
    if hasattr(loader, 'get_filename'):
        if _bootstrap_external is None:
            raise NotImplementedError
        spec_from_file_location = _bootstrap_external.spec_from_file_location

        if is_package is None:
            return spec_from_file_location(name, loader=loader)
        search = [] if is_package else None
        return spec_from_file_location(name, loader=loader,
                                       submodule_search_locations=search)

    if is_package is None:
        if hasattr(loader, 'is_package'):
            try:
                is_package = loader.is_package(name)
            except ImportError:
                is_package = None  # aka, undefined
        else:
            # the default
            is_package = False

    return ModuleSpec(name, loader, origin=origin, is_package=is_package)
def spec_from_loader ( name , loader , * , origin = None , is_package = None ) : if hasattr ( loader , 'get_filename' ) : if _bootstrap_external is None : raise NotImplementedError spec_from_file_location = _bootstrap_external . spec_from_file_location if is_package is None : return spec_from_file_location ( name , loader = loader ) search = [ ] if is_package else None return spec_from_file_location ( name , loader = loader , submodule_search_locations = search ) if is_package is None : if hasattr ( loader , 'is_package' ) : try : is_package = loader . is_package ( name ) except ImportError : is_package = None # aka, undefined else : # the default is_package = False return ModuleSpec ( name , loader , origin = origin , is_package = is_package )