Fix PML2PMLZ FileTypePlugin.

This commit is contained in:
John Schember 2009-12-04 18:38:20 -05:00
parent 7212ede7fb
commit 74d613eb37

View File

@ -66,25 +66,20 @@ class PML2PMLZ(FileTypePlugin):
def run(self, pmlfile):
import zipfile
from calibre.ptempfile import TemporaryDirectory
with TemporaryDirectory('_plugin_pml2pmlz') as tdir:
name = os.path.join(tdir, '_plugin_pml2pmlz.pmlz')
pmlz = zipfile.ZipFile(name, 'w')
pmlz.write(pmlfile)
of = self.temporary_file('_plugin_pml2pmlz.pmlz')
pmlz = zipfile.ZipFile(of.name, 'w')
pmlz.write(pmlfile, os.path.basename(pmlfile))
pml_img = os.path.basename(pmlfile)[0] + '_img'
img_dir = pml_img if os.path.exists(pml_img) else 'images' if \
os.path.exists('images') else ''
if img_dir:
for image in glob.glob(os.path.join(img_dir, '*.png')):
pmlz.write(image)
pmlz.write(image, os.path.join('images', (os.path.basename(image))))
pmlz.close()
return name
def customization_help(self, gui=False):
return _('Character encoding for the input PML files. Should ways be: cp1252.')
return of.name
class ComicMetadataReader(MetadataReaderPlugin):