aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/importlib/resources/simple.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/importlib/resources/simple.py')
-rw-r--r--Lib/importlib/resources/simple.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/Lib/importlib/resources/simple.py b/Lib/importlib/resources/simple.py
index da073cbdb11..d0fbf237762 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):