mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Micro-optimization
This commit is contained in:
parent
fd251bb00a
commit
ba0bcb408f
@ -242,12 +242,11 @@ def rewrite_links(root, link_repl_func, resolve_base_href=False):
|
|||||||
repl = repl.decode('utf-8')
|
repl = repl.decode('utf-8')
|
||||||
el.text = '\n'+ clean_xml_chars(repl) + '\n'
|
el.text = '\n'+ clean_xml_chars(repl) + '\n'
|
||||||
|
|
||||||
if 'style' in el.attrib:
|
text = el.get('style')
|
||||||
text = el.attrib['style']
|
if text and _css_url_re.search(text) is not None:
|
||||||
if _css_url_re.search(text) is not None:
|
|
||||||
try:
|
try:
|
||||||
stext = parser.parseStyle(text, validate=False)
|
stext = parser.parseStyle(text, validate=False)
|
||||||
except:
|
except Exception:
|
||||||
# Parsing errors are raised by cssutils
|
# Parsing errors are raised by cssutils
|
||||||
continue
|
continue
|
||||||
replaceUrls(stext, link_repl_func)
|
replaceUrls(stext, link_repl_func)
|
||||||
@ -255,7 +254,7 @@ def rewrite_links(root, link_repl_func, resolve_base_href=False):
|
|||||||
' ')
|
' ')
|
||||||
if isbytestring(repl):
|
if isbytestring(repl):
|
||||||
repl = repl.decode('utf-8')
|
repl = repl.decode('utf-8')
|
||||||
el.attrib['style'] = repl
|
el.set('style', repl)
|
||||||
|
|
||||||
|
|
||||||
types_map = get_types_map()
|
types_map = get_types_map()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user