Use maximum compression options.

This commit is contained in:
Bastian Kleineidam 2015-07-19 15:43:21 +02:00
parent c482bbd861
commit 93f0caeecc
13 changed files with 69 additions and 36 deletions

View File

@ -2,6 +2,8 @@
* Added support for ZPAQ archives. * Added support for ZPAQ archives.
Closes: GH bug #14 Closes: GH bug #14
* Use options for maximum compression when creating archives
and the archive program has such options.
1.7 (released 27.6.2014) 1.7 (released 27.6.2014)

View File

@ -1,5 +1,5 @@
.\" -*- nroff -*- .\" -*- nroff -*-
.\" Copyright (C) 2010-2014 Bastian Kleineidam .\" Copyright (C) 2010-2015 Bastian Kleineidam
.\" .\"
.\" This program is free software: you can redistribute it and/or modify .\" 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 .\" it under the terms of the GNU General Public License as published by
@ -94,7 +94,8 @@ List files in archives.
Create an archive from given files. All of the given files to add Create an archive from given files. All of the given files to add
to the archive must be readable by the current user. to the archive must be readable by the current user.
The format of the archive to create is determined by the archive file The format of the archive to create is determined by the archive file
extension. extension. If the archive program has options to maximize file compression,
\fBpatool\fP uses those options.
.SS test .SS test
\fBpatool\fP \fBtest\fP <\fIarchive\fP>... \fBpatool\fP \fBtest\fP <\fIarchive\fP>...
.PP .PP
@ -137,4 +138,4 @@ When running under a Unix shell the following aliases can be defined to save som
.SH AUTHOR .SH AUTHOR
Bastian Kleineidam <bastian.kleineidam@web.de> Bastian Kleineidam <bastian.kleineidam@web.de>
.SH COPYRIGHT .SH COPYRIGHT
Copyright \(co 2010-2014 Bastian Kleineidam Copyright \(co 2010-2015 Bastian Kleineidam

View File

@ -1,4 +1,4 @@
PATOOL(1) PATOOL(1) PATOOL(1) General Commands Manual PATOOL(1)
@ -91,10 +91,11 @@ COMMANDS
create create
patool create <archive> <file-or-directory>... patool create <archive> <file-or-directory>...
Create an archive from given files. All of the given files to Create an archive from given files. All of the given files to
add to the archive must be readable by the current user. The add to the archive must be readable by the current user. The
format of the archive to create is determined by the archive format of the archive to create is determined by the archive
file extension. file extension. If the archive program has options to maximize
file compression, patool uses those options.
test test
patool test <archive>... patool test <archive>...
@ -146,7 +147,7 @@ AUTHOR
Bastian Kleineidam <bastian.kleineidam@web.de> Bastian Kleineidam <bastian.kleineidam@web.de>
COPYRIGHT COPYRIGHT
Copyright © 2010-2014 Bastian Kleineidam Copyright © 2010-2015 Bastian Kleineidam

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (C) 2010-2014 Bastian Kleineidam # Copyright (C) 2010-2015 Bastian Kleineidam
# #
# This program is free software: you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
@ -25,7 +25,7 @@ def create_bzip2 (archive, compression, cmd, verbosity, filenames):
cmdlist = [util.shell_quote(cmd)] cmdlist = [util.shell_quote(cmd)]
if verbosity > 1: if verbosity > 1:
cmdlist.append('-v') cmdlist.append('-v')
cmdlist.extend(['-c', '-z', '--']) cmdlist.extend(['-c', '-z', '-9', '--'])
cmdlist.extend([util.shell_quote(x) for x in filenames]) cmdlist.extend([util.shell_quote(x) for x in filenames])
cmdlist.extend(['>', util.shell_quote(archive)]) cmdlist.extend(['>', util.shell_quote(archive)])
return (cmdlist, {'shell': True}) return (cmdlist, {'shell': True})

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (C) 2011-2012 Bastian Kleineidam # Copyright (C) 2011-2015 Bastian Kleineidam
# #
# This program is free software: you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
@ -14,10 +14,19 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# 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 clzip program.""" """Archive commands for the clzip program."""
from . import extract_singlefile_standard, \ from . import extract_singlefile_standard, test_singlefile_standard
test_singlefile_standard, create_singlefile_standard from .. import util
extract_lzip = extract_singlefile_standard extract_lzip = extract_singlefile_standard
test_lzip = test_singlefile_standard test_lzip = test_singlefile_standard
create_lzip = create_singlefile_standard
def create_lzip(archive, compression, cmd, verbosity, filenames):
"""Create an LZIP archive."""
cmdlist = [util.shell_quote(cmd)]
if verbosity > 1:
cmdlist.append('-v')
cmdlist.extend(['-c', '-9', '--'])
cmdlist.extend([util.shell_quote(x) for x in filenames])
cmdlist.extend(['>', util.shell_quote(archive)])
return (cmdlist, {'shell': True})

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (C) 2012-2014 Bastian Kleineidam # Copyright (C) 2012-2015 Bastian Kleineidam
# #
# This program is free software: you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
@ -25,7 +25,7 @@ def extract_flac (archive, compression, cmd, verbosity, outdir):
def create_flac (archive, compression, cmd, verbosity, filenames): def create_flac (archive, compression, cmd, verbosity, filenames):
"""Compress a WAV file to a FLAC archive.""" """Compress a WAV file to a FLAC archive."""
cmdlist = [cmd, filenames[0], '--output-name', archive] cmdlist = [cmd, filenames[0], '--best', '--output-name', archive]
return cmdlist return cmdlist

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (C) 2010-2014 Bastian Kleineidam # Copyright (C) 2010-2015 Bastian Kleineidam
# #
# This program is free software: you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
@ -14,12 +14,23 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# 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 gzip program.""" """Archive commands for the gzip program."""
from . import extract_singlefile_standard, \ from . import extract_singlefile_standard, test_singlefile_standard
test_singlefile_standard, create_singlefile_standard from .. import util
extract_gzip = extract_compress = extract_singlefile_standard extract_gzip = extract_compress = extract_singlefile_standard
test_gzip = test_compress = test_singlefile_standard test_gzip = test_compress = test_singlefile_standard
create_gzip = create_singlefile_standard
def create_gzip(archive, compression, cmd, verbosity, filenames):
"""Create a GZIP archive."""
cmdlist = [util.shell_quote(cmd)]
if verbosity > 1:
cmdlist.append('-v')
cmdlist.extend(['-c', '-9', '--'])
cmdlist.extend([util.shell_quote(x) for x in filenames])
cmdlist.extend(['>', util.shell_quote(archive)])
return (cmdlist, {'shell': True})
def list_gzip (archive, compression, cmd, verbosity): def list_gzip (archive, compression, cmd, verbosity):
"""List a GZIP archive.""" """List a GZIP archive."""

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (C) 2010-2014 Bastian Kleineidam # Copyright (C) 2010-2015 Bastian Kleineidam
# #
# This program is free software: you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
@ -84,7 +84,7 @@ test_bzip2 = \
def create_7z (archive, compression, cmd, verbosity, filenames): def create_7z (archive, compression, cmd, verbosity, filenames):
"""Create a 7z archive.""" """Create a 7z archive."""
cmdlist = [cmd, 'a', '--', archive] cmdlist = [cmd, 'a', '-mx=9', '--', archive]
cmdlist.extend(filenames) cmdlist.extend(filenames)
return cmdlist return cmdlist

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (C) 2012-2014 Bastian Kleineidam # Copyright (C) 2012-2015 Bastian Kleineidam
# #
# This program is free software: you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
@ -48,7 +48,7 @@ def _create(archive, compression, cmd, format, verbosity, filenames):
if len(filenames) > 1: if len(filenames) > 1:
raise util.PatoolError('multi-file compression not supported in Python lzma') raise util.PatoolError('multi-file compression not supported in Python lzma')
try: try:
with lzma.LZMAFile(archive, mode='wb', format=format) as lzmafile: with lzma.LZMAFile(archive, mode='wb', format=format, preset=9) as lzmafile:
filename = filenames[0] filename = filenames[0]
with open(filename, 'rb') as srcfile: with open(filename, 'rb') as srcfile:
data = srcfile.read(READ_SIZE_BYTES) data = srcfile.read(READ_SIZE_BYTES)

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (C) 2010-2014 Bastian Kleineidam # Copyright (C) 2010-2015 Bastian Kleineidam
# #
# This program is free software: you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
@ -37,6 +37,6 @@ def test_rar (archive, compression, cmd, verbosity):
def create_rar (archive, compression, cmd, verbosity, filenames): def create_rar (archive, compression, cmd, verbosity, filenames):
"""Create a RAR archive.""" """Create a RAR archive."""
cmdlist = [cmd, 'a', '-r', '--', archive] cmdlist = [cmd, 'a', '-r', '-m5', '--', archive]
cmdlist.extend(filenames) cmdlist.extend(filenames)
return cmdlist return cmdlist

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (C) 2010-2014 Bastian Kleineidam # Copyright (C) 2010-2015 Bastian Kleineidam
# #
# This program is free software: you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
@ -27,7 +27,7 @@ def extract_rzip (archive, compression, cmd, verbosity, outdir):
def create_rzip (archive, compression, cmd, verbosity, filenames): def create_rzip (archive, compression, cmd, verbosity, filenames):
"""Create an RZIP archive.""" """Create an RZIP archive."""
cmdlist = [cmd, '-k', '-o', archive] cmdlist = [cmd, '-k', '-9', '-o', archive]
if verbosity > 1: if verbosity > 1:
cmdlist.append('-v') cmdlist.append('-v')
cmdlist.extend(filenames) cmdlist.extend(filenames)

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (C) 2010-2014 Bastian Kleineidam # Copyright (C) 2010-2015 Bastian Kleineidam
# #
# This program is free software: you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
@ -14,14 +14,12 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# 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 xz program.""" """Archive commands for the xz program."""
from . import extract_singlefile_standard, \ from . import extract_singlefile_standard, test_singlefile_standard
test_singlefile_standard, create_singlefile_standard
from .. import util from .. import util
extract_xz = extract_singlefile_standard extract_xz = extract_singlefile_standard
test_xz = test_singlefile_standard test_xz = test_singlefile_standard
create_xz = create_singlefile_standard
def list_xz (archive, compression, cmd, verbosity): def list_xz (archive, compression, cmd, verbosity):
"""List a XZ archive.""" """List a XZ archive."""
@ -33,6 +31,17 @@ def list_xz (archive, compression, cmd, verbosity):
return cmdlist return cmdlist
def create_xz(archive, compression, cmd, verbosity, filenames):
"""Create an XZ archive."""
cmdlist = [util.shell_quote(cmd)]
if verbosity > 1:
cmdlist.append('-v')
cmdlist.extend(['-c', '-9', '--'])
cmdlist.extend([util.shell_quote(x) for x in filenames])
cmdlist.extend(['>', util.shell_quote(archive)])
return (cmdlist, {'shell': True})
def extract_lzma(archive, compression, cmd, verbosity, outdir): def extract_lzma(archive, compression, cmd, verbosity, outdir):
"""Extract an LZMA archive.""" """Extract an LZMA archive."""
cmdlist = [util.shell_quote(cmd), '--format=lzma'] cmdlist = [util.shell_quote(cmd), '--format=lzma']
@ -58,7 +67,7 @@ def create_lzma(archive, compression, cmd, verbosity, filenames):
cmdlist = [util.shell_quote(cmd), '--format=lzma'] cmdlist = [util.shell_quote(cmd), '--format=lzma']
if verbosity > 1: if verbosity > 1:
cmdlist.append('-v') cmdlist.append('-v')
cmdlist.extend(['-c', '--']) cmdlist.extend(['-c', '-9', '--'])
cmdlist.extend([util.shell_quote(x) for x in filenames]) cmdlist.extend([util.shell_quote(x) for x in filenames])
cmdlist.extend(['>', util.shell_quote(archive)]) cmdlist.extend(['>', util.shell_quote(archive)])
return (cmdlist, {'shell': True}) return (cmdlist, {'shell': True})

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (C) 2010-2014 Bastian Kleineidam # Copyright (C) 2010-2015 Bastian Kleineidam
# #
# This program is free software: you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
@ -17,7 +17,7 @@
def create_zip (archive, compression, cmd, verbosity, filenames): def create_zip (archive, compression, cmd, verbosity, filenames):
"""Create a ZIP archive.""" """Create a ZIP archive."""
cmdlist = [cmd, '-r'] cmdlist = [cmd, '-r', '-9']
if verbosity > 1: if verbosity > 1:
cmdlist.append('-v') cmdlist.append('-v')
cmdlist.append(archive) cmdlist.append(archive)