Added --verbose option to create command

This commit is contained in:
Bastian Kleineidam 2010-03-06 14:01:02 +01:00
parent 0ba0ca63d4
commit aff6657980
5 changed files with 43 additions and 16 deletions

View File

@ -2,6 +2,7 @@
* Remove the --force option. Local files are now never overwritten. * Remove the --force option. Local files are now never overwritten.
* Added option alias -v for --verbose. * Added option alias -v for --verbose.
* Added --verbose option to create command.
0.5 "Vanishing Point" (released 4.3.2010) 0.5 "Vanishing Point" (released 4.3.2010)

View File

@ -15,8 +15,8 @@
.SH NAME .SH NAME
patool - simple manager for file archives of various types patool - simple manager for file archives of various types
.SH SYNOPSIS .SH SYNOPSIS
\fBpatool\fP (\fBextract\fP|\fBlist\fP|\fBtest\fP) [\fIoptions\fP] <\fIarchive-file\fP> \fBpatool\fP (\fBextract\fP|\fBlist\fP|\fBtest\fP) [\fIoptions\fP] <\fIarchive-file\fP>...
\fBpatool\fP \fBcreate\fP [\fIoptions\fP] <\fIarchive-file\fP> [\fIfiles\fP..] \fBpatool\fP \fBcreate\fP [\fIoptions\fP] <\fIarchive-file\fP> [\fIfiles\fP...]
\fBpatool\fP \fBformats\fP [\fIoptions\fP] \fBpatool\fP \fBformats\fP [\fIoptions\fP]
.SH DESCRIPTION .SH DESCRIPTION
Various archive types can be created, extracted, tested and listed by Various archive types can be created, extracted, tested and listed by
@ -32,6 +32,11 @@ RPM (.rpm), DEB (.deb), LZIP (.lz), LZOP (.lzo), LZMA (.lzma), RAR (.rar)
and XZ (.xz) formats. and XZ (.xz) formats.
It relies on helper applications to handle those archive formats It relies on helper applications to handle those archive formats
(for example bzip2 for BZIP2 archives). (for example bzip2 for BZIP2 archives).
.SH EXAMPLES
\fBpatool extract archive.zip\fP
\fBpatool test --verbose dist.tar.gz\fP
\fBpatool list package.deb\fP
\fPpatool create --verbose myfiles.zip file1.txt dir/\fP
.SH COMMANDS .SH COMMANDS
Several commands and options are available. Several commands and options are available.
.SS \fBextract\fP .SS \fBextract\fP
@ -60,10 +65,11 @@ Verbose archive listing (if the helper application supports it).
\fB\-\-help\fP \fB\-\-help\fP
Show help for this command. Show help for this command.
.SS \fBcreate\fP .SS \fBcreate\fP
Create an archive from given files. Create an archive from given files. At least on of the given files to add
.\" .TP to the archive has to exist.
.\" \fB\-v\fP, \fB\-\-verbose\fP .TP
.\" Verbose operation (if the helper application supports it). \fB\-v\fP, \fB\-\-verbose\fP
Verbose operation (if the helper application supports it).
.TP .TP
\fB\-\-help\fP \fB\-\-help\fP
Show help for this command. Show help for this command.

View File

@ -6,8 +6,8 @@ NAME
patool - simple manager for file archives of various types patool - simple manager for file archives of various types
SYNOPSIS SYNOPSIS
patool (extract|list|test) [options] <archive-file> patool (extract|list|test) [options] <archive-file>...
patool create [options] <archive-file> [files..] patool create [options] <archive-file> [files...]
patool formats [options] patool formats [options]
DESCRIPTION DESCRIPTION
@ -24,6 +24,12 @@ DESCRIPTION
and XZ (.xz) formats. It relies on helper applications to handle those and XZ (.xz) formats. It relies on helper applications to handle those
archive formats (for example bzip2 for BZIP2 archives). archive formats (for example bzip2 for BZIP2 archives).
EXAMPLES
patool extract archive.zip
patool test --verbose dist.tar.gz
patool list package.deb
patool create --verbose myfiles.zip file1.txt dir/
COMMANDS COMMANDS
Several commands and options are available. Several commands and options are available.
@ -52,7 +58,11 @@ COMMANDS
--help Show help for this command. --help Show help for this command.
create create
Create an archive from given files. Create an archive from given files. At least on of the given files to
add to the archive has to exist.
-v, --verbose
Verbose operation (if the helper application supports it).
--help Show help for this command. --help Show help for this command.

9
patool
View File

@ -38,10 +38,13 @@ def list (archive, verbose=False):
return handle_archive(archive, 'list') return handle_archive(archive, 'list')
@baker.command @baker.command(shortopts={"verbose": "v"}, params={
def create (archive, *args): "verbose": "Verbose archive listing (if the helper application supports it).",
})
def create (archive, file1, *files, **kwargs):
"""Create an archive from given files.""" """Create an archive from given files."""
return handle_archive(archive, 'create', *args) allfiles = (file1,)+files
return handle_archive(archive, 'create', *allfiles, **kwargs)
@baker.command(shortopts={"verbose": "v"}, params={ @baker.command(shortopts={"verbose": "v"}, params={

View File

@ -47,6 +47,7 @@ class ArchiveTest (unittest.TestCase):
os.chdir(tmpdir) os.chdir(tmpdir)
try: try:
patoolib._handle_archive(archive, 'extract', program=self.program) patoolib._handle_archive(archive, 'extract', program=self.program)
patoolib._handle_archive(archive, 'extract', program=self.program, verbose=True)
finally: finally:
os.chdir(basedir) os.chdir(basedir)
shutil.rmtree(tmpdir) shutil.rmtree(tmpdir)
@ -70,10 +71,6 @@ class ArchiveTest (unittest.TestCase):
topack = os.path.join(datadir, 'foo.txt') topack = os.path.join(datadir, 'foo.txt')
else: else:
topack = os.path.join(datadir, 'foo') topack = os.path.join(datadir, 'foo')
# create a temporary directory for creation
tmpdir = patoolib.util.tmpdir(dir=basedir)
archive = os.path.join(tmpdir, filename)
os.chdir(tmpdir)
# The format and encoding arguments are needed for creating # The format and encoding arguments are needed for creating
# archives with unusual file extensions. # archives with unusual file extensions.
kwargs = dict( kwargs = dict(
@ -81,6 +78,16 @@ class ArchiveTest (unittest.TestCase):
format=format, format=format,
encoding=encoding encoding=encoding
) )
self._archive_create(filename, topack, kwargs)
kwargs['verbose'] = True
self._archive_create(filename, topack, kwargs)
def _archive_create (self, filename, topack, kwargs):
"""Create archive from filename."""
# create a temporary directory for creation
tmpdir = patoolib.util.tmpdir(dir=basedir)
archive = os.path.join(tmpdir, filename)
os.chdir(tmpdir)
try: try:
patoolib._handle_archive(archive, 'create', topack, **kwargs) patoolib._handle_archive(archive, 'create', topack, **kwargs)
# not all programs can test what they create # not all programs can test what they create