push
travis-ci
25 of 25 new or added lines in 3 files covered. (100.0%)
231 of 267 relevant lines covered (86.52%)
3.41 hits per line
1 |
# -*- coding: utf-8 -*-
|
|
2 |
# © 2015 ACSONE SA/NV
|
|
3 |
# License AGPLv3 (http://www.gnu.org/licenses/agpl-3.0-standalone.html)
|
|
|
import sys |
4✔ |
5 |
|
|
|
PY2 = sys.version_info[0] == 2 |
4✔ |
7 |
|
|
|
if PY2:
|
4✔ |
|
string_types = (str, unicode) # noqa |
1 only 21.1 ✔ |
10 |
|
|
|
def console_to_str(s): |
1 only 21.1 ✔ |
|
return s.decode('utf_8') |
1 only 21.1 ✔ |
13 |
else:
|
|
|
string_types = (str,)
|
3 all except 21.1 ✔ |
|
console_encoding = sys.__stdout__.encoding |
3 all except 21.1 ✔ |
16 |
|
|
|
def console_to_str(s): |
3 all except 21.1 ✔ |
18 |
""" From pypa/pip project, pip.backwardwardcompat. License MIT. """
|
|
|
try:
|
3 all except 21.1 ✔ |
|
return s.decode(console_encoding)
|
3 all except 21.1 ✔ |
|
except UnicodeDecodeError: |
× |
|
return s.decode('utf_8') |
× |
|
except AttributeError: # for tests, #13 |
× |
|
return s
|
× |