File: textutils.py

package info (click to toggle)
junit2html 31.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 576 kB
  • sloc: xml: 3,208; python: 1,023; makefile: 6; sh: 5
file content (16 lines) | stat: -rw-r--r-- 302 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
"""
Stringify to unicode
"""

from typing import Any, Optional


def unicode_str(text: "Optional[Any]"):
    """
    Convert text to unicode
    :param text:
    :return:
    """
    if isinstance(text, bytes):
        return text.decode("utf-8", "strict")
    return "" if text is None else str(text)