Anons79 Mini Shell

Directory : /lib/python2.7/site-packages/ansible/module_utils/
Upload File :
Current File : //lib/python2.7/site-packages/ansible/module_utils/_text.pyc

�
�Udac@s�dZddlZddlmZmZmZyejd�eZWne	k
r^e
ZnXed�Z
ddd	d
�Zddd	d�Zer�eZneZdS(
s(
.. warn:: This module_util is currently internal implementation.
    We want to evaluate this code for stability and API suitability before
    making backwards compatibility guarantees.  The API may change between
    releases.  Do not use this unless you are willing to port your module code.
i����N(tPY3t	text_typetbinary_typetsurrogateescapetsurrogate_or_replacetsurrogate_or_stricttsurrogate_then_replacesutf-8t
simplereprcCs�t|t�r|S|}|tkrRtr4d}qR|dkrId}qRd}nt|t�r�y|j||�SWq�tk
r�|dkr�|jdd�}|jdd�}|j|d�S�q�Xn|dkr-yt	|�}Wq~t
k
r)yt|�}Wq*t
k
r%td�SXq~XnQ|d	kr=|S|d
krStd�S|dkrnt
d��nt
d|��t|||�S(s
Make sure that a string is a byte string

    :arg obj: An object to make sure is a byte string.  In most cases this
        will be either a text string or a byte string.  However, with
        ``nonstring='simplerepr'``, this can be used as a traceback-free
        version of ``str(obj)``.
    :kwarg encoding: The encoding to use to transform from a text string to
        a byte string.  Defaults to using 'utf-8'.
    :kwarg errors: The error handler to use if the text string is not
        encodable using the specified encoding.  Any valid `codecs error
        handler <https://docs.python.org/2/library/codecs.html#codec-base-classes>`_
        may be specified. There are three additional error strategies
        specifically aimed at helping people to port code.  The first two are:

            :surrogate_or_strict: Will use ``surrogateescape`` if it is a valid
                handler, otherwise it will use ``strict``
            :surrogate_or_replace: Will use ``surrogateescape`` if it is a valid
                handler, otherwise it will use ``replace``.

        Because ``surrogateescape`` was added in Python3 this usually means that
        Python3 will use ``surrogateescape`` and Python2 will use the fallback
        error handler. Note that the code checks for ``surrogateescape`` when the
        module is imported.  If you have a backport of ``surrogateescape`` for
        Python2, be sure to register the error handler prior to importing this
        module.

        The last error handler is:

            :surrogate_then_replace: Will use ``surrogateescape`` if it is a valid
                handler.  If encoding with ``surrogateescape`` would traceback,
                surrogates are first replaced with a replacement characters
                and then the string is encoded using ``replace`` (which replaces
                the rest of the nonencodable bytes).  If ``surrogateescape`` is
                not present it will simply use ``replace``.  (Added in Ansible 2.3)
                This strategy is designed to never traceback when it attempts
                to encode a string.

        The default until Ansible-2.2 was ``surrogate_or_replace``
        From Ansible-2.3 onwards, the default is ``surrogate_then_replace``.

    :kwarg nonstring: The strategy to use if a nonstring is specified in
        ``obj``.  Default is 'simplerepr'.  Valid values are:

        :simplerepr: The default.  This takes the ``str`` of the object and
            then returns the bytes version of that string.
        :empty: Return an empty byte string
        :passthru: Return the object passed in
        :strict: Raise a :exc:`TypeError`

    :returns: Typically this returns a byte string.  If a nonstring object is
        passed in this may be a different type depending on the strategy
        specified by nonstring.  This will never return a text string.

    .. note:: If passed a byte string, this function does not check that the
        string is valid in the specified encoding.  If it's important that the
        byte string is in the specified encoding do::

            encoded_string = to_bytes(to_text(input_string, 'latin-1'), 'utf-8')

    .. version_changed:: 2.3

        Added the ``surrogate_then_replace`` error handler and made it the default error handler.
    RRtstricttreplaceRsutf-8Rttpassthrutemptysobj must be a string types2Invalid value %s for to_bytes' nonstring parameterN(NR(t
isinstanceRt_COMPOSED_ERROR_HANDLERStHAS_SURROGATEESCAPERtencodetUnicodeEncodeErrortNonetdecodetstrtUnicodeErrortreprtto_bytest	TypeError(tobjtencodingterrorst	nonstringtoriginal_errorst
return_stringtvalue((s>/usr/lib/python2.7/site-packages/ansible/module_utils/_text.pyR4sD@			




cCst|t�r|S|tkrLtr.d}qL|dkrCd}qLd}nt|t�rk|j||�S|dkr�yt|�}Wqtk
r�yt|�}Wq�tk
r�dSXqXnK|dkr�|S|dkr�dS|dkr�t	d	��nt	d
|��t
|||�S(s�
Make sure that a string is a text string

    :arg obj: An object to make sure is a text string.  In most cases this
        will be either a text string or a byte string.  However, with
        ``nonstring='simplerepr'``, this can be used as a traceback-free
        version of ``str(obj)``.
    :kwarg encoding: The encoding to use to transform from a byte string to
        a text string.  Defaults to using 'utf-8'.
    :kwarg errors: The error handler to use if the byte string is not
        decodable using the specified encoding.  Any valid `codecs error
        handler <https://docs.python.org/2/library/codecs.html#codec-base-classes>`_
        may be specified.   We support three additional error strategies
        specifically aimed at helping people to port code:

            :surrogate_or_strict: Will use surrogateescape if it is a valid
                handler, otherwise it will use strict
            :surrogate_or_replace: Will use surrogateescape if it is a valid
                handler, otherwise it will use replace.
            :surrogate_then_replace: Does the same as surrogate_or_replace but
                `was added for symmetry with the error handlers in
                :func:`ansible.module_utils._text.to_bytes` (Added in Ansible 2.3)

        Because surrogateescape was added in Python3 this usually means that
        Python3 will use `surrogateescape` and Python2 will use the fallback
        error handler. Note that the code checks for surrogateescape when the
        module is imported.  If you have a backport of `surrogateescape` for
        python2, be sure to register the error handler prior to importing this
        module.

        The default until Ansible-2.2 was `surrogate_or_replace`
        In Ansible-2.3 this defaults to `surrogate_then_replace` for symmetry
        with :func:`ansible.module_utils._text.to_bytes` .
    :kwarg nonstring: The strategy to use if a nonstring is specified in
        ``obj``.  Default is 'simplerepr'.  Valid values are:

        :simplerepr: The default.  This takes the ``str`` of the object and
            then returns the text version of that string.
        :empty: Return an empty text string
        :passthru: Return the object passed in
        :strict: Raise a :exc:`TypeError`

    :returns: Typically this returns a text string.  If a nonstring object is
        passed in this may be a different type depending on the strategy
        specified by nonstring.  This will never return a byte string.
        From Ansible-2.3 onwards, the default is `surrogate_then_replace`.

    .. version_changed:: 2.3

        Added the surrogate_then_replace error handler and made it the default error handler.
    RRRR	RuRRsobj must be a string types2Invalid value %s for to_text's nonstring parameter(R
RRRRRRRRRtto_text(RRRRR((s>/usr/lib/python2.7/site-packages/ansible/module_utils/_text.pyR �s43			

(NRssurrogate_or_strictssurrogate_then_replace(t__doc__tcodecstansible.module_utils.sixRRRtlookup_errortTrueRtLookupErrortFalset	frozensetRRRR t	to_native(((s>/usr/lib/python2.7/site-packages/ansible/module_utils/_text.pyt<module>"s



	uj	

Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]