1
0
mirror of https://github.com/gryf/ebook-converter.git synced 2026-04-27 17:13:32 +02:00

Move force_uniceode to utils package

This commit is contained in:
2020-11-11 19:30:50 +01:00
parent 35c34c3b45
commit 3152c52839
16 changed files with 72 additions and 60 deletions
+6 -3
View File
@@ -119,21 +119,24 @@ def reset_base_dir():
base_dir()
def force_unicode(x):
def _force_unicode(x):
# Cannot use the implementation in calibre.__init__ as it causes a circular
# dependency
# NOTE(gryf): Congratulations! that's a 3rd function in this codebase
# called force_unicode! I guess that forcing unicode on text objects is
# some kind of hobby.
if isinstance(x, bytes):
x = x.decode(filesystem_encoding)
return x
def _make_file(suffix, prefix, base):
suffix, prefix = map(force_unicode, (suffix, prefix)) # no2to3
suffix, prefix = map(_force_unicode, (suffix, prefix)) # no2to3
return tempfile.mkstemp(suffix, prefix, dir=base)
def _make_dir(suffix, prefix, base):
suffix, prefix = map(force_unicode, (suffix, prefix)) # no2to3
suffix, prefix = map(_force_unicode, (suffix, prefix)) # no2to3
return tempfile.mkdtemp(suffix, prefix, base)