Skip to content

Commit 6934f74

Browse files
committed
Update Multiplexed to return Multiplexed objects for subpackages.
1 parent 61f64ac commit 6934f74

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

importlib_resources/abc.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,20 +139,22 @@ def read_text(self, *args, **kwargs):
139139
return self.open(mode='r', *args, **kwargs).read()
140140

141141
def is_dir(self):
142-
return True
142+
return any(path.is_dir() for path in self._paths)
143143

144144
def is_file(self):
145-
return False
145+
return any(path.is_file() for path in self._paths)
146146

147147
def joinpath(self, child):
148-
# todo: how to handle subpackages that are themselves multiplexed?
149-
subpackages = ()
150-
children = (path.joinpath(child) for path in self._paths)
151-
return next(
148+
children = (
149+
path.joinpath(child)
150+
for path in self._paths
151+
)
152+
existing = (
152153
child
153-
for child in itertools.chain(subpackages, children)
154+
for child in children
154155
if child.is_dir() or child.is_file()
155156
)
157+
return Multiplexed(*existing)
156158

157159
__truediv__ = joinpath
158160

0 commit comments

Comments
 (0)