File: //opt/saltstack/salt/lib/python3.10/site-packages/cheroot/__pycache__/_compat.cpython-310.pyc
o
�N�gT � @ s� d Z ddlmZmZmZ eZddlZddlZddl Z ddl
Z
zddlZW n
ey1 ddl
ZY nw zddlZejdkZ[W n eyI dZY nw zddlmZ W n eyg ddlmZ edd� �ZY nw ee�d ��Zee�d
��Ze�� dkZe�� ZedkZed
kZedkZe�� Z e �!d�Z"e
j#s�ddd�Z$ddd�Z%ddd�Z&nddd�Z$ddd�Z%ddd�Z&dd� Z'e
j#s� e(Z(n e)Z(dd� Z*dS )zECompatibility code for using Cheroot with various versions of Python.� )�absolute_import�division�print_functionN)� r )�suppress)�contextmanagerc g s$ � zdV W dS | y Y dS w )z:Return a context manager that suppresses the `exceptions`.N� )�
exceptionsr r �C/opt/saltstack/salt/lib/python3.10/site-packages/cheroot/_compat.pyr s ��r ZCIZGITHUB_WORKFLOW�PyPy�Windows�Linux�Darwin�ppc�
ISO-8859-1c C s t | � | �|�S �z8Return the native string as bytes in the given encoding.)�
assert_native�encode��n�encodingr r r
�ntob9 s
r c C � t | � | S )�<Return the native string as Unicode with the given encoding.�r r r r r
�ntou? s r c C s
| � |�S �z>Return the byte string as native string in the given encoding.)�decode��br r r r
�btonE s
r c C r r r r r r r
r J s c C s2 t | � |dkrt�ddd� | �d��S | �|�S )r �escapez\\u([0-9a-zA-Z]{4})c S s t �t| �d�d��S )Nr � )�sixZunichr�int�group)�mr r r
�<lambda>] s zntou.<locals>.<lambda>r )r �re�subr r r r r
r R s �
c C s | S r r r r r r
r d s c C s t | t�stdt| �j ��dS )zxCheck whether the input is of native :py:class:`str` type.
Raises:
TypeError: in case of failed check
zn must be a native str (got %s)N)�
isinstance�str� TypeError�type�__name__)r r r r
r i s
�r c C s6 t | t�rtjrt| �S | �� S t | t�r| S td��)aR Retrieve bytes out of the given input buffer.
:param mv: input :py:func:`buffer`
:type mv: memoryview or bytes
:return: unwrapped bytes
:rtype: bytes
:raises ValueError: if the input is not one of \
:py:class:`memoryview`/:py:func:`buffer` \
or :py:class:`bytes`
z8extract_bytes() only accepts bytes and memoryview/buffer)r* �
memoryviewr# �PY2�bytes�tobytes�
ValueError)�mvr r r
�
extract_bytes s
�r5 )r )+�__doc__Z
__future__r r r r- Z
__metaclass__�os�platformr( r# � selectors�ImportErrorZ
selectors2�ssl�OPENSSL_VERSION_INFOZIS_ABOVE_OPENSSL10�
contextlibr r �bool�getenvZIS_CIZIS_GITHUB_ACTIONS_WORKFLOW�python_implementationZIS_PYPY�systemZSYS_PLATFORMZ
IS_WINDOWSZIS_LINUXZIS_MACOS�machineZ
PLATFORM_ARCH�
startswithZIS_PPCr0 r r r r r/ �bufferr5 r r r r
�<module> sb �
��