Added support for ARC (.arc) archives.
This commit is contained in:
parent
83f355634b
commit
4f12f39834
|
@ -1,6 +1,7 @@
|
||||||
0.7 "" (released xx.xx.xxxx)
|
0.7 "" (released xx.xx.xxxx)
|
||||||
|
|
||||||
* Added support for ALZIP (.alz) archives.
|
* Added support for ALZIP (.alz) archives.
|
||||||
|
* Added support for ARC (.arc) archives.
|
||||||
|
|
||||||
0.6 "Waking Ned" (released 6.3.2010)
|
0.6 "Waking Ned" (released 6.3.2010)
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,8 @@ files without having to remember a myriad of programs and options.
|
||||||
The archive format is determined by the file(1) program and as a fallback
|
The archive format is determined by the file(1) program and as a fallback
|
||||||
by the archive file extension.
|
by the archive file extension.
|
||||||
.PP
|
.PP
|
||||||
\fBpatool\fP supports 7z (.7z), ACE (.ace), ALZIP (.alz), AR (.a), ARJ (.arj),
|
\fBpatool\fP supports 7z (.7z), ACE (.ace), ALZIP (.alz), AR (.a),
|
||||||
|
ARC (.arc), ARJ (.arj),
|
||||||
BZIP2 (.bz2), CAB (.cab), compress (.Z), CPIO (.cpio), DEB (.deb), GZIP (.gz),
|
BZIP2 (.bz2), CAB (.cab), compress (.Z), CPIO (.cpio), DEB (.deb), GZIP (.gz),
|
||||||
LZH (.lha, .lzh), LZIP (.lz), LZMA (.lzma), LZOP (.lzo), RPM (.rpm),
|
LZH (.lha, .lzh), LZIP (.lz), LZMA (.lzma), LZOP (.lzo), RPM (.rpm),
|
||||||
RAR (.rar), TAR (.tar), XZ (.xz) and ZIP (.zip, .jar) formats.
|
RAR (.rar), TAR (.tar), XZ (.xz) and ZIP (.zip, .jar) formats.
|
||||||
|
|
|
@ -18,12 +18,12 @@ DESCRIPTION
|
||||||
The archive format is determined by the file(1) program and as a fall‐
|
The archive format is determined by the file(1) program and as a fall‐
|
||||||
back by the archive file extension.
|
back by the archive file extension.
|
||||||
|
|
||||||
patool supports 7z (.7z), ACE (.ace), ALZIP (.alz), AR (.a), ARJ
|
patool supports 7z (.7z), ACE (.ace), ALZIP (.alz), AR (.a), ARC
|
||||||
(.arj), BZIP2 (.bz2), CAB (.cab), compress (.Z), CPIO (.cpio), DEB
|
(.arc), ARJ (.arj), BZIP2 (.bz2), CAB (.cab), compress (.Z), CPIO
|
||||||
(.deb), GZIP (.gz), LZH (.lha, .lzh), LZIP (.lz), LZMA (.lzma), LZOP
|
(.cpio), DEB (.deb), GZIP (.gz), LZH (.lha, .lzh), LZIP (.lz), LZMA
|
||||||
(.lzo), RPM (.rpm), RAR (.rar), TAR (.tar), XZ (.xz) and ZIP (.zip,
|
(.lzma), LZOP (.lzo), RPM (.rpm), RAR (.rar), TAR (.tar), XZ (.xz) and
|
||||||
.jar) formats. It relies on helper applications to handle those ar‐
|
ZIP (.zip, .jar) formats. It relies on helper applications to handle
|
||||||
chive formats (for example bzip2 for BZIP2 archives).
|
those archive formats (for example bzip2 for BZIP2 archives).
|
||||||
|
|
||||||
EXAMPLES
|
EXAMPLES
|
||||||
patool extract archive.zip otherarchive.rar
|
patool extract archive.zip otherarchive.rar
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
nomarch
|
|
@ -23,21 +23,10 @@ _patool()
|
||||||
|
|
||||||
if [[ "$cur" == -* ]]; then
|
if [[ "$cur" == -* ]]; then
|
||||||
# possible options for the command
|
# possible options for the command
|
||||||
case $command in
|
|
||||||
extract)
|
|
||||||
options='--verbose --force'
|
|
||||||
;;
|
|
||||||
list)
|
|
||||||
options='--verbose'
|
|
||||||
;;
|
|
||||||
test)
|
|
||||||
options='--verbose'
|
|
||||||
;;
|
|
||||||
create)
|
|
||||||
options='--verbose --force'
|
|
||||||
;;
|
|
||||||
formats)
|
|
||||||
options=''
|
options=''
|
||||||
|
case $command in
|
||||||
|
extract|list|test|create)
|
||||||
|
options='--verbose'
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
options="$options --help"
|
options="$options --help"
|
||||||
|
|
|
@ -22,13 +22,13 @@ from patoolib import util
|
||||||
ArchiveCommands = ('list', 'extract', 'test', 'create')
|
ArchiveCommands = ('list', 'extract', 'test', 'create')
|
||||||
|
|
||||||
# Supported archive formats
|
# Supported archive formats
|
||||||
ArchiveFormats = ('gzip', 'bzip2', 'tar', 'zip', 'compress', '7z', 'rar',
|
ArchiveFormats = ('7z', 'ace', 'alzip', 'ar', 'arc', 'arj', 'bzip2',
|
||||||
'cab', 'arj', 'cpio', 'rpm', 'deb', 'lzop', 'lzma', 'xz', 'lzip', 'ace',
|
'cab', 'compress', 'cpio', 'deb', 'gzip', 'lzh', 'lzip', 'lzma',
|
||||||
'ar', 'lzh', 'alzip')
|
'lzop', 'rar', 'rpm', 'tar', 'xz', 'zip')
|
||||||
|
|
||||||
# Supported encodings (used with tar for example)
|
# Supported encodings (used with tar for example)
|
||||||
# Note that all encodings must also be archive formats
|
# Note that all encodings must also be archive formats
|
||||||
ArchiveEncodings = ('gzip', 'bzip2', 'compress', 'lzma', 'xz', 'lzip')
|
ArchiveEncodings = ('bzip2', 'compress', 'gzip', 'lzip', 'lzma', 'xz')
|
||||||
|
|
||||||
# Map MIME types to archive format
|
# Map MIME types to archive format
|
||||||
ArchiveMimetypes = {
|
ArchiveMimetypes = {
|
||||||
|
@ -57,6 +57,7 @@ ArchiveMimetypes = {
|
||||||
'application/x-lha': 'lzh',
|
'application/x-lha': 'lzh',
|
||||||
'application/x-lzh': 'lzh',
|
'application/x-lzh': 'lzh',
|
||||||
'application/x-alzip': 'alzip',
|
'application/x-alzip': 'alzip',
|
||||||
|
'application/x-arc': 'arc',
|
||||||
}
|
}
|
||||||
|
|
||||||
# List of programs supporting the given encoding
|
# List of programs supporting the given encoding
|
||||||
|
@ -86,6 +87,9 @@ ArchivePrograms = {
|
||||||
'ar': {
|
'ar': {
|
||||||
None: ('ar',),
|
None: ('ar',),
|
||||||
},
|
},
|
||||||
|
'arc': {
|
||||||
|
None: ('arc',),
|
||||||
|
},
|
||||||
'bzip2': {
|
'bzip2': {
|
||||||
'extract': ('pbzip2', 'bzip2', '7z'),
|
'extract': ('pbzip2', 'bzip2', '7z'),
|
||||||
'test': ('pbzip2', 'bzip2', '7z'),
|
'test': ('pbzip2', 'bzip2', '7z'),
|
||||||
|
@ -393,15 +397,23 @@ def _handle_archive (archive, command, *args, **kwargs):
|
||||||
# prepare func() call arguments
|
# prepare func() call arguments
|
||||||
kwargs = dict(verbose=config['verbose'])
|
kwargs = dict(verbose=config['verbose'])
|
||||||
outdir = None
|
outdir = None
|
||||||
|
origarchive = None
|
||||||
if command == 'extract':
|
if command == 'extract':
|
||||||
outdir = util.tmpdir(dir=os.getcwd())
|
outdir = util.tmpdir(dir=os.getcwd())
|
||||||
kwargs['outdir'] = outdir
|
kwargs['outdir'] = outdir
|
||||||
|
elif command == 'create' and os.path.basename(program) == 'arc' and \
|
||||||
|
".arc" in archive and not archive.endswith(".arc"):
|
||||||
|
# the arc program mangles the archive name if it contains ".arc"
|
||||||
|
origarchive = archive
|
||||||
|
archive = util.tmpfile(dir=os.path.dirname(archive), suffix=".arc")
|
||||||
try:
|
try:
|
||||||
cmdlist = get_archive_cmdlist(archive, encoding, program, *args, **kwargs)
|
cmdlist = get_archive_cmdlist(archive, encoding, program, *args, **kwargs)
|
||||||
run_archive_cmdlist(cmdlist)
|
run_archive_cmdlist(cmdlist)
|
||||||
if command == 'extract':
|
if command == 'extract':
|
||||||
target = cleanup_outdir(archive, outdir)
|
target = cleanup_outdir(archive, outdir)
|
||||||
print "%s: extracted to %s" % (archive, target)
|
print "%s: extracted to %s" % (archive, target)
|
||||||
|
elif command == 'create' and origarchive:
|
||||||
|
shutil.move(archive, origarchive)
|
||||||
finally:
|
finally:
|
||||||
if outdir:
|
if outdir:
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright (C) 2010 Bastian Kleineidam
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
"""Archive commands for the arc program."""
|
||||||
|
|
||||||
|
def extract_arc (archive, encoding, cmd, **kwargs):
|
||||||
|
"""Extract a ARC archive."""
|
||||||
|
# Since extracted files will be placed in the current directory,
|
||||||
|
# the cwd argument has to be the output directory.
|
||||||
|
cmdlist = [cmd, 'x', archive]
|
||||||
|
return (cmdlist, {'cwd': kwargs['outdir']})
|
||||||
|
|
||||||
|
def list_arc (archive, encoding, cmd, **kwargs):
|
||||||
|
"""List a ARC archive."""
|
||||||
|
cmdlist = [cmd]
|
||||||
|
if kwargs['verbose']:
|
||||||
|
cmdlist.append('v')
|
||||||
|
else:
|
||||||
|
cmdlist.append('l')
|
||||||
|
cmdlist.append(archive)
|
||||||
|
return cmdlist
|
||||||
|
|
||||||
|
def test_arc (archive, encoding, cmd, **kwargs):
|
||||||
|
"""Test a ARC archive."""
|
||||||
|
return [cmd, 't', archive]
|
||||||
|
|
||||||
|
def create_arc (archive, encoding, cmd, *args, **kwargs):
|
||||||
|
"""Create a ARC archive."""
|
||||||
|
cmdlist = [cmd, 'a', archive]
|
||||||
|
cmdlist.extend(args)
|
||||||
|
return cmdlist
|
|
@ -43,6 +43,7 @@ mimedb.add_type('application/x-ace', '.ace', strict=False)
|
||||||
# Since .a is already a common type, strict=True must be used.
|
# Since .a is already a common type, strict=True must be used.
|
||||||
mimedb.add_type('application/x-archive', '.a', strict=True)
|
mimedb.add_type('application/x-archive', '.a', strict=True)
|
||||||
mimedb.add_type('application/x-alzip', '.alz', strict=False)
|
mimedb.add_type('application/x-alzip', '.alz', strict=False)
|
||||||
|
mimedb.add_type('application/x-arc', '.arc', strict=False)
|
||||||
|
|
||||||
|
|
||||||
class PatoolError (StandardError):
|
class PatoolError (StandardError):
|
||||||
|
@ -199,6 +200,7 @@ FileText2Mime = {
|
||||||
"lzip compressed data": "application/x-lzip",
|
"lzip compressed data": "application/x-lzip",
|
||||||
"current ar archive": "application/x-archive",
|
"current ar archive": "application/x-archive",
|
||||||
"LHa ": "application/x-lha",
|
"LHa ": "application/x-lha",
|
||||||
|
"ARC archive data": "application/x-arc",
|
||||||
}
|
}
|
||||||
|
|
||||||
def guess_mime_file_text (file_prog, filename):
|
def guess_mime_file_text (file_prog, filename):
|
||||||
|
@ -245,6 +247,11 @@ def tmpdir (dir=None):
|
||||||
return tempfile.mkdtemp(suffix='', prefix='Unpack_', dir=dir)
|
return tempfile.mkdtemp(suffix='', prefix='Unpack_', dir=dir)
|
||||||
|
|
||||||
|
|
||||||
|
def tmpfile (dir=None, prefix="temp", suffix=None):
|
||||||
|
"""Return a temporary file."""
|
||||||
|
return tempfile.mkstemp(suffix=suffix, prefix=prefix, dir=dir)[1]
|
||||||
|
|
||||||
|
|
||||||
def shell_quote (value):
|
def shell_quote (value):
|
||||||
"""Quote all shell metacharacters in given string value."""
|
"""Quote all shell metacharacters in given string value."""
|
||||||
return '%s' % value
|
return '%s' % value
|
||||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -290,3 +290,8 @@ class TestArchives (ArchiveTest):
|
||||||
def test_lha (self):
|
def test_lha (self):
|
||||||
self.program = 'lha'
|
self.program = 'lha'
|
||||||
self.archive_commands('t.lha')
|
self.archive_commands('t.lha')
|
||||||
|
|
||||||
|
@needs_program('arc')
|
||||||
|
def test_arc (self):
|
||||||
|
self.program = 'arc'
|
||||||
|
self.archive_commands('t.arc', singlefile=True)
|
||||||
|
|
|
@ -335,3 +335,8 @@ class TestArchives (ArchiveTest):
|
||||||
# self.archive_test('t.alz.foo')
|
# self.archive_test('t.alz.foo')
|
||||||
# self.archive_list('t.alz.foo')
|
# self.archive_list('t.alz.foo')
|
||||||
# self.archive_extract('t.alz.foo')
|
# self.archive_extract('t.alz.foo')
|
||||||
|
|
||||||
|
@needs_program('arc')
|
||||||
|
def test_arc (self):
|
||||||
|
self.program = 'arc'
|
||||||
|
self.archive_commands('t.arc.foo', format="arc", singlefile=True)
|
||||||
|
|
|
@ -109,7 +109,8 @@ class TestMime (unittest.TestCase):
|
||||||
# file(1) does not recognize .alz files
|
# file(1) does not recognize .alz files
|
||||||
#self.mime_test_mimedb("t.alz", "application/x-alzip", None)
|
#self.mime_test_mimedb("t.alz", "application/x-alzip", None)
|
||||||
#self.mime_test_mimedb("t.alz.foo", "application/x-alzip", None)
|
#self.mime_test_mimedb("t.alz.foo", "application/x-alzip", None)
|
||||||
|
self.mime_test_file("t.arc", "application/x-arc", None)
|
||||||
|
self.mime_test_file("t.arc.foo", "application/x-arc", None)
|
||||||
|
|
||||||
def test_mime_mimedb (self):
|
def test_mime_mimedb (self):
|
||||||
self.mime_test_mimedb("t.7z", "application/x-7z-compressed", None)
|
self.mime_test_mimedb("t.7z", "application/x-7z-compressed", None)
|
||||||
|
@ -144,3 +145,4 @@ class TestMime (unittest.TestCase):
|
||||||
self.mime_test_mimedb("t.lha", "application/x-lha", None)
|
self.mime_test_mimedb("t.lha", "application/x-lha", None)
|
||||||
self.mime_test_mimedb("t.lzh", "application/x-lzh", None)
|
self.mime_test_mimedb("t.lzh", "application/x-lzh", None)
|
||||||
self.mime_test_mimedb("t.alz", "application/x-alzip", None)
|
self.mime_test_mimedb("t.alz", "application/x-alzip", None)
|
||||||
|
self.mime_test_mimedb("t.arc", "application/x-arc", None)
|
||||||
|
|
Loading…
Reference in New Issue