Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

not all globstrings are supported in open_files #957

Open
ghislainp opened this issue May 2, 2022 · 2 comments
Open

not all globstrings are supported in open_files #957

ghislainp opened this issue May 2, 2022 · 2 comments

Comments

@ghislainp
Copy link
Contributor

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]
@martindurant
Copy link
Member

You are right, that line could probably use a glob.has_magic function call checking for all the characters that imply glob expansion should happen.

@martindurant
Copy link
Member

(please feel free to make a PR with this change)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants