Repository URL to install this package:
|
Version:
3.4.51 ▾
|
ó
MEYc @ sX d d l Z d d l Z e j Z d d d Z d d d d Z d Z d Z d S( iÿÿÿÿNt strictc C s¤ t | t j t j f s4 t d t | n t | t j rJ | S| sk t j j pe t j
} n y | j | | SWn t k
r | j d | SXd S( s Decodes incoming text/bytes string using `incoming` if they're not
already unicode.
:param incoming: Text's current encoding
:param errors: Errors handling policy. See here for valid
values http://docs.python.org/2/library/codecs.html
:returns: text or a unicode `incoming` encoded
representation of it.
:raises TypeError: If text is not an instance of str
s %s can't be decodeds utf-8N(
t
isinstancet sixt string_typest binary_typet TypeErrort typet text_typet syst stdint encodingt getdefaultencodingt decodet UnicodeDecodeError( t textt incomingt errors( ( sK /home/tvault/.virtenv/lib/python2.7/site-packages/oslo_utils/encodeutils.pyt safe_decode s
s utf-8c C sï t | t j t j f s4 t d t | n | sU t j j pO t j } n t
| d rs | j } n t
| d r | j } n t | t j r³ | j
| | S| rç | | k rç t | | | } | j
| | S| Sd S( s Encodes incoming text/bytes string using `encoding`.
If incoming is not specified, text is expected to be encoded with
current python's default encoding. (`sys.getdefaultencoding`)
:param incoming: Text's current encoding
:param encoding: Expected encoding for text (Default UTF-8)
:param errors: Errors handling policy. See here for valid
values http://docs.python.org/2/library/codecs.html
:returns: text or a bytestring `encoding` encoded
representation of it.
:raises TypeError: If text is not an instance of str
See also to_utf8() function which is simpler and don't depend on
the locale encoding.
s %s can't be encodedt lowerN( R R R R R R R R R
R t hasattrR R t encodeR ( R R R
R ( ( sK /home/tvault/.virtenv/lib/python2.7/site-packages/oslo_utils/encodeutils.pyt safe_encodeB s c C sO t | t r | St | t j r2 | j d St d t | j d S( s Encode Unicode to UTF-8, return bytes unchanged.
Raise TypeError if text is not a bytes string or a Unicode string.
.. versionadded:: 3.5
s utf-8s! bytes or Unicode expected, got %sN( R t bytesR R R R R t __name__( R ( ( sK /home/tvault/.virtenv/lib/python2.7/site-packages/oslo_utils/encodeutils.pyt to_utf8k s
c C sý d } t j rl y t | } Wql t k
rh t | d ri y | j } Wqe t k
ra qe Xqi ql Xn | d k r | j } n t | t j r | Sy | j
d SWn t k
rÁ n Xt } y | j
| SWn t k
rï n X| j
d S( sª Get the message of an exception as a Unicode string.
On Python 3, the exception message is always a Unicode string. On
Python 2, the exception message is a bytes string *most* of the time.
If the exception message is a bytes strings, try to decode it from UTF-8
(superset of ASCII), from the locale encoding, or fallback to decoding it
from ISO-8859-1 (which never fails).
.. versionadded:: 1.6
t __unicode__s utf-8t latin1N(
t NoneR t PY2t unicodet UnicodeErrorR R t __str__R R R R
t _getfilesystemencoding( t exct msgR
( ( sK /home/tvault/.virtenv/lib/python2.7/site-packages/oslo_utils/encodeutils.pyt exception_to_unicode{ s0
( R R t getfilesystemencodingR R R R R R# ( ( ( sK /home/tvault/.virtenv/lib/python2.7/site-packages/oslo_utils/encodeutils.pyt <module> s '(