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

Extract pattern support #575

Merged
merged 9 commits into from
Jan 18, 2016
Merged

Extract pattern support #575

merged 9 commits into from
Jan 18, 2016

Conversation

hansmi
Copy link
Contributor

@hansmi hansmi commented Jan 18, 2016

Implement the request for pattern support on file extraction from issue #361.

@codecov-io
Copy link

Current coverage is 83.21%

Merging #575 into master will increase coverage by +0.02% as of e92691f

@@            master    #575   diff @@
======================================
  Files           13      13       
  Stmts         3951    3967    +16
  Branches       685     689     +4
  Methods          0       0       
======================================
+ Hit           3287    3301    +14
- Partial        204     205     +1
- Missed         460     461     +1

Review entire Coverage Diff as of e92691f


Uncovered Suggestions

  1. +0.37% via borg/helpers.py#795...809
  2. +0.32% via borg/archiver.py#392...404
  3. +0.27% via borg/key.py#407...417
  4. See 7 more...

Powered by Codecov. Updated on successful CI builds.

@@ -129,6 +129,11 @@ def do_change_passphrase(self, args):

def do_create(self, args):
"""Create new archive"""
matcher = PatternMatcher()
matcher.fallback = True
Copy link
Member

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?

Copy link
Contributor Author

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

Copy link
Member

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)?

@ThomasWaldmann
Copy link
Member

ok, guess I am through with it. i didn't look at all test cases, though.
one last round of minor fixes and then merge?

- 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.
ThomasWaldmann added a commit that referenced this pull request Jan 18, 2016
@ThomasWaldmann ThomasWaldmann merged commit 1e1812c into borgbackup:master Jan 18, 2016
@hansmi hansmi deleted the extract-pattern-support branch January 19, 2016 09:11
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

Successfully merging this pull request may close these issues.

3 participants