mirror of
https://github.com/gryf/ebook-converter.git
synced 2026-03-27 13:53:32 +01:00
Some misc cleanups
This commit is contained in:
@@ -7,12 +7,9 @@ import sys
|
||||
import time
|
||||
import urllib.parse
|
||||
import urllib.request
|
||||
import warnings
|
||||
|
||||
from functools import partial
|
||||
|
||||
if os.getenv('CALIBRE_SHOW_DEPRECATION_WARNINGS') is None:
|
||||
warnings.simplefilter('ignore', DeprecationWarning)
|
||||
try:
|
||||
os.getcwd()
|
||||
except EnvironmentError:
|
||||
@@ -140,9 +137,6 @@ def sanitize_file_name(name, substitute='_'):
|
||||
return one
|
||||
|
||||
|
||||
sanitize_file_name2 = sanitize_file_name_unicode = sanitize_file_name
|
||||
|
||||
|
||||
def prints(*args, **kwargs):
|
||||
'''
|
||||
Print unicode arguments safely by encoding them to preferred_encoding
|
||||
@@ -551,12 +545,12 @@ def entity_to_unicode(match, exceptions=[], encoding='cp1252',
|
||||
|
||||
|
||||
_ent_pat = re.compile(r'&(\S+?);')
|
||||
xml_entity_to_unicode = partial(entity_to_unicode, result_exceptions={
|
||||
'"' : '"',
|
||||
"'" : ''',
|
||||
'<' : '<',
|
||||
'>' : '>',
|
||||
'&' : '&'})
|
||||
xml_entity_to_unicode = partial(entity_to_unicode,
|
||||
result_exceptions={'"': '"',
|
||||
"'": ''',
|
||||
'<': '<',
|
||||
'>': '>',
|
||||
'&': '&'})
|
||||
|
||||
|
||||
def replace_entities(raw, encoding='cp1252'):
|
||||
@@ -586,7 +580,7 @@ def force_unicode(obj, enc=preferred_encoding):
|
||||
except Exception:
|
||||
try:
|
||||
obj = obj.decode(filesystem_encoding if enc ==
|
||||
preferred_encoding else preferred_encoding)
|
||||
preferred_encoding else preferred_encoding)
|
||||
except Exception:
|
||||
try:
|
||||
obj = obj.decode('utf-8')
|
||||
@@ -628,11 +622,6 @@ def human_readable(size, sep=' '):
|
||||
return size + sep + suffix
|
||||
|
||||
|
||||
def ipython(user_ns=None):
|
||||
from ebook_converter.utils.ipython import ipython
|
||||
ipython(user_ns=user_ns)
|
||||
|
||||
|
||||
def fsync(fileobj):
|
||||
fileobj.flush()
|
||||
os.fsync(fileobj.fileno())
|
||||
|
||||
Reference in New Issue
Block a user