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

Add support for recursive flag in glob/glob_ext #293

Open
ghost opened this issue Jun 26, 2023 · 2 comments
Open

Add support for recursive flag in glob/glob_ext #293

ghost opened this issue Jun 26, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@ghost
Copy link

ghost commented Jun 26, 2023

Hi,

I have run into the following problem. When using glob or glob_ext files are only discovered within the first sub-directory, so there seems to be no real recursion. Is this intended?

Example:

>>> t = Target.open("test/2020JimmyWilson.E01")

>>> for h in t.fs.glob("/sysvol/Users/Jimmy Wilson/Desktop/Robert Ripoff/Shesa*"):
            print(h)

Output: /sysvol/Users/Jimmy Wilson/Desktop/Robert Ripoff/Shesa Hippo.jpg

>>> for h in t.fs.glob("/sysvol/Users/Jimmy Wilson/Desktop/**/Shesa*"):
            print(h)

Output: /sysvol/Users/Jimmy Wilson/Desktop/Robert Ripoff/Shesa Hippo.jpg

>>> for h in t.fs.glob("/sysvol/Users/Jimmy Wilson/**/Shesa*"):
            print(h)

Output:

@Schamper
Copy link
Member

Schamper commented Jun 26, 2023

Hi @ruukaku!

The t.fs.glob and t.fs.glob_ext functions should behave similarly to the Python glob module. It does indeed look like we do not yet support the recursive=True flag that it documented for that module. That's something we could definitely add.

However, it's recommended that you actually use the pathlib API to access the filesystem contents:

t.fs.path("sysvol/Users/Jimmy Wilson").rglob("Shesa*")

Pretty much all read-only functionality that is documented for the official pathlib module will work. A TargetPath object returned from t.fs.path("/") will behave the same as a pathlib.Path object! In fact, isinstance(t.fs.path("/"), pathlib.Path) == True.

@ghost
Copy link
Author

ghost commented Jun 26, 2023

The t.fs.glob and t.fs.glob_ext functions should behave similarly to the Python glob module. It does indeed look like we do not yet support the recursive=True flag that it documented for that module. That's something we could definitely add.

I would very much appreciate that :)

However, it's recommended that you actually use the pathlib API to access the filesystem contents:

Thanks for the recommendation

@Schamper Schamper added the enhancement New feature or request label Jun 26, 2023
@Schamper Schamper changed the title Recursion missing in glob(_ext) Add support for recursive flag in glob/glob_ext Jun 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant