simplified and fixed a couple of things
This commit is contained in:
parent
1a2db4fb5d
commit
7fa3d39b8a
@ -91,7 +91,7 @@ class Book(object):
|
|||||||
self.title = root.attribute('title', 'Untitled')
|
self.title = root.attribute('title', 'Untitled')
|
||||||
self.overwrite = root.attribute('overwrite', 'true' if Book.DefaultOverwrite else 'false') == 'true'
|
self.overwrite = root.attribute('overwrite', 'true' if Book.DefaultOverwrite else 'false') == 'true'
|
||||||
self.device = root.attribute('device', Book.DefaultDevice)
|
self.device = root.attribute('device', Book.DefaultDevice)
|
||||||
self.outputFormat = root.attribute('outputFormat', 'image+cbz')
|
self.outputFormat = root.attribute('outputFormat', Book.DefaultOutputFormat)
|
||||||
self.imageFlags = int(root.attribute('imageFlags', str(Book.DefaultImageFlags)))
|
self.imageFlags = int(root.attribute('imageFlags', str(Book.DefaultImageFlags)))
|
||||||
self.filename = filename
|
self.filename = filename
|
||||||
self.modified = False
|
self.modified = False
|
||||||
|
@ -25,15 +25,19 @@ class Archive(object):
|
|||||||
outputPath = os.path.join(outputDirectory, outputFileName)
|
outputPath = os.path.join(outputDirectory, outputFileName)
|
||||||
self.zipfile = ZipFile(outputPath, 'w', ZIP_STORED)
|
self.zipfile = ZipFile(outputPath, 'w', ZIP_STORED)
|
||||||
|
|
||||||
|
|
||||||
def addFile(self, filename):
|
def addFile(self, filename):
|
||||||
arcname = os.path.basename(filename)
|
arcname = os.path.basename(filename)
|
||||||
self.zipfile.write(filename, arcname)
|
self.zipfile.write(filename, arcname)
|
||||||
|
|
||||||
|
|
||||||
def __enter__(self):
|
def __enter__(self):
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
|
||||||
def __exit__(self, exc_type, exc_val, exc_tb):
|
def __exit__(self, exc_type, exc_val, exc_tb):
|
||||||
self.close()
|
self.close()
|
||||||
|
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
self.zipfile.close()
|
self.zipfile.close()
|
||||||
|
@ -13,10 +13,9 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
import os, shutil
|
import os, shutil
|
||||||
|
|
||||||
from PyQt4 import QtGui, QtCore
|
from PyQt4 import QtGui, QtCore
|
||||||
|
|
||||||
import image
|
import image
|
||||||
import cbz
|
import cbz
|
||||||
|
|
||||||
@ -26,7 +25,7 @@ class DialogConvert(QtGui.QProgressDialog):
|
|||||||
QtGui.QProgressDialog.__init__(self)
|
QtGui.QProgressDialog.__init__(self)
|
||||||
|
|
||||||
self.book = book
|
self.book = book
|
||||||
self.directory = directory
|
self.bookPath = os.path.join(unicode(directory), unicode(self.book.title))
|
||||||
|
|
||||||
self.timer = None
|
self.timer = None
|
||||||
self.setWindowTitle('Exporting book...')
|
self.setWindowTitle('Exporting book...')
|
||||||
@ -34,46 +33,45 @@ class DialogConvert(QtGui.QProgressDialog):
|
|||||||
self.setValue(0)
|
self.setValue(0)
|
||||||
|
|
||||||
self.archive = None
|
self.archive = None
|
||||||
if 'cbz' in self.book.outputFormat:
|
if 'CBZ' in self.book.outputFormat:
|
||||||
# TODO: switch to API 2, to get rid of the unicode conversions
|
self.archive = cbz.Archive(self.bookPath)
|
||||||
self.archive = cbz.Archive(
|
|
||||||
os.path.join(unicode(self.directory), unicode(self.book.title)))
|
|
||||||
|
|
||||||
|
|
||||||
def showEvent(self, event):
|
def showEvent(self, event):
|
||||||
if self.timer is None:
|
if self.timer is None:
|
||||||
self.timer = QtCore.QTimer()
|
self.timer = QtCore.QTimer()
|
||||||
self.connect(self.timer, QtCore.SIGNAL('timeout()'), self.onTimer)
|
self.timer.timeout.connect(self.onTimer)
|
||||||
self.timer.start(0)
|
self.timer.start(0)
|
||||||
|
|
||||||
|
|
||||||
def hideEvent(self, event):
|
def hideEvent(self, event):
|
||||||
"""Called when the dialog finishes processing."""
|
"""Called when the dialog finishes processing."""
|
||||||
# close the archive if we created a CBZ file
|
|
||||||
|
# Close the archive if we created a CBZ file
|
||||||
if self.archive is not None:
|
if self.archive is not None:
|
||||||
self.archive.close()
|
self.archive.close()
|
||||||
# remove image directory if the user didn't wish for images
|
|
||||||
if 'image' not in self.book.outputFormat:
|
# Remove image directory if the user didn't wish for images
|
||||||
path = os.path.join(unicode(self.directory), unicode(self.book.title))
|
if 'Image' not in self.book.outputFormat:
|
||||||
shutil.rmtree(path)
|
shutil.rmtree(self.bookPath)
|
||||||
|
|
||||||
|
|
||||||
def onTimer(self):
|
def onTimer(self):
|
||||||
index = self.value()
|
index = self.value()
|
||||||
directory = os.path.join(unicode(self.directory), unicode(self.book.title))
|
target = os.path.join(self.bookPath, '%05d.png' % index)
|
||||||
target = os.path.join(directory, '%05d.png' % index)
|
|
||||||
source = unicode(self.book.images[index])
|
source = unicode(self.book.images[index])
|
||||||
|
|
||||||
if index == 0:
|
if index == 0:
|
||||||
try:
|
try:
|
||||||
if not os.path.isdir(directory):
|
if not os.path.isdir(self.bookPath):
|
||||||
os.makedirs(directory)
|
os.makedirs(self.bookPath)
|
||||||
except OSError:
|
except OSError:
|
||||||
QtGui.QMessageBox.critical(self, 'Mangle', 'Cannot create directory %s' % directory)
|
QtGui.QMessageBox.critical(self, 'Mangle', 'Cannot create directory %s' % self.bookPath)
|
||||||
self.close()
|
self.close()
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
base = os.path.join(directory, unicode(self.book.title))
|
base = os.path.join(self.bookPath, unicode(self.book.title))
|
||||||
|
|
||||||
mangaName = base + '.manga'
|
mangaName = base + '.manga'
|
||||||
if self.book.overwrite or not os.path.isfile(mangaName):
|
if self.book.overwrite or not os.path.isfile(mangaName):
|
||||||
@ -89,7 +87,7 @@ class DialogConvert(QtGui.QProgressDialog):
|
|||||||
mangaSave.close()
|
mangaSave.close()
|
||||||
|
|
||||||
except IOError:
|
except IOError:
|
||||||
QtGui.QMessageBox.critical(self, 'Mangle', 'Cannot write manga file(s) to directory %s' % directory)
|
QtGui.QMessageBox.critical(self, 'Mangle', 'Cannot write manga file(s) to directory %s' % self.bookPath)
|
||||||
self.close()
|
self.close()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -47,11 +47,11 @@
|
|||||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||||
p, li { white-space: pre-wrap; }
|
p, li { white-space: pre-wrap; }
|
||||||
</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;">
|
</style></head><body style=" font-family:'Sans Serif'; font-size:10pt; font-weight:400; font-style:normal;">
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:14pt;">Mangle</span></p>
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans'; font-size:14pt;">Mangle</span></p>
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Version 2.2</p>
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans';">Version 2.3</span></p>
|
||||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p>
|
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans';"></p>
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Manga processor by Alex Yatskov for the Kindle e-book reader. Please see <span style=" font-style:italic;">license.txt</span> for licensing information. Visit the homepage at <a href="http://foosoft.net/mangle"><span style=" text-decoration: underline; color:#0000ff;">http://foosoft.net/mangle</span></a>.</p></body></html></string>
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans';">Manga processor by Alex Yatskov for the Kindle e-book reader. Please see </span><span style=" font-family:'Sans'; font-style:italic;">license.txt</span><span style=" font-family:'Sans';"> for licensing information. Visit the homepage at </span><a href="http://foosoft.net/mangle"><span style=" font-family:'Sans'; text-decoration: underline; color:#0000ff;">http://foosoft.net/mangle</span></a><span style=" font-family:'Sans';">.</span></p></body></html></string>
|
||||||
</property>
|
</property>
|
||||||
<property name="wordWrap">
|
<property name="wordWrap">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
|
@ -97,6 +97,11 @@
|
|||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="QComboBox" name="comboBoxFormat">
|
<widget class="QComboBox" name="comboBoxFormat">
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Images & CBZ</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Images only</string>
|
<string>Images only</string>
|
||||||
@ -107,11 +112,6 @@
|
|||||||
<string>CBZ only</string>
|
<string>CBZ only</string>
|
||||||
</property>
|
</property>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Images & CBZ</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
Loading…
Reference in New Issue
Block a user