-
Notifications
You must be signed in to change notification settings - Fork 7
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
Matching filename over paths #72
Comments
1. Split the given path into its components and compare each component with the given pattern (re.split is used) 2. Add exception for double backslash (would cause problems with split) 3. Add tests and documentation 4. Little rearrangement
1. Split the given path into its components and compare each component with the given pattern (re.split is used) 2. Add exception for double backslash (would cause problems with split) 3. Add tests and documentation 4. Little rearrangement
1. Split the given path into its components and compare each component with the given pattern (re.split is used) 2. Add exception for double backslash (would cause problems with split) 3. Add tests and documentation 4. Little rearrangement
@kimt33 I'd like to solve this by using the same syntax as in recursive globbing, which fairly well-established. Recursive glob is supported in the Python standard library in I'd suggest we use the following package: https://pypi.org/project/pywildcard/ Would that work for you? |
The following implementation of recursive glob in an fnmatch-like function seems healthier than pywildcard: https://github.com/facelessuser/wcmatch |
And I'm not sure if I remember correctly, but within the context of If the syntax for the rules changes significantly (i.e. tests get broken), then this should be equivalent to breaking the API and may break some of the existing But either way, I'm on board with either of your suggestions. I thought that the use of |
In
matches_filefilter
,fnmatch
is used to check if the givenfilename
satisfies the given set of patterns using the UNIX filename matching patterns. I'm not too sure if this is correct, but going by how I use filename matching in my terminal (egls
), I would think that*py
search only the current directory,*/*py
would search all directories within the current directory, and so on. However,fnmatch
simply treats the given filename as a string and assumes no directory information. For example,fnmatch('foo/bar.py', '*py')
would returnTrue
. In fact, we can assume thatfnmatch
expects a filename specifically rather than the file path.Right now, each pattern used in
matches_filefilter
should start with*
if the file is located in any of the subdirectories. It's weird that if I want to find all python files (in all directories), my pattern would be*.py
, but if I want all python files that start withtest_
, I would need to write*test_*.py
or*/test_*.py
. I would expect that if*py
is valid,test_*.py
is also valid.The text was updated successfully, but these errors were encountered: