Added support for creating ZIP archives.
This commit is contained in:
parent
8d02fdfe8f
commit
2577a454b9
|
@ -1,7 +1,8 @@
|
|||
0.4 "" (released xx.xx.2010)
|
||||
|
||||
* Improved listing of available archive formats.
|
||||
* Added support for Windows systems.
|
||||
* Added support for creating ZIP files.
|
||||
* Improved listing of available archive formats.
|
||||
* Improved recognition of MIME types.
|
||||
|
||||
0.3 "Management" (released 23.2.2010)
|
||||
|
|
|
@ -77,6 +77,7 @@ ArchivePrograms = {
|
|||
'extract': ('unzip', '7z'),
|
||||
'list': ('unzip', '7z'),
|
||||
'test': ('unzip', '7z'),
|
||||
'create': ('zip',),
|
||||
},
|
||||
'gzip': {
|
||||
None: ('gzip', '7z'),
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
# -*- 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 <http://www.gnu.org/licenses/>.
|
||||
"""Archive commands for the zip program."""
|
||||
|
||||
def create_zip (archive, encoding, cmd, *args, **kwargs):
|
||||
"""Create a ZIP archive."""
|
||||
cmdlist = [cmd]
|
||||
# XXX if archive already exists, use zip -u (update)?
|
||||
cmdlist.append('-r')
|
||||
if kwargs['verbose']:
|
||||
cmdlist.append('--verbose')
|
||||
cmdlist.append(archive)
|
||||
cmdlist.extend(args)
|
||||
return cmdlist
|
|
@ -87,6 +87,8 @@ class ArchiveTest (unittest.TestCase):
|
|||
# not all programs can test what they create
|
||||
if self.program == 'compress':
|
||||
program = 'gzip'
|
||||
elif self.program == 'zip':
|
||||
program = 'unzip'
|
||||
else:
|
||||
program = self.program
|
||||
patoolib._handle_archive(archive, 'test', program=program)
|
||||
|
|
|
@ -114,6 +114,11 @@ class TestArchives (ArchiveTest):
|
|||
self.archive_list('t.jar')
|
||||
self.archive_test('t.jar')
|
||||
|
||||
@needs_program('zip')
|
||||
def test_zip (self):
|
||||
self.program = 'zip'
|
||||
self.archive_create('t.zip')
|
||||
|
||||
@needs_program('gzip')
|
||||
def test_gzip (self):
|
||||
self.program = 'gzip'
|
||||
|
|
|
@ -133,6 +133,12 @@ class TestArchives (ArchiveTest):
|
|||
self.archive_list('t.jar.foo')
|
||||
self.archive_test('t.jar.foo')
|
||||
|
||||
@needs_program('file')
|
||||
@needs_program('zip')
|
||||
def test_zip (self):
|
||||
self.program = 'zip'
|
||||
self.archive_create('t.zip.foo', format="zip")
|
||||
|
||||
@needs_program('file')
|
||||
@needs_program('gzip')
|
||||
def test_gzip (self):
|
||||
|
|
Loading…
Reference in New Issue