travis-ci
1 of 1 new or added line in 1 file covered. (100.0%)
277 of 339 relevant lines covered (81.71%)
4.04 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)
|
|
4 |
import sys |
5✔ |
5 |
|
|
6 |
PY2 = sys.version_info[0] == 2 |
5✔ |
7 |
|
|
8 |
if PY2:
|
5✔ |
9 |
string_types = (str, unicode) # noqa |
1 only 112.1 ✔ |
10 |
|
|
11 |
def console_to_str(s): |
1 only 112.1 ✔ |
12 |
return s.decode('utf_8') |
1 only 112.1 ✔ |
13 |
else:
|
|
14 |
string_types = (str,)
|
4 all except 112.1 ✔ |
15 |
console_encoding = sys.__stdout__.encoding |
4 all except 112.1 ✔ |
16 |
|
|
17 |
def console_to_str(s): |
4 all except 112.1 ✔ |
18 |
""" From pypa/pip project, pip.backwardwardcompat. License MIT. """
|
|
19 |
try:
|
4 all except 112.1 ✔ |
20 |
return s.decode(console_encoding)
|
4 all except 112.1 ✔ |
21 |
except UnicodeDecodeError: |
× |
22 |
return s.decode('utf_8') |
× |
23 |
except AttributeError: # for tests, #13 |
× |
24 |
return s
|
× |