Create a ModuleSpec for the specified module. Returns None if the module cannot be found.
(self, fullname, target=None)
| 96 | |
| 97 | |
| 98 | def find_spec(self, fullname, target=None): |
| 99 | """Create a ModuleSpec for the specified module. |
| 100 | |
| 101 | Returns None if the module cannot be found. |
| 102 | """ |
| 103 | module_info = _get_module_info(self, fullname) |
| 104 | if module_info is not None: |
| 105 | return _bootstrap.spec_from_loader(fullname, self, is_package=module_info) |
| 106 | else: |
| 107 | # Not a module or regular package. See if this is a directory, and |
| 108 | # therefore possibly a portion of a namespace package. |
| 109 | |
| 110 | # We're only interested in the last path component of fullname |
| 111 | # earlier components are recorded in self.prefix. |
| 112 | modpath = _get_module_path(self, fullname) |
| 113 | if _is_dir(self, modpath): |
| 114 | # This is possibly a portion of a namespace |
| 115 | # package. Return the string representing its path, |
| 116 | # without a trailing separator. |
| 117 | path = f'{self.archive}{path_sep}{modpath}' |
| 118 | spec = _bootstrap.ModuleSpec(name=fullname, loader=None, |
| 119 | is_package=True) |
| 120 | spec.submodule_search_locations.append(path) |
| 121 | return spec |
| 122 | else: |
| 123 | return None |
| 124 | |
| 125 | def get_code(self, fullname): |
| 126 | """get_code(fullname) -> code object. |
no test coverage detected