Remove duplicate code.

This commit is contained in:
Bastian Kleineidam 2010-11-15 21:29:51 +01:00
parent 0d7a90e0f0
commit 9cfc1b1e61
2 changed files with 25 additions and 88 deletions

View File

@ -20,65 +20,27 @@ From the man page:
but does not need any others.
"""
def extract_7z (archive, encoding, cmd, **kwargs):
"""Extract a 7z archive."""
cmdlist = [cmd, 'x']
if not kwargs['verbose']:
cmdlist.append('-bd')
cmdlist.extend(['-o%s' % kwargs['outdir'], '--', archive])
return cmdlist
extract_bzip2 = \
extract_gzip = \
extract_zip = \
extract_compress = \
extract_rar = \
extract_cab = \
extract_7z
def list_7z (archive, encoding, cmd, **kwargs):
"""List a 7z archive."""
cmdlist = [cmd, 'l']
if not kwargs['verbose']:
cmdlist.append('-bd')
cmdlist.append('--')
cmdlist.append(archive)
return cmdlist
list_bzip2 = \
list_gzip = \
list_zip = \
list_compress = \
list_rar = \
list_cab = \
list_rpm = \
list_7z
def test_7z (archive, encoding, cmd, **kwargs):
"""Test a 7z archive."""
cmdlist = [cmd, 't']
if not kwargs['verbose']:
cmdlist.append('-bd')
cmdlist.append('--')
cmdlist.append(archive)
return cmdlist
test_bzip2 = \
test_gzip = \
test_zip = \
test_compress = \
test_rar = \
test_cab = \
test_7z
def create_7z (archive, encoding, cmd, *args, **kwargs):
"""Create a 7z archive."""
cmdlist = [cmd, 'a']
if not kwargs['verbose']:
cmdlist.append('-bd')
cmdlist.append('--')
cmdlist.append(archive)
cmdlist.extend(args)
return cmdlist
from .p7zip import \
extract_bzip2, \
extract_gzip, \
extract_zip, \
extract_compress, \
extract_rar, \
extract_cab, \
extract_7z, \
list_bzip2, \
list_gzip, \
list_zip, \
list_compress, \
list_rar, \
list_cab, \
list_rpm, \
list_7z, \
test_bzip2, \
test_gzip, \
test_zip, \
test_compress, \
test_rar, \
test_cab, \
test_7z, \
create_7z

View File

@ -15,29 +15,4 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""Archive commands for the unrar program."""
def extract_rar (archive, encoding, cmd, **kwargs):
"""Extract a RAR archive."""
cmdlist = [cmd, 'x']
if not kwargs['verbose']:
cmdlist.append('-c-')
cmdlist.extend(['-r', '--', archive, kwargs['outdir']])
return cmdlist
def list_rar (archive, encoding, cmd, **kwargs):
"""List a RAR archive."""
cmdlist = [cmd]
if kwargs['verbose']:
cmdlist.append('v')
else:
cmdlist.append('l')
cmdlist.append('-c-')
cmdlist.extend(['--', archive])
return cmdlist
def test_rar (archive, encoding, cmd, **kwargs):
"""Test a RAR archive."""
cmdlist = [cmd, 't']
if not kwargs['verbose']:
cmdlist.append('-c-')
cmdlist.extend(['--', archive])
return cmdlist
from .rar import extract_rar, list_rar, test_rar