mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
GwR wip
This commit is contained in:
parent
73be593458
commit
a76a09d633
@ -106,6 +106,9 @@ class CSV_XML(CatalogPlugin):
|
|||||||
if self.fmt == 'csv':
|
if self.fmt == 'csv':
|
||||||
outfile = codecs.open(path_to_output, 'w', 'utf8')
|
outfile = codecs.open(path_to_output, 'w', 'utf8')
|
||||||
|
|
||||||
|
# Write a UTF-8 BOM
|
||||||
|
outfile.write('\xef\xbb\xbf')
|
||||||
|
|
||||||
# Output the field headers
|
# Output the field headers
|
||||||
outfile.write(u'%s\n' % u','.join(fields))
|
outfile.write(u'%s\n' % u','.join(fields))
|
||||||
|
|
||||||
@ -132,7 +135,6 @@ class CSV_XML(CatalogPlugin):
|
|||||||
elif field == 'comments':
|
elif field == 'comments':
|
||||||
item = item.replace(u'\r\n',u' ')
|
item = item.replace(u'\r\n',u' ')
|
||||||
item = item.replace(u'\n',u' ')
|
item = item.replace(u'\n',u' ')
|
||||||
|
|
||||||
outstr.append(u'"%s"' % unicode(item).replace('"','""'))
|
outstr.append(u'"%s"' % unicode(item).replace('"','""'))
|
||||||
|
|
||||||
outfile.write(u','.join(outstr) + u'\n')
|
outfile.write(u','.join(outstr) + u'\n')
|
||||||
@ -953,24 +955,22 @@ class EPUB_MOBI(CatalogPlugin):
|
|||||||
float(self.opts.thumb_width))
|
float(self.opts.thumb_width))
|
||||||
zfw = ZipFile(self.__archive_path, mode='w')
|
zfw = ZipFile(self.__archive_path, mode='w')
|
||||||
zfw.writestr("Catalog Thumbs Archive",'')
|
zfw.writestr("Catalog Thumbs Archive",'')
|
||||||
zfw.comment = "thumb_width: %1.2f" % float(self.opts.thumb_width)
|
#zfw.comment = "thumb_width: %1.2f" % float(self.opts.thumb_width)
|
||||||
zfw.close()
|
zfw.close()
|
||||||
else:
|
else:
|
||||||
with closing(ZipFile(self.__archive_path, mode='r')) as zfr:
|
with closing(ZipFile(self.__archive_path, mode='r')) as zfr:
|
||||||
try:
|
try:
|
||||||
cached_thumb_width = float(zfr.comment[len('thumb_width: '):])
|
cached_thumb_width = zfr.read('thumb_width')
|
||||||
except:
|
except:
|
||||||
cached_thumb_width = "0.0"
|
cached_thumb_width = "-1"
|
||||||
|
|
||||||
if float(cached_thumb_width) != float(self.opts.thumb_width):
|
if float(cached_thumb_width) != float(self.opts.thumb_width):
|
||||||
self.opts.log.info(" invalidating cache at '%s'" % self.__archive_path)
|
self.opts.log.info(" invalidating cache at '%s'" % self.__archive_path)
|
||||||
self.opts.log.info(' thumb_width: %1.2f" => %1.2f"' %
|
self.opts.log.info(' thumb_width: %1.2f" => %1.2f"' %
|
||||||
(float(cached_thumb_width),float(self.opts.thumb_width)))
|
(float(cached_thumb_width),float(self.opts.thumb_width)))
|
||||||
os.remove(self.__archive_path)
|
os.remove(self.__archive_path)
|
||||||
zfw = ZipFile(self.__archive_path, mode='w')
|
with closing(ZipFile(self.__archive_path, mode='w')) as zfw:
|
||||||
zfw.writestr("Catalog Thumbs Archive",'')
|
zfw.writestr("Catalog Thumbs Archive",'')
|
||||||
zfw.comment = "thumb_width: %1.2f" % float(self.opts.thumb_width)
|
|
||||||
zfw.close()
|
|
||||||
else:
|
else:
|
||||||
self.opts.log.info(' existing thumb cache at %s, cached_thumb_width: %1.2f"' %
|
self.opts.log.info(' existing thumb cache at %s, cached_thumb_width: %1.2f"' %
|
||||||
(self.__archive_path, float(cached_thumb_width)))
|
(self.__archive_path, float(cached_thumb_width)))
|
||||||
@ -2997,6 +2997,11 @@ class EPUB_MOBI(CatalogPlugin):
|
|||||||
title['cover'] = cover
|
title['cover'] = cover
|
||||||
self.generateThumbnail(title, image_dir, "thumbnail_default.jpg")
|
self.generateThumbnail(title, image_dir, "thumbnail_default.jpg")
|
||||||
|
|
||||||
|
# Write the thumb_width to the file validating cache contents
|
||||||
|
# Allows detection of aborted catalog builds
|
||||||
|
with closing(ZipFile(self.__archive_path, mode='a'))as zfw:
|
||||||
|
zfw.writestr('thumb_width', self.opts.thumb_width)
|
||||||
|
|
||||||
self.thumbs = thumbs
|
self.thumbs = thumbs
|
||||||
|
|
||||||
def generateOPF(self):
|
def generateOPF(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user