fsspec / fsspec/filesystem_spec

not all globstrings are supported in open_files

Open
#957 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.4k
Forks
490
Avg merge
2d 3h
Merged PRs (30d)
38

Description

open_files is insensitive to some globstring:

fspec.open_files("filename*.txt") --> it's working fine.
fspec.open_files("filename?.txt") --> it's not working.
fspec.open_files("filename[0-9].txt") --> it's not working.

I'd expect all these globstrings to be expanded, as documented in the glob method.

The reason seems to be in get_fs_token_paths:

if isinstance(paths, (list, tuple, set)):
    paths = expand_paths_if_needed(paths, mode, num, fs, name_function)
else:
    if "w" in mode and expand:
        paths = _expand_paths(paths, name_function, num)
    elif "*" in paths:                                                   <------- HERE. Are more tests needed for "?" and "["  ?
        paths = [f for f in sorted(fs.glob(paths)) if not fs.isdir(f)]
    else:
        paths = [paths]

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at get_fs_token_paths and inspect the conditional that only checks for "*", along with the fs.glob call shown in the issue. Add or update tests for ?, [0-9], and existing * patterns, and confirm that open_files expands each pattern as documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
operating-systems
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.