mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-08-11 09:13:57 -04:00
Fix #1218 (LRF2LRS error)
This commit is contained in:
parent
828a141b29
commit
a3fa08360c
@ -201,7 +201,7 @@ def sanitize_file_name(name):
|
|||||||
Also remove path separators. All illegal characters are replaced by
|
Also remove path separators. All illegal characters are replaced by
|
||||||
underscores.
|
underscores.
|
||||||
'''
|
'''
|
||||||
return re.sub(r'\s', ' ', re.sub(r'["\'\|\~\:\?\\\/]|^-', '_', name.strip()))
|
return re.sub(r'\s', ' ', re.sub(r'[\xae"\'\|\~\:\?\\\/]|^-', '_', name.strip()))
|
||||||
|
|
||||||
def detect_ncpus():
|
def detect_ncpus():
|
||||||
"""Detects the number of effective CPUs in the system"""
|
"""Detects the number of effective CPUs in the system"""
|
||||||
|
@ -4,7 +4,7 @@ __copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
|||||||
|
|
||||||
import sys, array, os, re, codecs, logging
|
import sys, array, os, re, codecs, logging
|
||||||
|
|
||||||
from calibre import setup_cli_handlers
|
from calibre import setup_cli_handlers, sanitize_file_name
|
||||||
from calibre.utils.config import OptionParser
|
from calibre.utils.config import OptionParser
|
||||||
from calibre.ebooks.lrf.meta import LRFMetaFile
|
from calibre.ebooks.lrf.meta import LRFMetaFile
|
||||||
from calibre.ebooks.lrf.objects import get_object, PageTree, StyleObject, \
|
from calibre.ebooks.lrf.objects import get_object, PageTree, StyleObject, \
|
||||||
@ -89,8 +89,9 @@ class LRFDocument(LRFMetaFile):
|
|||||||
bookinfo += u'<FreeText reading="">%s</FreeText>\n</BookInfo>\n<DocInfo>\n'%(self.metadata.free_text,)
|
bookinfo += u'<FreeText reading="">%s</FreeText>\n</BookInfo>\n<DocInfo>\n'%(self.metadata.free_text,)
|
||||||
th = self.doc_info.thumbnail
|
th = self.doc_info.thumbnail
|
||||||
if th:
|
if th:
|
||||||
bookinfo += u'<CThumbnail file="%s" />\n'%(self.metadata.title+'_thumbnail.'+self.doc_info.thumbnail_extension,)
|
prefix = sanitize_file_name(self.metadata.title)
|
||||||
open(self.metadata.title+'_thumbnail.'+self.doc_info.thumbnail_extension, 'wb').write(th)
|
bookinfo += u'<CThumbnail file="%s" />\n'%(prefix+'_thumbnail.'+self.doc_info.thumbnail_extension,)
|
||||||
|
open(prefix+'_thumbnail.'+self.doc_info.thumbnail_extension, 'wb').write(th)
|
||||||
bookinfo += u'<Language reading="">%s</Language>\n'%(self.doc_info.language,)
|
bookinfo += u'<Language reading="">%s</Language>\n'%(self.doc_info.language,)
|
||||||
bookinfo += u'<Creator reading="">%s</Creator>\n'%(self.doc_info.creator,)
|
bookinfo += u'<Creator reading="">%s</Creator>\n'%(self.doc_info.creator,)
|
||||||
bookinfo += u'<Producer reading="">%s</Producer>\n'%(self.doc_info.producer,)
|
bookinfo += u'<Producer reading="">%s</Producer>\n'%(self.doc_info.producer,)
|
||||||
|
@ -35,7 +35,7 @@ def normpath(x):
|
|||||||
x = x.lower()
|
x = x.lower()
|
||||||
return x
|
return x
|
||||||
|
|
||||||
_filename_sanitize = re.compile(r'[\0\\|\?\*<":>\+\[\]/]')
|
_filename_sanitize = re.compile(r'[\xae\0\\|\?\*<":>\+\[\]/]')
|
||||||
def sanitize_file_name(name, substitute='_'):
|
def sanitize_file_name(name, substitute='_'):
|
||||||
'''
|
'''
|
||||||
Sanitize the filename `name`. All invalid characters are replaced by `substitute`.
|
Sanitize the filename `name`. All invalid characters are replaced by `substitute`.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user