diff --git a/doc/changelog.txt b/doc/changelog.txt index 0076b3d..042c7ea 100644 --- a/doc/changelog.txt +++ b/doc/changelog.txt @@ -8,6 +8,7 @@ current user. * Added support for ACE (.ace) archives. * Added support for AR (.a) archives. + * Added support for LZH (.lha, .lzh) archives. 0.5 "Vanishing Point" (released 4.3.2010) diff --git a/doc/patool.1 b/doc/patool.1 index 7058060..7615314 100644 --- a/doc/patool.1 +++ b/doc/patool.1 @@ -26,10 +26,11 @@ 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), ACE (.ace), AR (.a), ZIP (.zip, .jar), GZIP (.gz), compress (.Z), +\fBpatool\fP supports 7z (.7z), ACE (.ace), AR (.a), 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. +RPM (.rpm), DEB (.deb), LZH (.lha, .lzh), 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). .SH EXAMPLES diff --git a/doc/todo.txt b/doc/todo.txt index e05ddbb..e69de29 100644 --- a/doc/todo.txt +++ b/doc/todo.txt @@ -1 +0,0 @@ -- Support lha archives. diff --git a/patoolib/__init__.py b/patoolib/__init__.py index 5e375e8..2401be5 100644 --- a/patoolib/__init__.py +++ b/patoolib/__init__.py @@ -24,7 +24,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', 'ace', - 'ar') + 'ar', 'lzh') # Supported encodings (used with tar for example) # Note that all encodings must also be archive formats @@ -54,6 +54,8 @@ ArchiveMimetypes = { 'application/x-lzip': 'lzip', 'application/x-ace': 'ace', 'application/x-archive': 'ar', + 'application/x-lha': 'lzh', + 'application/x-lzh': 'lzh', } # List of programs supporting the given encoding @@ -96,6 +98,9 @@ ArchivePrograms = { 'gzip': { None: ('gzip', '7z'), }, + 'lzh': { + None: ('lha',), + }, 'lzip': { 'extract': ('lzip',), 'list': ('echo',), diff --git a/patoolib/programs/lha.py b/patoolib/programs/lha.py new file mode 100644 index 0000000..37fc46e --- /dev/null +++ b/patoolib/programs/lha.py @@ -0,0 +1,56 @@ +# -*- 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 . +"""Archive commands for the lha program.""" + +def extract_lzh (archive, encoding, cmd, **kwargs): + """Extract a LZH archive.""" + cmdlist = [cmd] + opts = 'x' + if kwargs['verbose']: + opts += 'v' + opts += "w=%s" % kwargs['outdir'] + cmdlist.extend([opts, archive]) + return cmdlist + +def list_lzh (archive, encoding, cmd, **kwargs): + """List a LZH archive.""" + cmdlist = [cmd] + if kwargs['verbose']: + cmdlist.append('v') + else: + cmdlist.append('l') + cmdlist.append(archive) + return cmdlist + +def test_lzh (archive, encoding, cmd, **kwargs): + """Test a LZH archive.""" + cmdlist = [cmd] + opts = 't' + if kwargs['verbose']: + opts += 'v' + cmdlist.extend([opts, archive]) + return cmdlist + +def create_lzh (archive, encoding, cmd, *args, **kwargs): + """Create a LZH archive.""" + cmdlist = [cmd] + opts = 'a' + if kwargs['verbose']: + opts += 'v' + cmdlist.extend([opts, archive]) + cmdlist.extend(args) + return cmdlist + diff --git a/patoolib/util.py b/patoolib/util.py index b02a000..ae106f0 100644 --- a/patoolib/util.py +++ b/patoolib/util.py @@ -197,6 +197,7 @@ FileText2Mime = { "compress'd data": "application/x-compress", "lzip compressed data": "application/x-lzip", "current ar archive": "application/x-archive", + "LHa ": "application/x-lha", } def guess_mime_file_text (file_prog, filename):