Honor outdir option in tarfile and zipfile Python modules.
This commit is contained in:
parent
6f61f5816f
commit
8f922c5077
|
@ -27,10 +27,9 @@ def extract_bzip2 (archive, compression, cmd, **kwargs):
|
|||
"""Extract a BZIP2 archive with the bz2 Python module."""
|
||||
verbose = kwargs['verbose']
|
||||
outdir = kwargs['outdir']
|
||||
# XXX honor outdir
|
||||
if verbose:
|
||||
util.log_info('extracting %s...' % archive)
|
||||
targetname = util.get_single_outfile(kwargs['outdir'], archive)
|
||||
targetname = util.get_single_outfile(outdir, archive)
|
||||
bz2file = bz2.BZ2File(archive)
|
||||
try:
|
||||
targetfile = open(targetname, 'wb')
|
||||
|
|
|
@ -25,10 +25,9 @@ def extract_gzip (archive, compression, cmd, **kwargs):
|
|||
"""Extract a GZIP archive with the gzip Python module."""
|
||||
verbose = kwargs['verbose']
|
||||
outdir = kwargs['outdir']
|
||||
# XXX honor outdir
|
||||
if verbose:
|
||||
util.log_info('extracting %s...' % archive)
|
||||
targetname = util.get_single_outfile(kwargs['outdir'], archive)
|
||||
targetname = util.get_single_outfile(outdir, archive)
|
||||
gzipfile = gzip.GzipFile(archive)
|
||||
try:
|
||||
targetfile = open(targetname, 'wb')
|
||||
|
|
|
@ -38,12 +38,11 @@ def extract_tar (archive, compression, cmd, **kwargs):
|
|||
"""Extract a TAR archive with the tarfile Python module."""
|
||||
verbose = kwargs['verbose']
|
||||
outdir = kwargs['outdir']
|
||||
# XXX honor outdir
|
||||
if verbose:
|
||||
util.log_info('extracting %s...' % archive)
|
||||
tfile = tarfile.open(archive)
|
||||
try:
|
||||
tfile.extractall()
|
||||
tfile.extractall(path=outdir)
|
||||
finally:
|
||||
tfile.close()
|
||||
if verbose:
|
||||
|
|
|
@ -39,12 +39,11 @@ def extract_zip (archive, compression, cmd, **kwargs):
|
|||
"""Extract a ZIP archive with the zipfile Python module."""
|
||||
verbose = kwargs['verbose']
|
||||
outdir = kwargs['outdir']
|
||||
# XXX honor outdir
|
||||
if verbose:
|
||||
util.log_info('extracting %s...' % archive)
|
||||
zfile = zipfile.ZipFile(archive)
|
||||
try:
|
||||
zfile.extractall()
|
||||
zfile.extractall(outdir)
|
||||
finally:
|
||||
zfile.close()
|
||||
if verbose:
|
||||
|
|
Loading…
Reference in New Issue