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
tarfile should expose supported formats #58221
Comments
shutil contains high-level functions to create a zipfile or a tarball. When a new format is added to the tarfile module, then shutil needs to be updated manually. If tarfile exposed the names of the compressors it supports, then shutil could just automatically support everything that tarfile supports instead of having to re-do import dances for optional modules (bz2, lzma, zlib) and also duplicate formats in its doc. This may also be useful for other code wanting to do some introspection. Attached patch implements tarfile.formats, a list of strings (I thought about using a frozenset but then followed the precedent set by the 3.3 crypt module). Tests and docs not updated, I wanted to get Lars’ approval on the principle first. One could argue that this is not needed: compression modules are not added often; updating shutil after updating tarfile is not hard; it is not that useful to have access to the list of supported formats. |
I think this is a reasonable proposal. I think it is good style to let tarfile figure out which supported compression methods are available instead of shutil or the user. So far I have no objections. Following 3.3's crypt module, I think the name |
Thanks for the quick reply.
(There will also be ugliness in packaging: Even if I make it transparently supports all formats that shutil supports, I’ll need to have a bit of duplication because packaging has a preferred format by platform. Well.)
BTW I will gladly wait for commits related to the other bugs (misc bugs and misc doc edits) and refresh my patch then. |
I've updated Éric's patch. Minor changes:
|
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: