From 55812ce2f0c89b83aff9a4ec033a2325011b37b5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 May 2022 20:48:17 -0700 Subject: [PATCH] Bump importlib-resources from 5.6.0 to 5.7.1 (#1723) * Bump importlib-resources from 5.6.0 to 5.7.1 Bumps [importlib-resources](https://github.com/python/importlib_resources) from 5.6.0 to 5.7.1. - [Release notes](https://github.com/python/importlib_resources/releases) - [Changelog](https://github.com/python/importlib_resources/blob/main/CHANGES.rst) - [Commits](https://github.com/python/importlib_resources/compare/v5.6.0...v5.7.1) --- updated-dependencies: - dependency-name: importlib-resources dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] * Update importlib-resources==5.7.1 Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com> [skip ci] --- lib/importlib_resources/abc.py | 11 +++++++++-- lib/importlib_resources/simple.py | 15 ++++++++++++--- package/requirements-package.txt | 2 +- requirements.txt | 2 +- 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/lib/importlib_resources/abc.py b/lib/importlib_resources/abc.py index a2b0af62..5e38ba61 100644 --- a/lib/importlib_resources/abc.py +++ b/lib/importlib_resources/abc.py @@ -55,6 +55,9 @@ class Traversable(Protocol): """ An object with a subset of pathlib.Path methods suitable for traversing directories and opening files. + + Any exceptions that occur when accessing the backing resource + may propagate unaltered. """ @abc.abstractmethod @@ -90,9 +93,13 @@ class Traversable(Protocol): """ @abc.abstractmethod - def joinpath(self, child: StrPath) -> "Traversable": + def joinpath(self, *descendants: StrPath) -> "Traversable": """ - Return Traversable child in self + Return Traversable resolved with any descendants applied. + + Each descendant should be a path segment relative to self + and each may contain multiple levels separated by + ``posixpath.sep`` (``/``). """ def __truediv__(self, child: StrPath) -> "Traversable": diff --git a/lib/importlib_resources/simple.py b/lib/importlib_resources/simple.py index da073cbd..d0fbf237 100644 --- a/lib/importlib_resources/simple.py +++ b/lib/importlib_resources/simple.py @@ -99,10 +99,19 @@ class ResourceContainer(Traversable): def open(self, *args, **kwargs): raise IsADirectoryError() - def joinpath(self, name): + @staticmethod + def _flatten(compound_names): + for name in compound_names: + yield from name.split('/') + + def joinpath(self, *descendants): + if not descendants: + return self + names = self._flatten(descendants) + target = next(names) return next( - traversable for traversable in self.iterdir() if traversable.name == name - ) + traversable for traversable in self.iterdir() if traversable.name == target + ).joinpath(*names) class TraversableReader(TraversableResources, SimpleReader): diff --git a/package/requirements-package.txt b/package/requirements-package.txt index 5acd462f..910a9fb8 100644 --- a/package/requirements-package.txt +++ b/package/requirements-package.txt @@ -1,5 +1,5 @@ apscheduler==3.9.1 -importlib-resources==5.6.0 +importlib-resources==5.7.1 pyinstaller==4.9 pyopenssl==22.0.0 pycryptodomex==3.14.1 diff --git a/requirements.txt b/requirements.txt index d6b0816c..6fb9cf89 100644 --- a/requirements.txt +++ b/requirements.txt @@ -19,7 +19,7 @@ html5lib==1.1 httpagentparser==1.9.2 idna==3.3 importlib-metadata==4.11.3 -importlib-resources==5.6.0 +importlib-resources==5.7.1 git+https://github.com/Tautulli/ipwhois.git@master#egg=ipwhois IPy==1.01 Mako==1.2.0