Added support for ACE (.ace) archives.

This commit is contained in:
Bastian Kleineidam 2010-03-06 15:47:00 +01:00
parent 670d5df652
commit 9a04371f07
12 changed files with 81 additions and 9 deletions

View File

@ -3,9 +3,10 @@
* Remove the --force option. Local files are now never overwritten.
* Added option alias -v for --verbose.
* Added --verbose option to create command.
* Added support for Extract, list and test multiple archives.
* Added support for extracting, listing and testing multiple archives.
* Fix permissions of extracted files: make them readable by the
current user.
* Added support for ACE (.ace) archives.
0.5 "Vanishing Point" (released 4.3.2010)

View File

@ -26,7 +26,7 @@ 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
by the archive file extension.
.PP
\fBpatool\fP supports 7z (.7z), ZIP (.zip, .jar), GZIP (.gz), compress (.Z),
\fBpatool\fP supports 7z (.7z), ACE (.ace), ZIP (.zip, .jar), GZIP (.gz), compress (.Z),
BZIP2 (.bz2), TAR (.tar), ARJ (.arj), CAB (.cab), CPIO (.cpio),
RPM (.rpm), DEB (.deb), LZIP (.lz), LZOP (.lzo), LZMA (.lzma), RAR (.rar)
and XZ (.xz) formats.

View File

@ -18,11 +18,11 @@ DESCRIPTION
The archive format is determined by the file(1) program and as a fall
back by the archive file extension.
patool supports 7z (.7z), ZIP (.zip, .jar), GZIP (.gz), compress (.Z),
BZIP2 (.bz2), TAR (.tar), ARJ (.arj), CAB (.cab), CPIO (.cpio), RPM
(.rpm), DEB (.deb), LZIP (.lz), LZOP (.lzo), LZMA (.lzma), RAR (.rar)
and XZ (.xz) formats. It relies on helper applications to handle those
archive formats (for example bzip2 for BZIP2 archives).
patool supports 7z (.7z), ACE (.ace), ZIP (.zip, .jar), GZIP (.gz),
compress (.Z), BZIP2 (.bz2), TAR (.tar), ARJ (.arj), CAB (.cab), CPIO
(.cpio), RPM (.rpm), DEB (.deb), LZIP (.lz), LZOP (.lzo), LZMA (.lzma),
RAR (.rar) and XZ (.xz) formats. It relies on helper applications to
handle those archive formats (for example bzip2 for BZIP2 archives).
EXAMPLES
patool extract archive.zip otherarchive.rar

View File

@ -1,3 +1,2 @@
- Support ace (unace) archives.
- Support ar archives.
- Support lha archives.

View File

@ -23,7 +23,7 @@ ArchiveCommands = ('list', 'extract', 'test', 'create')
# Supported archive formats
ArchiveFormats = ('gzip', 'bzip2', 'tar', 'zip', 'compress', '7z', 'rar',
'cab', 'arj', 'cpio', 'rpm', 'deb', 'lzop', 'lzma', 'xz', 'lzip')
'cab', 'arj', 'cpio', 'rpm', 'deb', 'lzop', 'lzma', 'xz', 'lzip', 'ace')
# Supported encodings (used with tar for example)
# Note that all encodings must also be archive formats
@ -51,6 +51,7 @@ ArchiveMimetypes = {
'application/x-lzma': 'lzma',
'application/x-xz': 'xz',
'application/x-lzip': 'lzip',
'application/x-ace': 'ace',
}
# List of programs supporting the given encoding
@ -67,6 +68,11 @@ EncodingPrograms = {
# List of programs supporting the given archive format and command.
# If command is None, the program supports all commands (list, extract, ...)
ArchivePrograms = {
'ace': {
'extract': ('unace',),
'test': ('unace',),
'list': ('unace',),
},
'bzip2': {
'extract': ('pbzip2', 'bzip2', '7z'),
'test': ('pbzip2', 'bzip2', '7z'),

View File

@ -0,0 +1,47 @@
# -*- 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 unace program."""
def extract_ace (archive, encoding, cmd, **kwargs):
"""Extract a ACE archive."""
cmdlist = [cmd]
cmdlist.append('x')
if not kwargs['verbose']:
cmdlist.append('-c-')
cmdlist.extend([archive, kwargs['outdir']])
return cmdlist
def list_ace (archive, encoding, cmd, **kwargs):
"""List a ACE archive."""
cmdlist = [cmd]
if kwargs['verbose']:
cmdlist.append('v')
else:
cmdlist.append('l')
cmdlist.append('-c-')
cmdlist.extend([archive])
return cmdlist
def test_ace (archive, encoding, cmd, **kwargs):
"""Test a ACE archive."""
cmdlist = [cmd]
cmdlist.append('t')
if not kwargs['verbose']:
cmdlist.append('-c-')
cmdlist.extend([archive])
return cmdlist

View File

@ -39,6 +39,7 @@ mimedb.add_type('application/x-7z-compressed', '.7z', strict=False)
mimedb.add_type('application/x-cab', '.cab', strict=False)
mimedb.add_type('application/x-rpm', '.rpm', strict=False)
mimedb.add_type('application/x-debian-package', '.deb', strict=False)
mimedb.add_type('application/x-ace', '.ace', strict=False)
class PatoolError (StandardError):
@ -174,6 +175,7 @@ def get_file_mime_encoding (parts):
# Match file(1) output text to mime types
FileText2Mime = {
"7-zip archive data": "application/x-7z-compressed",
"ACE archive data": "application/x-ace",
"ARJ archive data": "application/x-arj",
"bzip2 compressed data": "application/x-bzip2",
"cpio archive": "application/x-cpio",

BIN
tests/data/t.ace Normal file

Binary file not shown.

BIN
tests/data/t.ace.foo Normal file

Binary file not shown.

View File

@ -219,6 +219,13 @@ class TestArchives (ArchiveTest):
self.archive_extract('t.cpio')
self.archive_create('t.cpio')
@needs_program('unace')
def test_unace (self):
self.program = 'unace'
self.archive_list('t.ace')
self.archive_test('t.ace')
self.archive_extract('t.ace')
@needs_program('rpm')
def test_rpm (self):
self.program = 'rpm'

View File

@ -251,6 +251,14 @@ class TestArchives (ArchiveTest):
self.archive_extract('t.cpio.foo')
self.archive_create('t.cpio.foo', format="cpio")
@needs_program('file')
@needs_program('unace')
def test_unace (self):
self.program = 'unace'
self.archive_list('t.ace.foo')
self.archive_test('t.ace.foo')
self.archive_extract('t.ace.foo')
@needs_program('file')
@needs_program('rpm')
def test_rpm (self):

View File

@ -86,3 +86,5 @@ class TestMime (unittest.TestCase):
self.mime_test("t.Z.foo", "application/x-compress", None)
self.mime_test("t.zip", "application/zip", None)
self.mime_test("t.zip.foo", "application/zip", None)
self.mime_test("t.ace", "application/x-ace", None)
self.mime_test("t.ace.foo", "application/x-ace", None)