|
@@ -16,6 +16,9 @@ def default_sigint():
|
|
finally:
|
|
finally:
|
|
signal.signal(signal.SIGINT, original_sigint_handler)
|
|
signal.signal(signal.SIGINT, original_sigint_handler)
|
|
|
|
|
|
|
|
+def get_encoding():
|
|
|
|
+ return locale.getpreferredencoding()
|
|
|
|
+
|
|
def to_utf8(s):
|
|
def to_utf8(s):
|
|
"""Re-encode string from the default system encoding to UTF-8."""
|
|
"""Re-encode string from the default system encoding to UTF-8."""
|
|
current = locale.getpreferredencoding()
|
|
current = locale.getpreferredencoding()
|
|
@@ -42,10 +45,6 @@ def catch_exceptions(exit_codes, fun, *args, **kwargs):
|
|
debug("[{0}] {1}".format(exc.__class__.__name__, exc))
|
|
debug("[{0}] {1}".format(exc.__class__.__name__, exc))
|
|
return exit_codes[exc.__class__]
|
|
return exit_codes[exc.__class__]
|
|
|
|
|
|
-def get_encoding(fd):
|
|
|
|
- """Guess terminal encoding."""
|
|
|
|
- return fd.encoding or locale.getpreferredencoding()
|
|
|
|
-
|
|
|
|
def first(it):
|
|
def first(it):
|
|
"""Return first element in iterable."""
|
|
"""Return first element in iterable."""
|
|
return it.next()
|
|
return it.next()
|