in torchdata/datapipes/iter/load/fsspec.py [0:0]
def __iter__(self) -> Iterator[str]:
fs, path = fsspec.core.url_to_fs(self.root)
is_local = fs.protocol == "file" or not self.root.startswith(fs.protocol)
if fs.isfile(path):
yield self.root
else:
for file_name in fs.ls(path):
if not match_masks(file_name, self.masks):
continue
# ensure the file name has the full fsspec protocol path
if file_name.startswith(fs.protocol):
yield file_name
else:
if is_local:
abs_path = os.path.join(path, file_name)
else:
abs_path = posixpath.join(path, file_name)
if self.root.startswith(fs.protocol):
yield fs.protocol + "://" + abs_path
else:
yield abs_path