Returns textual value of a given value (Note: not necessary Unicode on Python2) >>> getText(b"foobar") 'foobar' >>> isinstance(getText(u"fo\\u2299bar"), six.text_type) True
(value, encoding=None)
| 381 | return six.text_type(str(value), errors="ignore") # encoding ignored for non-basestring instances |
| 382 | |
| 383 | def getText(value, encoding=None): |
| 384 | """ |
| 385 | Returns textual value of a given value (Note: not necessary Unicode on Python2) |
| 386 | |
| 387 | >>> getText(b"foobar") |
| 388 | 'foobar' |
| 389 | >>> isinstance(getText(u"fo\\u2299bar"), six.text_type) |
| 390 | True |
| 391 | """ |
| 392 | |
| 393 | retVal = value |
| 394 | |
| 395 | if isinstance(value, six.binary_type): |
| 396 | retVal = getUnicode(value, encoding) |
| 397 | |
| 398 | if six.PY2: |
| 399 | try: |
| 400 | retVal = str(retVal) |
| 401 | except: |
| 402 | pass |
| 403 | |
| 404 | return retVal |
| 405 | |
| 406 | def stdoutEncode(value): |
| 407 | """ |
no test coverage detected
searching dependent graphs…