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

Double Asterisk in File Search #823

Open
JamesHabben opened this issue Sep 26, 2024 · 0 comments
Open

Double Asterisk in File Search #823

JamesHabben opened this issue Sep 26, 2024 · 0 comments
Labels
documentation Improvements or additions to documentation

Comments

@JamesHabben
Copy link
Collaborator

There are quite a few modules that have double asterisk marks at the start of their search pattern. I haven't done any speed tests to see if this impacts anything, but I used the fnmatch module to manually translate the given pattern with the double and removing one of them. The result is the same regex pattern that gets returned, and this is the function we use to translate the file search pattern to a regex for the seeker process. Documenting this here so others can see, and it seems that we can remove the double asterisk ** from modules that have it as we update them for other reasons.

Test code:

>>> import fnmatch
>>>
>>> fnmatch.translate('*asdf*')
'(?s:(?>.*?asdf).*)\\Z'
>>> fnmatch.translate('**asdf*')
'(?s:(?>.*?asdf).*)\\Z'
>>> 
>>> fnmatch.translate('**/Documents/AllTrails.sqlite*')
'(?s:(?>.*?/Documents/AllTrails\\.sqlite).*)\\Z'
>>> fnmatch.translate('*/Documents/AllTrails.sqlite*')
'(?s:(?>.*?/Documents/AllTrails\\.sqlite).*)\\Z'

Example module pattern:
image

@JamesHabben JamesHabben added the documentation Improvements or additions to documentation label Sep 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

1 participant