mirror of
https://github.com/gryf/ebook-converter.git
synced 2026-04-24 07:01:30 +02:00
Move force_uniceode to utils package
This commit is contained in:
@@ -8,9 +8,9 @@ import re
|
||||
import sys
|
||||
import urllib.parse
|
||||
|
||||
from ebook_converter import force_unicode
|
||||
from ebook_converter.utils.config_base import tweaks
|
||||
from ebook_converter.polyglot.urllib import unquote
|
||||
from ebook_converter.utils import encoding as uenc
|
||||
|
||||
|
||||
try:
|
||||
@@ -43,7 +43,7 @@ def remove_bracketed_text(src, brackets=None):
|
||||
from collections import Counter
|
||||
counts = Counter()
|
||||
buf = []
|
||||
src = force_unicode(src)
|
||||
src = uenc.force_unicode(src)
|
||||
rmap = {v: k for k, v in brackets.items()}
|
||||
for char in src:
|
||||
if char in brackets:
|
||||
@@ -75,7 +75,7 @@ def author_to_author_sort(author, method=None):
|
||||
if method == 'copy':
|
||||
return author
|
||||
|
||||
prefixes = {force_unicode(y).lower()
|
||||
prefixes = {uenc.force_unicode(y).lower()
|
||||
for y in tweaks['author_name_prefixes']}
|
||||
prefixes |= {y+'.' for y in prefixes}
|
||||
while True:
|
||||
@@ -87,7 +87,7 @@ def author_to_author_sort(author, method=None):
|
||||
else:
|
||||
break
|
||||
|
||||
suffixes = {force_unicode(y).lower()
|
||||
suffixes = {uenc.force_unicode(y).lower()
|
||||
for y in tweaks['author_name_suffixes']}
|
||||
suffixes |= {y+'.' for y in suffixes}
|
||||
|
||||
|
||||
@@ -12,10 +12,10 @@ from lxml import etree
|
||||
from ebook_converter.utils.date import parse_only_date
|
||||
from ebook_converter.utils.img import save_cover_data_to
|
||||
from ebook_converter.utils.imghdr import identify
|
||||
from ebook_converter import force_unicode
|
||||
from ebook_converter.ebooks.metadata import MetaInformation, check_isbn
|
||||
from ebook_converter.ebooks.chardet import xml_to_unicode
|
||||
from ebook_converter.polyglot.binary import as_base64_unicode
|
||||
from ebook_converter.utils import encoding as uenc
|
||||
|
||||
|
||||
NAMESPACES = {'fb2': 'http://www.gribuser.ru/xml/fictionbook/2.0',
|
||||
@@ -110,7 +110,7 @@ def get_metadata(stream):
|
||||
if book_title:
|
||||
book_title = str(book_title)
|
||||
else:
|
||||
book_title = force_unicode(os.path.splitext(
|
||||
book_title = uenc.force_unicode(os.path.splitext(
|
||||
os.path.basename(getattr(stream, 'name', 'Unknown')))[0])
|
||||
mi = MetaInformation(book_title, authors)
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@ Edit metadata in RTF files.
|
||||
import codecs
|
||||
import re
|
||||
|
||||
from ebook_converter import force_unicode
|
||||
from ebook_converter.ebooks.metadata import MetaInformation
|
||||
from ebook_converter.utils import encoding as uenc
|
||||
|
||||
title_pat = re.compile(br'\{\\info.*?\{\\title(.*?)(?<!\\)\}', re.DOTALL)
|
||||
author_pat = re.compile(br'\{\\info.*?\{\\author(.*?)(?<!\\)\}', re.DOTALL)
|
||||
@@ -74,7 +74,7 @@ def detect_codepage(stream):
|
||||
|
||||
def encode(unistr):
|
||||
if not isinstance(unistr, str):
|
||||
unistr = force_unicode(unistr)
|
||||
unistr = uenc.force_unicode(unistr)
|
||||
return ''.join(c if ord(c) < 128 else
|
||||
'\\u{}?'.format(ord(c)) for c in unistr)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user