-
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
Match filename rather than paths #73
base: master
Are you sure you want to change the base?
Conversation
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
ab47b53
to
aa56061
Compare
Codecov Report
@@ Coverage Diff @@
## master #73 +/- ##
==========================================
+ Coverage 98.13% 98.16% +0.03%
==========================================
Files 17 17
Lines 642 655 +13
Branches 93 94 +1
==========================================
+ Hits 630 643 +13
Misses 12 12
Continue to review full report at Codecov.
|
Good idea but we need to work out a few more details. Can you explain the purpose of the double backslash? Some of the tests are not really in line with expected behavior on a bash terminal, e.g. I would expect The best way to implement this is to translate the pattern into one regular expression that works on the entire path name and gives a match or not. This is an example implementation of that idea: https://github.com/metagriffin/globre |
P.S. When you put "Fixes #72" in the first message of your PR, that issue will get closed automatically when the PR is merged. This is better than putting it in the PR title because that only adds confusion, namely having two numbers appearing on the title line. |
Oh, something we shouldn't forget: when we merge a change like this, we should do it at a moment where we can fix all the repositories that rely on the current behavior. |
I thought the backslash will cause some problems later on for someone that would use a character with a backslash. I mainly thought of it for people that would use spaces in the filename, like So then the question is to support it or not because these crazy names violate some sort of PEP or law of nature. I thought it should be supported because these names should be caught (hopefully) by some linter anyways and the functionality of the method is to filter out names with the given pattern (and not to judge the user for their unconventional naming practices). The complexity introduced to the code wasn't that terrible (i.e. using regular expression) in exchange for slight generality, so I thought it was okay. |
Thank you, it does make things a bit ugly. I thought that adding the issue number will link the PR to the issue but that can be done somewhere in the text and not in the title. |
I like the I just thought that since statements like I just checked the rsync documentation and I think they do the same thing (I think):
|
@tovrstra I remembered the purpose of the double backslash. The code works by dividing up the given path (as a string) into the contributing directories (and subdirectories) and/or the filename. The path is "decomposed" by splitting it by the However, if the directory name or the filename contains the However, if a directory name ends with a double backslash, e.g. |
ok. I understand. Thanks for explaining. |
with the given pattern (re.split is used)