mirror of
https://github.com/python/cpython.git
synced 2025-11-24 20:30:18 +00:00
gh-97930: Merge with importlib_resources 5.9 (GH-97929)
* Merge with importlib_resources 5.9 * Update changelog
This commit is contained in:
parent
5c9302d03a
commit
cea910ebf1
7 changed files with 102 additions and 29 deletions
|
|
@ -99,20 +99,6 @@ class ResourceContainer(Traversable):
|
|||
def open(self, *args, **kwargs):
|
||||
raise IsADirectoryError()
|
||||
|
||||
@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 == target
|
||||
).joinpath(*names)
|
||||
|
||||
|
||||
class TraversableReader(TraversableResources, SimpleReader):
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue