Remove duplicate code.
This commit is contained in:
parent
0d7a90e0f0
commit
9cfc1b1e61
|
@ -20,65 +20,27 @@ From the man page:
|
||||||
but does not need any others.
|
but does not need any others.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def extract_7z (archive, encoding, cmd, **kwargs):
|
from .p7zip import \
|
||||||
"""Extract a 7z archive."""
|
extract_bzip2, \
|
||||||
cmdlist = [cmd, 'x']
|
extract_gzip, \
|
||||||
if not kwargs['verbose']:
|
extract_zip, \
|
||||||
cmdlist.append('-bd')
|
extract_compress, \
|
||||||
cmdlist.extend(['-o%s' % kwargs['outdir'], '--', archive])
|
extract_rar, \
|
||||||
return cmdlist
|
extract_cab, \
|
||||||
|
extract_7z, \
|
||||||
extract_bzip2 = \
|
list_bzip2, \
|
||||||
extract_gzip = \
|
list_gzip, \
|
||||||
extract_zip = \
|
list_zip, \
|
||||||
extract_compress = \
|
list_compress, \
|
||||||
extract_rar = \
|
list_rar, \
|
||||||
extract_cab = \
|
list_cab, \
|
||||||
extract_7z
|
list_rpm, \
|
||||||
|
list_7z, \
|
||||||
def list_7z (archive, encoding, cmd, **kwargs):
|
test_bzip2, \
|
||||||
"""List a 7z archive."""
|
test_gzip, \
|
||||||
cmdlist = [cmd, 'l']
|
test_zip, \
|
||||||
if not kwargs['verbose']:
|
test_compress, \
|
||||||
cmdlist.append('-bd')
|
test_rar, \
|
||||||
cmdlist.append('--')
|
test_cab, \
|
||||||
cmdlist.append(archive)
|
test_7z, \
|
||||||
return cmdlist
|
create_7z
|
||||||
|
|
||||||
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
|
|
||||||
|
|
|
@ -15,29 +15,4 @@
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
"""Archive commands for the unrar program."""
|
"""Archive commands for the unrar program."""
|
||||||
|
|
||||||
def extract_rar (archive, encoding, cmd, **kwargs):
|
from .rar import extract_rar, list_rar, test_rar
|
||||||
"""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
|
|
||||||
|
|
Loading…
Reference in New Issue