-
-
Notifications
You must be signed in to change notification settings - Fork 756
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
Extract pattern support #575
Extract pattern support #575
Conversation
Current coverage is
|
@@ -129,6 +129,11 @@ def do_change_passphrase(self, args): | |||
|
|||
def do_create(self, args): | |||
"""Create new archive""" | |||
matcher = PatternMatcher() | |||
matcher.fallback = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could that be done in __init__
? Do you mean fallback or _fallback?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An earlier version of PatternMatcher
only supported booleans and was much more complicated. The current implementation is simpler and supports any fallback value type. For this reason the default is None
and needs to be overwritten here.
I've changed PatternMatcher
to directly expose fallback
instead of doing so via a property as it's no longer necessary with the simplified version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, but why is it not PatternMatcher(fallback=True)?
ok, guess I am through with it. i didn't look at all test cases, though. |
- Stop using “adjust_pattern” and “exclude_path” as they're utility functions not relevant to testing pattern classes - Cover a few more cases, especially with more than one path separator and relative paths - At least one dedicated test function for each pattern style as opposed to a single, big test mixing styles - Use positive instead of negative matching (i.e. the expected list of resulting items is a list of items matching a pattern)
The utility functions “adjust_patterns” and “exclude_path” produce respectively use a standard list object containing pattern objects. With the forthcoming introduction of patterns for filtering files to be extracted it's better to move the logic of these classes into a single class. The wrapper allows adding any number of patterns to an internal list together with a value to be returned if a match function finds that one of the patterns matches. A fallback value is returned otherwise.
The newly added pattern matcher class can replace the “exclude_path” function. The latter is going to be removed in a later change.
The prefix used for pattern styles should be kept together with the respective style implementation.
A function to parse pattern specifications was introduced in commit 2bafece. Since then it had a hardcoded default style of “fm”, meaning fnmatch. With the forthcoming support for extracting files using patterns this default style must be more flexible.
The “extract” command supports extracting all files underneath a given set of prefix paths. The forthcoming support for extracting files using a pattern (i.e. only files ending in “.zip”) requires the introduction of path prefixes as a third pattern style, making it also available for exclusions.
This change implements the functionality requested in issue #361: extracting files with a given extension. It does so by permitting patterns to be used instead plain prefix paths. The pattern styles supported are the same as for exclusions.
Remove the “adjust_pattern” and “exclude_path” functions and replace them with the recently introduced pattern matcher class.
Extract pattern support
Implement the request for pattern support on file extraction from issue #361.