mirror of
https://github.com/gryf/ebook-converter.git
synced 2026-04-21 05:31:30 +02:00
Move force_uniceode to utils package
This commit is contained in:
@@ -3,12 +3,12 @@ import functools
|
||||
|
||||
from css_parser.css import CSSRule, CSSStyleDeclaration
|
||||
|
||||
from ebook_converter import force_unicode
|
||||
from ebook_converter.css_selectors import parse, SelectorSyntaxError
|
||||
from ebook_converter.ebooks.oeb import base
|
||||
from ebook_converter.ebooks.oeb.polish import pretty
|
||||
from ebook_converter.utils.icu import numeric_sort_key
|
||||
from ebook_converter.css_selectors import Select, SelectorError
|
||||
from ebook_converter.utils import encoding as uenc
|
||||
|
||||
|
||||
def filter_used_rules(rules, log, select):
|
||||
@@ -137,7 +137,7 @@ def remove_unused_css(container, report=None, remove_unused_classes=False,
|
||||
if unused_rules:
|
||||
num_of_removed_rules += len(unused_rules)
|
||||
[sheet.cssRules.remove(r) for r in unused_rules]
|
||||
style.text = force_unicode(sheet.cssText, 'utf-8')
|
||||
style.text = uenc.force_unicode(sheet.cssText, 'utf-8')
|
||||
pretty.pretty_script_or_style(container, style)
|
||||
container.dirty(name)
|
||||
|
||||
@@ -241,7 +241,7 @@ def transform_inline_styles(container, name, transform_sheet, transform_style):
|
||||
sheet = container.parse_css(style.text)
|
||||
if transform_sheet(sheet):
|
||||
changed = True
|
||||
style.text = force_unicode(sheet.cssText, 'utf-8')
|
||||
style.text = uenc.force_unicode(sheet.cssText, 'utf-8')
|
||||
pretty.pretty_script_or_style(container, style)
|
||||
for elem in root.xpath('//*[@style]'):
|
||||
text = elem.get('style', None)
|
||||
@@ -253,8 +253,9 @@ def transform_inline_styles(container, name, transform_sheet, transform_style):
|
||||
del elem.attrib['style']
|
||||
else:
|
||||
elem.set('style',
|
||||
force_unicode(style.getCssText(separator=' '),
|
||||
'utf-8'))
|
||||
uenc.force_unicode(style
|
||||
.getCssText(separator=' '),
|
||||
'utf-8'))
|
||||
return changed
|
||||
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import textwrap
|
||||
|
||||
from ebook_converter import constants as const
|
||||
from ebook_converter import force_unicode
|
||||
from ebook_converter.ebooks.oeb import parse_utils
|
||||
from ebook_converter.ebooks.oeb import base
|
||||
from ebook_converter.ebooks.oeb.polish.utils import guess_type
|
||||
from ebook_converter.utils import encoding as uenc
|
||||
from ebook_converter.utils.icu import sort_key
|
||||
|
||||
|
||||
@@ -157,8 +157,9 @@ def pretty_script_or_style(container, child):
|
||||
if child.text:
|
||||
indent = indent_for_tag(child)
|
||||
if child.tag.endswith('style'):
|
||||
child.text = force_unicode(pretty_css(container, '', child.text),
|
||||
'utf-8')
|
||||
child.text = uenc.force_unicode(pretty_css(container, '',
|
||||
child.text),
|
||||
'utf-8')
|
||||
child.text = textwrap.dedent(child.text)
|
||||
child.text = '\n' + '\n'.join([(indent + x) if x else ''
|
||||
for x in child.text.splitlines()])
|
||||
|
||||
Reference in New Issue
Block a user