mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix PML2PMLZ FileTypePlugin.
This commit is contained in:
parent
7212ede7fb
commit
74d613eb37
@ -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):
|
||||
|
Loading…
x
Reference in New Issue
Block a user