mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
kepubify: Handle long file internal paths on windows
This commit is contained in:
parent
c3d35d2733
commit
4bffaa147a
@ -50,7 +50,7 @@ from calibre.ebooks.oeb.polish.parsing import decode_xml
|
|||||||
from calibre.ebooks.oeb.polish.parsing import parse as parse_html_tweak
|
from calibre.ebooks.oeb.polish.parsing import parse as parse_html_tweak
|
||||||
from calibre.ebooks.oeb.polish.utils import OEB_FONTS, CommentFinder, PositionFinder, adjust_mime_for_epub, guess_type, insert_self_closing, parse_css
|
from calibre.ebooks.oeb.polish.utils import OEB_FONTS, CommentFinder, PositionFinder, adjust_mime_for_epub, guess_type, insert_self_closing, parse_css
|
||||||
from calibre.ptempfile import PersistentTemporaryDirectory, PersistentTemporaryFile, TemporaryDirectory
|
from calibre.ptempfile import PersistentTemporaryDirectory, PersistentTemporaryFile, TemporaryDirectory
|
||||||
from calibre.utils.filenames import hardlink_file, nlinks_file, retry_on_fail
|
from calibre.utils.filenames import hardlink_file, make_long_path_useable, nlinks_file, retry_on_fail
|
||||||
from calibre.utils.ipc.simple_worker import WorkerError, fork_job
|
from calibre.utils.ipc.simple_worker import WorkerError, fork_job
|
||||||
from calibre.utils.logging import default_log
|
from calibre.utils.logging import default_log
|
||||||
from calibre.utils.xml_parse import safe_xml_fromstring
|
from calibre.utils.xml_parse import safe_xml_fromstring
|
||||||
@ -1076,7 +1076,7 @@ class Container(ContainerBase): # {{{
|
|||||||
this will commit the file if it is dirtied and remove it from the parse
|
this will commit the file if it is dirtied and remove it from the parse
|
||||||
cache. You must finish with this file before accessing the parsed
|
cache. You must finish with this file before accessing the parsed
|
||||||
version of it again, or bad things will happen. '''
|
version of it again, or bad things will happen. '''
|
||||||
return open(self.get_file_path_for_processing(name, mode not in {'r', 'rb'}), mode)
|
return open(make_long_path_useable(self.get_file_path_for_processing(name, mode not in {'r', 'rb'})), mode)
|
||||||
|
|
||||||
def commit(self, outpath=None, keep_parsed=False):
|
def commit(self, outpath=None, keep_parsed=False):
|
||||||
'''
|
'''
|
||||||
|
@ -34,6 +34,7 @@ from calibre.ebooks.oeb.polish.tts import lang_for_elem
|
|||||||
from calibre.ebooks.oeb.polish.utils import extract, insert_self_closing
|
from calibre.ebooks.oeb.polish.utils import extract, insert_self_closing
|
||||||
from calibre.spell.break_iterator import sentence_positions
|
from calibre.spell.break_iterator import sentence_positions
|
||||||
from calibre.srv.render_book import Profiler, calculate_number_of_workers
|
from calibre.srv.render_book import Profiler, calculate_number_of_workers
|
||||||
|
from calibre.utils.filenames import make_long_path_useable
|
||||||
from calibre.utils.localization import canonicalize_lang, get_lang
|
from calibre.utils.localization import canonicalize_lang, get_lang
|
||||||
from calibre.utils.short_uuid import uuid4
|
from calibre.utils.short_uuid import uuid4
|
||||||
|
|
||||||
@ -371,7 +372,7 @@ def kepubify_html_data(raw: str | bytes, kobo_js_href: str = KOBO_JS_NAME, opts:
|
|||||||
|
|
||||||
|
|
||||||
def kepubify_html_path(path: str, kobo_js_href: str = KOBO_JS_NAME, metadata_lang: str = 'en', opts: Options = Options()):
|
def kepubify_html_path(path: str, kobo_js_href: str = KOBO_JS_NAME, metadata_lang: str = 'en', opts: Options = Options()):
|
||||||
with open(path, 'r+b') as f:
|
with open(make_long_path_useable(path), 'r+b') as f:
|
||||||
raw = f.read()
|
raw = f.read()
|
||||||
root = kepubify_html_data(raw, kobo_js_href, opts, metadata_lang)
|
root = kepubify_html_data(raw, kobo_js_href, opts, metadata_lang)
|
||||||
raw = serialize_html(root)
|
raw = serialize_html(root)
|
||||||
@ -461,7 +462,7 @@ def first_spine_item_is_probably_title_page(container: Container) -> bool:
|
|||||||
|
|
||||||
def process_stylesheet_path(path: str, opts: Options) -> None:
|
def process_stylesheet_path(path: str, opts: Options) -> None:
|
||||||
if opts.needs_stylesheet_processing:
|
if opts.needs_stylesheet_processing:
|
||||||
with open(path, 'r+b') as f:
|
with open(make_long_path_useable(path), 'r+b') as f:
|
||||||
css = f.read().decode()
|
css = f.read().decode()
|
||||||
ncss = process_stylesheet(css, opts)
|
ncss = process_stylesheet(css, opts)
|
||||||
if ncss is not css:
|
if ncss is not css:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user