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 .TP
\fB\-\-help\fP \fB\-\-help\fP
Show help for this command. 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 .SS \fBformats\fP
Show all supported archive formats. Show all supported archive formats.
.TP .TP
@ -81,7 +92,7 @@ Supported archive formats are listed by the \fBformats\fP command.
.TP .TP
\fImode\fP\fB=/usr/bin/mycommand\fP \fImode\fP\fB=/usr/bin/mycommand\fP
Set the application to handle the archive format for given mode. 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 .SH FILES
\fB/etc/patool.conf\fP, \fB~/.patool.conf\fP - \fB/etc/patool.conf\fP, \fB~/.patool.conf\fP -
configuration files configuration files

View File

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

8
patool
View File

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

View File

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

View File

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