import pathlib
root_collection = arvados.collection.Collection(...)
# Start work from the base stream.
-stream_queue = collections.deque(['.'])
+stream_queue = collections.deque([pathlib.PurePosixPath('.')])
while stream_queue:
- stream_name = stream_queue.popleft()
- collection = root_collection.find(stream_name)
+ stream_path = stream_queue.popleft()
+ collection = root_collection.find(str(stream_path))
for item_name in collection:
try:
my_file = collection.open(item_name)
except IsADirectoryError:
# item_name refers to a stream. Queue it to walk later.
- stream_path = pathlib.Path(stream_name, item_name)
- stream_queue.append(stream_path.as_posix())
+ stream_queue.append(stream_path / item_name)
continue
with my_file:
... # Work with my_file as desired