qualia_core.utils.path module
Path utilities.
- qualia_core.utils.path.resources_to_path(resources: Path | MultiplexedPath | Traversable) Path[source]
Convert a (static type) Traversable to a Path if the underlying dynamic type is MultiplexedPath.
This is useful when using
importlib.resources.files()since with Python >= 3.10 it returns aimportlib.readers.MultiplexedPathwhenimportlib.readers.NamespaceReaderis used as a reader, e.g. when used on a package available as a plain directory (not zip file). This allows getting a standardpathlib.Pathout of it. Any other situation will probably fail with ValueError.- Parameters:
resources – An object returned by
importlib.resources.files()- Returns:
A standard Path object pointing to the
resourcespath on the filesystem- Raises:
ValueError – When conversion fails because
resourceswas not aimportlib.readers.MultiplexedPathon Python >= 3.10 or apathlib.Path