mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
...
This commit is contained in:
parent
6e7f6db830
commit
1968754d97
@ -135,6 +135,13 @@ class MOBIFile(object):
|
|||||||
|
|
||||||
self.files.append(File(skel, skeleton, ftext, first_aid, sections))
|
self.files.append(File(skel, skeleton, ftext, first_aid, sections))
|
||||||
|
|
||||||
|
def dump_flows(self, ddir):
|
||||||
|
for i, x in enumerate(self.fdst.sections):
|
||||||
|
start, end = x
|
||||||
|
raw = self.raw_text[start:end]
|
||||||
|
with open(os.path.join(ddir, 'flow%04d.txt'%i), 'wb') as f:
|
||||||
|
f.write(raw)
|
||||||
|
|
||||||
def extract_resources(self):
|
def extract_resources(self):
|
||||||
self.resource_map = []
|
self.resource_map = []
|
||||||
known_types = {b'FLIS', b'FCIS', b'SRCS',
|
known_types = {b'FLIS', b'FCIS', b'SRCS',
|
||||||
@ -181,7 +188,7 @@ def inspect_mobi(mobi_file, ddir):
|
|||||||
with open(alltext, 'wb') as of:
|
with open(alltext, 'wb') as of:
|
||||||
of.write(f.raw_text)
|
of.write(f.raw_text)
|
||||||
|
|
||||||
for x in ('text_records', 'images', 'fonts', 'binary', 'files'):
|
for x in ('text_records', 'images', 'fonts', 'binary', 'files', 'flows'):
|
||||||
os.mkdir(os.path.join(ddir, x))
|
os.mkdir(os.path.join(ddir, x))
|
||||||
|
|
||||||
for rec in f.text_records:
|
for rec in f.text_records:
|
||||||
@ -207,3 +214,6 @@ def inspect_mobi(mobi_file, ddir):
|
|||||||
for part in f.files:
|
for part in f.files:
|
||||||
part.dump(os.path.join(ddir, 'files'))
|
part.dump(os.path.join(ddir, 'files'))
|
||||||
|
|
||||||
|
f.dump_flows(os.path.join(ddir, 'flows'))
|
||||||
|
|
||||||
|
|
||||||
|
@ -173,7 +173,7 @@ class KF8Writer(object):
|
|||||||
if item.media_type == SVG_MIME:
|
if item.media_type == SVG_MIME:
|
||||||
data = self.data(item)
|
data = self.data(item)
|
||||||
images[item.href] = len(self.flows)
|
images[item.href] = len(self.flows)
|
||||||
self.flows.append(etree.tostring(data, encoding='UTF=8',
|
self.flows.append(etree.tostring(data, encoding='UTF-8',
|
||||||
with_tail=True, xml_declaration=True))
|
with_tail=True, xml_declaration=True))
|
||||||
|
|
||||||
for item in self.oeb.spine:
|
for item in self.oeb.spine:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user