add --replace-originals flag to extractcode - #1893
Conversation
pombredanne
left a comment
There was a problem hiding this comment.
@maxhbr Thank you ++ for this. The --replace-originals makes perfect sense. Let me reformulate the intent and outcome to make sure we are in sync: this forces a deletion of the extraction target and a new re-extraction of any archive?
PS: do not worry too much about all tests failures just now, Azure can be flaky and I will respin some if needed... BUT still there is something which may not be working OK. See https://ci.appveyor.com/project/nexB/scancode-toolkit/builds/30698997/job/ag1rs0yofobgsfd3#L4406
I think that the --replace-originals does may not honor anymore the recursive extraction flag?
See also some of my comments inline
| + '.' + getattr(extractor, '__name__', '')) | ||
| if extractor: | ||
| yield ExtractEvent(location, target, done=False, warnings=[], errors=[]) | ||
| yield ExtractEvent(location, target if not replace_originals else location, done=False, warnings=[], errors=[]) |
There was a problem hiding this comment.
Why would the target (e.g. where we extract) become the location (what we extract) with replace_originals? that's mostly informative because that what events are about... but still?
There was a problem hiding this comment.
As far as I understand the code, the variables could be the following:
location=a/a.tar.gztarget=a/a.tar.gz-extract
Since my changes extract the content of the file location to the folder location instead of the folder target. I thus think that this change here is correct.
7062806 to
8a34e1e
Compare
Codecov Report
@@ Coverage Diff @@
## develop #1893 +/- ##
===========================================
+ Coverage 78.94% 79.02% +0.08%
===========================================
Files 131 131
Lines 16925 16939 +14
===========================================
+ Hits 13361 13386 +25
+ Misses 3564 3553 -11
Continue to review full report at Codecov.
|
There was is an error in the recursion, I have to fix that. |
I think we are not in sync here. My goal is to change the behavior in the following way: I want to extract "in place" and get: |
8a34e1e to
ffd70a9
Compare
ffd70a9 to
06b5a08
Compare
|
@pombredanne I have updated the description and the intend of this PR. It now no longer tries to do "in place extraction" but instead just removes the original archives after they were extracted. |
@maxhbr I get it... and I am glad I asked. So this becomes a destructive extraction then, but I can see how this makes things simpler towards #14 alright! So I wonder if an approach may be instead to do this:
|
Even better! let me review this tomorrow |
| if TRACE: | ||
| logger.debug('extract:walk: recursing on target: %(target)r' % locals()) | ||
| for xevent in extract(target, kinds, recurse): | ||
| for xevent in extract(target if remove_originals else localtion, kinds, recurse, remove_originals=remove_originals): |
There was a problem hiding this comment.
localtion likely would need to be location...
There was a problem hiding this comment.
Good catch, i though I had fixed that.
06b5a08 to
c3d6f7b
Compare
|
@pombredanne I have now implemented your suggested way of using the events |
pombredanne
left a comment
There was a problem hiding this comment.
@maxhbr Thank you++ for the updates. We are all green 💚 . Please see my minor comments before I merge this!
Signed-off-by: Maximilian Huber <maximilian.huber@tngtech.com>
c3d6f7b to
9fa41f6
Compare
|
@pombredanne the comments are resolved |
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
pombredanne
left a comment
There was a problem hiding this comment.
LGTM... Thank you ++ I made a tiny change to the extract() function docstring and I am merging.
|
Hi @pombredanne, Have a nice day, |
|
@JakobSchubert sure thing! |
This adds the flag
--remove-originalstoextractcode. This modifies the behavior to remove the archive that was extracted from the file tree.Related to: #14
Tasks
Run tests locally to check for errors.