inveniosoftware / inveniosoftware/xrootdpyfs
How do we glob files?
- Dominant language
- Python
- Stars
- 8
- Forks
- 20
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
I am trying to find a way to glob files but there seems to be none. Therefore I am writting something like:
```python
from XRootD.client import FileSystem
from XRootD.client.flags import DirListFlags, StatInfoFlags
def _glob(fs : FileSystem, root : str, ext : str) -> list[str]:
print(f'Logging into: {root}')
status , dir_list = fs.dirlist(root, DirListFlags.STAT)
if not status.ok:
raise ValueError(f'Cannot open {root}')
paths = []
objects = dir_list.dirlist
if not objects:
return paths
for entry in objects:
is_dir = (entry.statinfo.flags & StatInfoFlags.IS_DIR)
if is_dir:
paths += _glob(fs=fs, root=f'{root}/{entry.name}', ext = ext)
if entry.name.endswith(f'.{ext}'):
paths.append(f'{root}/{entry.name}')
return paths
host = "root://eoslhcb.cern.ch"
root = "/eos/lhcb/wg/dpa/wp2/ci/22781/btoxll_mva_2024_nopid"
fs = FileSystem(host)
paths = _glob(fs=fs, root=root, ext='root')
```
Which is clearly not very efficient, but it's probably all I can do from my side, given that you haven't implemented anything for this sort of thing.
Cheers.
Contributor guide
Assessment
This issue has not been assessed yet.