From 40639cb172fa1801ebd121152bb2e9159aa7c255 Mon Sep 17 00:00:00 2001 From: Bastian Kleineidam Date: Wed, 23 May 2012 05:19:27 +0200 Subject: [PATCH] Fix tar compression options. --- patoolib/programs/star.py | 17 +---------------- patoolib/programs/tar.py | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/patoolib/programs/star.py b/patoolib/programs/star.py index 384ff73..e51755d 100644 --- a/patoolib/programs/star.py +++ b/patoolib/programs/star.py @@ -14,6 +14,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the star program.""" +from .tar import add_tar_opts as add_star_opts def extract_tar (archive, compression, cmd, **kwargs): """Extract a TAR archive.""" @@ -38,19 +39,3 @@ def create_tar (archive, compression, cmd, *args, **kwargs): cmdlist.append("file=%s" % archive) cmdlist.extend(args) return cmdlist - -def add_star_opts (cmdlist, compression, verbose): - """Add default options for the star program.""" - # Note that star autodetects compression compression, but displays a warning - # which we want to avoid. - if compression == 'gzip': - cmdlist.append('-z') - elif compression == 'compress': - cmdlist.append('-Z') - elif compression == 'bzip2': - cmdlist.append('-bz') - elif compression in ('lzma', 'xz', 'lzip'): - # use compress-program option - cmdlist.append('compress-program=%s' % compression) - if verbose: - cmdlist.append('-v') diff --git a/patoolib/programs/tar.py b/patoolib/programs/tar.py index 2a775a9..997140e 100644 --- a/patoolib/programs/tar.py +++ b/patoolib/programs/tar.py @@ -40,10 +40,17 @@ def create_tar (archive, compression, cmd, *args, **kwargs): return cmdlist def add_tar_opts (cmdlist, compression, verbose): - if compression == 'lzip': - # use compress-program option - cmdlist.extend(['--use-compress-program', compression]) - elif compression: - cmdlist.append('--%s' % compression) + if compression == 'gzip': + cmdlist.append('-z') + elif compression == 'compress': + cmdlist.append('-Z') + elif compression == 'bzip2': + cmdlist.append('-j') + elif compression in ('lzma', 'xz', 'lzip'): + # use the compression name as program name since + # tar is picky which programs it can use + program = compression + # set compression program + cmdlist.extend(['--use-compress-program', program]) if verbose: cmdlist.append('--verbose')