Honor outdir option in tarfile and zipfile Python modules.

This commit is contained in:
Bastian Kleineidam 2012-05-23 19:55:42 +02:00
parent 6f61f5816f
commit 8f922c5077
4 changed files with 4 additions and 8 deletions

View File

@ -27,10 +27,9 @@ def extract_bzip2 (archive, compression, cmd, **kwargs):
"""Extract a BZIP2 archive with the bz2 Python module.""" """Extract a BZIP2 archive with the bz2 Python module."""
verbose = kwargs['verbose'] verbose = kwargs['verbose']
outdir = kwargs['outdir'] outdir = kwargs['outdir']
# XXX honor outdir
if verbose: if verbose:
util.log_info('extracting %s...' % archive) 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) bz2file = bz2.BZ2File(archive)
try: try:
targetfile = open(targetname, 'wb') targetfile = open(targetname, 'wb')

View File

@ -25,10 +25,9 @@ def extract_gzip (archive, compression, cmd, **kwargs):
"""Extract a GZIP archive with the gzip Python module.""" """Extract a GZIP archive with the gzip Python module."""
verbose = kwargs['verbose'] verbose = kwargs['verbose']
outdir = kwargs['outdir'] outdir = kwargs['outdir']
# XXX honor outdir
if verbose: if verbose:
util.log_info('extracting %s...' % archive) 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) gzipfile = gzip.GzipFile(archive)
try: try:
targetfile = open(targetname, 'wb') targetfile = open(targetname, 'wb')

View File

@ -38,12 +38,11 @@ def extract_tar (archive, compression, cmd, **kwargs):
"""Extract a TAR archive with the tarfile Python module.""" """Extract a TAR archive with the tarfile Python module."""
verbose = kwargs['verbose'] verbose = kwargs['verbose']
outdir = kwargs['outdir'] outdir = kwargs['outdir']
# XXX honor outdir
if verbose: if verbose:
util.log_info('extracting %s...' % archive) util.log_info('extracting %s...' % archive)
tfile = tarfile.open(archive) tfile = tarfile.open(archive)
try: try:
tfile.extractall() tfile.extractall(path=outdir)
finally: finally:
tfile.close() tfile.close()
if verbose: if verbose:

View File

@ -39,12 +39,11 @@ def extract_zip (archive, compression, cmd, **kwargs):
"""Extract a ZIP archive with the zipfile Python module.""" """Extract a ZIP archive with the zipfile Python module."""
verbose = kwargs['verbose'] verbose = kwargs['verbose']
outdir = kwargs['outdir'] outdir = kwargs['outdir']
# XXX honor outdir
if verbose: if verbose:
util.log_info('extracting %s...' % archive) util.log_info('extracting %s...' % archive)
zfile = zipfile.ZipFile(archive) zfile = zipfile.ZipFile(archive)
try: try:
zfile.extractall() zfile.extractall(outdir)
finally: finally:
zfile.close() zfile.close()
if verbose: if verbose: