-
-
Notifications
You must be signed in to change notification settings - Fork 75
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 archive into buffer (dict of io.BytesIO()) #111
Closed
Closed
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
68b5d40
Extract archive into buffer (dict of io.BytesIO())
Zoynels 720923e
Update test
Zoynels da585ce
Add additional test for empty archive
Zoynels cb737db
Remove None file
Zoynels 72d9023
Update same delimiter = "/" for filename in Windows and other
Zoynels ccdaa0a
Update test: return_dict in same function as base extractall
Zoynels f14dabe
Update test_extract.py
Zoynels 96f071b
Update test_extract.py
Zoynels d50de2d
Update test_extract.py
Zoynels 49c758e
Update test_extract.py
Zoynels 59923e5
Update test_extract.py
Zoynels f66778b
Merge remote-tracking branch 'upstream/master'
Zoynels 8233f84
fix check
Zoynels 94fc8d4
fix flake8
Zoynels eac4007
@pytest.mark.parametrize('return_dict', [False, True])
Zoynels f935e23
@pytest.mark.parametrize('return_dict', [False, True])
Zoynels 80dfd01
Update test_extract.py
Zoynels 337507f
Update test_extract.py
Zoynels 869be59
Update test_extract.py
Zoynels 4911dc8
type definition
Zoynels 27769b2
Fix type definition
Zoynels 5a1f491
Unite extract_single
Zoynels 3558170
Fix test
Zoynels a046d66
Update extract_single
Zoynels 4727442
Merge branch 'master' into master
miurahr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,7 @@ | |
import stat | ||
import sys | ||
from io import BytesIO | ||
from typing import Any, BinaryIO, Dict, List, Optional, Tuple, Union | ||
from typing import IO, Any, BinaryIO, Dict, List, Optional, Tuple, Union | ||
|
||
from py7zr.archiveinfo import Folder, Header, SignatureHeader | ||
from py7zr.compression import SevenZipCompressor, Worker, get_methods_names | ||
|
@@ -644,15 +644,16 @@ def test(self) -> bool: | |
"""Test archive using CRC digests.""" | ||
return self._test_digests() | ||
|
||
def extractall(self, path: Optional[Any] = None) -> None: | ||
def extractall(self, path: Optional[Any] = None, return_dict: bool = False) -> Optional[Dict[str, IO[Any]]]: | ||
"""Extract all members from the archive to the current working | ||
directory and set owner, modification time and permissions on | ||
directories afterwards. `path' specifies a different directory | ||
to extract to. | ||
""" | ||
return self.extract(path) | ||
return self.extract(path, return_dict=return_dict) | ||
|
||
def extract(self, path: Optional[Any] = None, targets: Optional[List[str]] = None) -> None: | ||
def extract(self, path: Optional[Any] = None, targets: Optional[List[str]] = None, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. keep That keeps method signature and introduce |
||
return_dict: bool = False) -> Optional[Dict[str, IO[Any]]]: | ||
target_junction = [] # type: List[pathlib.Path] | ||
target_sym = [] # type: List[pathlib.Path] | ||
target_files = [] # type: List[Tuple[pathlib.Path, Dict[str, Any]]] | ||
|
@@ -724,7 +725,11 @@ def extract(self, path: Optional[Any] = None, targets: Optional[List[str]] = Non | |
raise Exception("Directory name is existed as a normal file.") | ||
else: | ||
raise Exception("Directory making fails on unknown condition.") | ||
self.worker.extract(self.fp, parallel=(not self.password_protected and not self._filePassed)) | ||
|
||
self.worker.extract(self.fp, parallel=(not self.password_protected and not self._filePassed), | ||
return_dict=return_dict) | ||
if return_dict: | ||
return self.worker._dict | ||
|
||
# create symbolic links on target path as a working directory. | ||
# if path is None, work on current working directory. | ||
|
@@ -746,6 +751,7 @@ def extract(self, path: Optional[Any] = None, targets: Optional[List[str]] = Non | |
|
||
for o, p in target_files: | ||
self._set_file_property(o, p) | ||
return None | ||
|
||
def writeall(self, path: Union[pathlib.Path, str], arcname: Optional[str] = None): | ||
"""Write files in target path into archive.""" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Shall we keep
extractall(self, path)-> None
as is and introducereadall(self, path) -> Dict[str, IO[Any]]
?