-
-
Notifications
You must be signed in to change notification settings - Fork 32.9k
gh-75203: Add support for custom compressor in tarfile #2734
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
Conversation
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA). Unfortunately we couldn't find an account corresponding to your GitHub username on bugs.python.org (b.p.o) to verify you have signed the CLA (this might be simply due to a missing "GitHub Name" entry in your b.p.o account settings). This is necessary for legal reasons before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. Thanks again to your contribution and we look forward to looking at it! |
Update my account on BPO to include my github handle, should be ok now |
Any chance this could get a look? |
Thanks for the PR. The changes proposed aren't considered trivial, and requires an issue to be created in https://bugs.python.org Can you first create the issue? Thanks. |
Sure! Just created http://bugs.python.org/issue31020 |
What are the next steps here? I created the bug on BPO, not sure if now it's just matter of waiting until someone looks at the issue or if there's something to be done on my side. Thanks! |
This PR is stale because it has been open for 30 days with no activity. |
This PR is stale because it has been open for 30 days with no activity. |
To use a custom compressor, pass a file-like object like Sorry for the delay in responding. Hopefully, it's better late than never. |
Exposed interface to specify a custom compressor for
tarfile
.To achieve this, a new compression type, "custom", and a new keyword argument
compressor
have been added. The compressor has to be a callable with the interface as explained below.This change just exposes the internal interface. Ideally the interface should be simpler, and just require an input and an output streams to compress/decompress and some modifiers. Additionally the classmethod is not necessary and any callable with the below interface should work. This could be done iteratively in a subsequent commit.
The compressor has to be a class method that takes as input
cls
,name
,mode
,fileobj
,compresslevel
and**kwargs
. This is exactly the same interface as the open methods referenced by OPEN_METH in tarfile.py, e.g.TarFile.gzipopen
orTarFile.bz2open
.The stream interface via the internal
_Stream
class is not exposed. As a consequence it is not possible to specify a compressor that uses such interface.https://bugs.python.org/issue31020