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

glob on windows local file system produces different results to glob.glob #389

Open
simonm3 opened this issue Apr 30, 2020 · 3 comments
Open

Comments

@simonm3
Copy link

simonm3 commented Apr 30, 2020

Is glob intended to produce same results as glob.glob? They seem to be different at least on windows local file system.

import fs
from glob import glob
local = fs.open_fs("")
glob("test"), [x.path for x in local.glob("test")]

(['test'], [])
#####################################

glob("test/*"), [x.path for x in local.glob("test/*")]
(['test\pilot'], ['/test/'])

#####################################
[x.path for x in local.glob("test/**")]
produces same results as glob("test/**", recursive=True) but takes over 6 seconds whereas native glob takes 3ms!

@simonm3
Copy link
Author

simonm3 commented Apr 30, 2020

It seems pyfilesystem2 matches files only but glob.glob matches folders as well.

@lurch
Copy link
Contributor

lurch commented Apr 30, 2020

I dunno what the intended PyFilesystem behaviour is, but the documentation is unfortunately a bit ambiguous. 😕 It says both "If the glob pattern ends in a /, it will only match directory paths, otherwise it will match files and directories." and also "* Matches all files in the current directory."

@smheidrich
Copy link

It's not just on Windows. On Linux too * should match files and directories, but PyFilesystem's glob yields only files... is there any kind of system where people would expect * to match files only?

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

3 participants