[issue19214] shutil.make_archive should recognize extensions in filenames
William Tisäter
report at bugs.python.org
Wed Apr 30 00:35:47 CEST 2014
William Tisäter added the comment:
I'm not sure if this is a suitable feature in `make_archive()`, it would only introduce a more expensive and ugly lookup. Using this method with a pre-defined filename including extension must be rare. If you really want this behaviour, I would prefer having this helper instead:
def make_archive(filename, **kwargs):
for fmt, ext, info in shutil.get_unpack_formats():
if not filename.lower().endswith(tuple(ext)):
continue
return shutil.make_archive(filename[:-len(ext)], fmt, **kwargs)
raise ValueError("Unknown archive format: %s" % filename)
Not sure what version you are using, `get_unpack_formats()` got introduced in 3.2.
----------
nosy: +tiwilliam
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue19214>
_______________________________________
More information about the Python-bugs-list
mailing list