Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(12)  |  Call(6)  |  Derive(0)  |  Import(6)

        def safe_decode(s, encoding=None):
    '''Similar to bytes `decode` method returning unicode.

    Decodes `s` using the given `encoding`, or determining one from the system.

    Returning type depend on python version; if 2.x is `unicode` if 3.x `str`.

    .. versionadded:: 1.1.3

    if isinstance(s, _unicode):
        return s
        encoding = force_encoding(encoding)
            # In Python 3 str(b'm') returns the string "b'm'" and not just "m",
            # this fixes this.
            return _unicode(s, encoding, 'replace')
            # For numbers and other stuff.
            return _unicode(s)

src/x/o/xoutil-1.5.4/xoutil/html/__init__.py   xoutil(Download)
from xoutil.six import PY3 as _py3k, iteritems as iteritems_
from xoutil.string import safe_decode
for name, entity in iteritems_(entities.entitydefs):
    text = entities.entitydefs_unicode[name] = safe_decode(entity, 'latin-1')
    entities.entitydefs_utf8[name] = text.encode('utf-8')
del name, entity, safe_decode, iteritems_
        from xoutil.six import text_type
        from xoutil.string import safe_decode, safe_encode
        if not isinstance(s, text_type):
            arg = safe_decode(s)

src/x/o/xoutil-1.5.4/xoutil/web.py   xoutil(Download)
    import re
    from xoutil.six import unichr
    from xoutil.string import _unicode, safe_decode, normalize_slug
    if not isinstance(s, _unicode):
        s = safe_decode(s)

src/x/o/xoutil-1.5.4/xoutil/cli/tools.py   xoutil(Download)
        from io import StringIO
        from xoutil.string import safe_decode
        buf = StringIO()
        start = True
        for letter in cls.__name__:
            if letter.isupper():
                if not start:
                letter = letter.lower()
            start = False

src/x/o/xoutil-1.5.4/xoutil/pprint.py   xoutil(Download)
        return res
        from xoutil.string import safe_decode
        return safe_decode(res)

src/x/o/xoutil-1.5.4/xoutil/objects.py   xoutil(Download)
    from xoutil.string import safe_decode
    assert isinstance(cls, type), _INVALID_CLASS_TYPE_MSG
    if deep < 1: