Krzysztof Rusek <[email protected]> added the comment:
Maybe importlib.resources.path() should skip checking file existence when
ResourceReader.resource_path() raises FileNotFoundError? Current logic:
@contextmanager
def path(package: Package, resource: Resource) -> Iterator[Path]:
resource = _normalize_path(resource)
package = _get_package(package)
reader = _get_resource_reader(package)
if reader is not None:
try:
yield Path(reader.resource_path(resource))
return
except FileNotFoundError:
pass
else:
_check_location(package)
# Fall-through for both the lack of resource_path() *and* if
# resource_path() raises FileNotFoundError.
package_directory = Path(package.__spec__.origin).parent
file_path = package_directory / resource
if file_path.exists():
yield file_path
else:
<create temporary file>
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue39980>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com