1
0
mirror of https://github.com/gryf/ebook-converter.git synced 2026-04-25 16:01:29 +02:00

Removed superfluous lopen builtin

This commit is contained in:
2020-04-20 21:12:22 +02:00
parent 3ca3f08054
commit 9e076e0af4
38 changed files with 107 additions and 195 deletions
+5 -5
View File
@@ -48,7 +48,7 @@ def _metadata_from_formats(formats, force_read_metadata=False, pattern=None):
return mi2
for path, ext in zip(formats, extensions):
with lopen(path, 'rb') as stream:
with open(path, 'rb') as stream:
try:
newmi = get_metadata(stream, stream_type=ext,
use_libprs_metadata=True,
@@ -223,19 +223,19 @@ def opf_metadata(opfpath):
def forked_read_metadata(path, tdir):
from ebook_converter.ebooks.metadata.opf2 import metadata_to_opf
with lopen(path, 'rb') as f:
with open(path, 'rb') as f:
fmt = os.path.splitext(path)[1][1:].lower()
f.seek(0, 2)
sz = f.tell()
with lopen(os.path.join(tdir, 'size.txt'), 'wb') as s:
with open(os.path.join(tdir, 'size.txt'), 'wb') as s:
s.write(str(sz).encode('ascii'))
f.seek(0)
mi = get_metadata(f, fmt)
if mi.cover_data and mi.cover_data[1]:
with lopen(os.path.join(tdir, 'cover.jpg'), 'wb') as f:
with open(os.path.join(tdir, 'cover.jpg'), 'wb') as f:
f.write(mi.cover_data[1])
mi.cover_data = (None, None)
mi.cover = 'cover.jpg'
opf = metadata_to_opf(mi, default_lang='und')
with lopen(os.path.join(tdir, 'metadata.opf'), 'wb') as f:
with open(os.path.join(tdir, 'metadata.opf'), 'wb') as f:
f.write(opf)