First cut at zip export
git-svn-id: http://comictagger.googlecode.com/svn/trunk@229 6c5673fe-1810-88d6-992b-cd32ca31540c
This commit is contained in:
parent
ab5d8599ac
commit
c5f1542874
@ -93,7 +93,6 @@ class ZipArchiver:
|
||||
# zip helper func
|
||||
def rebuildZipFile( self, exclude_list ):
|
||||
|
||||
# TODO: use tempfile.mkstemp
|
||||
# this recompresses the zip archive, without the files in the exclude_list
|
||||
#print "Rebuilding zip {0} without {1}".format( self.path, exclude_list )
|
||||
|
||||
@ -181,6 +180,26 @@ class ZipArchiver:
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
def copyFromArchive( self, otherArchive ):
|
||||
# Replace the current zip with one copied from another archive
|
||||
try:
|
||||
zout = zipfile.ZipFile (self.path, 'w')
|
||||
for fname in otherArchive.getArchiveFilenameList():
|
||||
data = otherArchive.readArchiveFile( fname )
|
||||
zout.writestr( fname, data )
|
||||
zout.close()
|
||||
|
||||
#preserve the old comment
|
||||
comment = otherArchive.getArchiveComment()
|
||||
if comment is not None:
|
||||
if not self.writeZipComment( self.path, comment ):
|
||||
return False
|
||||
except:
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
|
||||
#------------------------------------------
|
||||
# RAR implementation
|
||||
@ -694,3 +713,12 @@ class ComicArchive:
|
||||
metadata.isEmpty = False
|
||||
|
||||
return metadata
|
||||
|
||||
def exportAsZip( self, zipfilename ):
|
||||
if self.archive_type == self.ArchiveType.Zip:
|
||||
# nothing to do, we're already a zip
|
||||
return True
|
||||
|
||||
zip_archiver = ZipArchiver( zipfilename )
|
||||
return zip_archiver.copyFromArchive( self.archiver )
|
||||
|
||||
|
@ -275,8 +275,21 @@ class TaggerWindow( QtGui.QMainWindow):
|
||||
self.toolBar.addAction( self.actionPageBrowser )
|
||||
|
||||
def repackageArchive( self ):
|
||||
QtGui.QMessageBox.information(self, self.tr("Repackage Comic Archive"), self.tr("TBD"))
|
||||
|
||||
if self.comic_archive is not None:
|
||||
if self.comic_archive.isZip():
|
||||
QtGui.QMessageBox.information(self, self.tr("Export as Zip Archive"), self.tr("It's already a Zip Archive!"))
|
||||
return
|
||||
|
||||
#TODO get the new zip file name
|
||||
export_name = "test.cbz"
|
||||
|
||||
QtGui.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.WaitCursor))
|
||||
retcode = self.comic_archive.exportAsZip( "test.cbz")
|
||||
QtGui.QApplication.restoreOverrideCursor()
|
||||
|
||||
if not retcode:
|
||||
QtGui.QMessageBox.information(self, self.tr("Export as Zip Archive"), self.tr("An error occure while exporting."))
|
||||
|
||||
def aboutApp( self ):
|
||||
|
||||
website = "http://code.google.com/p/comictagger"
|
||||
|
@ -1146,7 +1146,7 @@
|
||||
</action>
|
||||
<action name="actionRepackage">
|
||||
<property name="text">
|
||||
<string>Repackage</string>
|
||||
<string>Export as Zip Archive</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionExit">
|
||||
|
Loading…
x
Reference in New Issue
Block a user