initial framework for creation of archives

This commit is contained in:
Bastian Kleineidam 2010-02-21 12:53:00 +01:00
parent 1e9d656d70
commit 1f1896b175
5 changed files with 27 additions and 11 deletions

View File

@ -54,6 +54,17 @@ Verbose archive listing (if the helper application supports it).
.TP
\fB\-\-help\fP
Show help for this command.
.SS \fBcreate\fP
Create an archive from given files.
.TP
\fB--force\fP
Allow overwriting of local archives.
.TP
\fB\-\-verbose\fP
Verbose operation (if the helper application supports it).
.TP
\fB\-\-help\fP
Show help for this command.
.SS \fBformats\fP
Show all supported archive formats.
.TP
@ -81,7 +92,7 @@ Supported archive formats are listed by the \fBformats\fP command.
.TP
\fImode\fP\fB=/usr/bin/mycommand\fP
Set the application to handle the archive format for given mode.
\fImode\fP can be one of \fBextract\fP, \fBlist\fP.
\fImode\fP can be one of (\fBextract\fP, \fBlist\fP, \fBcreate\fP).
.SH FILES
\fB/etc/patool.conf\fP, \fB~/.patool.conf\fP -
configuration files

View File

@ -1,3 +1,2 @@
- add project to github
- add create mode?
- add test mode?

8
patool
View File

@ -36,10 +36,10 @@ def list (archive, verbose=False):
return patoolib.handle_archive(archive, 'list')
#@baker.command
#def create (archive, *args):
# """Create an archive from given files."""
# return patoolib.handle_archive(archive, 'create', *args)
@baker.command
def create (archive, *args):
"""Create an archive from given files."""
return patoolib.handle_archive(archive, 'create', *args)
@baker.command

View File

@ -19,7 +19,7 @@ from distutils.spawn import find_executable
from . import util
# Supported archive commands
ArchiveCommands = ('list', 'extract')
ArchiveCommands = ('list', 'extract', 'create')
# Supported archive formats
ArchiveFormats = ('gzip', 'bzip2', 'tar', 'zip', 'compress', '7z', 'rar',
@ -254,7 +254,9 @@ def cleanup_outdir (archive, outdir, force):
return target
def _handle_archive (archive, command, **kwargs):
def _handle_archive (archive, command, *args, **kwargs):
if command != 'create':
# check that archive is a regular file
util.check_filename(archive)
encoding = None
format, encoding = get_archive_format(archive)
@ -288,10 +290,10 @@ def _handle_archive (archive, command, **kwargs):
pass
def handle_archive (archive, command, **kwargs):
def handle_archive (archive, command, *args, **kwargs):
"""Handle archive file command."""
try:
_handle_archive(archive, command, **kwargs)
_handle_archive(archive, command, *args, **kwargs)
res = 0
except util.PatoolError, msg:
util.log_error(msg)

View File

@ -34,3 +34,7 @@ def list_tar (archive, encoding, cmd, **kwargs):
cmdlist.append('--verbose')
cmdlist.extend(["--file", archive])
return cmdlist
def create_tar (archive, encoding, cmd, **kwargs):
"""Create a TAR archive."""
print "XXX create", archive, encoding, cmd, kwargs