A class method which returns a closure to use on sys.path_hook which will return an instance using the specified loaders and the path called on the closure. If the path called on the closure is not a directory, ImportError is raised.
(cls, *loader_details)
| 1433 | |
| 1434 | @classmethod |
| 1435 | def path_hook(cls, *loader_details): |
| 1436 | """A class method which returns a closure to use on sys.path_hook |
| 1437 | which will return an instance using the specified loaders and the path |
| 1438 | called on the closure. |
| 1439 | |
| 1440 | If the path called on the closure is not a directory, ImportError is |
| 1441 | raised. |
| 1442 | |
| 1443 | """ |
| 1444 | def path_hook_for_FileFinder(path): |
| 1445 | """Path hook for importlib.machinery.FileFinder.""" |
| 1446 | if not _path_isdir(path): |
| 1447 | raise ImportError('only directories are supported', path=path) |
| 1448 | return cls(path, *loader_details) |
| 1449 | |
| 1450 | return path_hook_for_FileFinder |
| 1451 | |
| 1452 | def _find_children(self): |
| 1453 | with _os.scandir(self.path) as scan_iterator: |
no outgoing calls
no test coverage detected