o
    'h                   	   @  s   d Z ddlmZ ddlmZmZ zddlZW n ey)   dZ	ddddZ	Y dS w dZddl
Z
ejejejejejejejejejf	ZddddZ	dS )z&An implementation of RFC4013 SASLprep.    )annotations)AnyOptionalNFTdatar   prohibit_unassigned_code_pointsOptional[bool]returnc                 C  s   t | tr	td| S )zSASLprep dummyz[The stringprep module is not available. Usernames and passwords must be instances of bytes.)
isinstancestr	TypeError)r   r    r   L/var/www/html/olx_land/venv/lib/python3.10/site-packages/pymongo/saslprep.pysaslprep   s
   
r   c                   s   t | ts| S |rg ttjR }nt}tjtjdfdd| D } tj	
d| } tj}|| d rJ|| d sAtdg |tjR }ng ||R }| D ] t fdd	|D rdtd
qS| S )aV  An implementation of RFC4013 SASLprep.

        :param data: The string to SASLprep. Unicode strings
            (:class:`str`) are supported. Byte strings
            (:class:`bytes`) are ignored.
        :param prohibit_unassigned_code_points: True / False. RFC 3454
            and RFCs for various SASL mechanisms distinguish between
            `queries` (unassigned code points allowed) and
            `stored strings` (unassigned code points prohibited). Defaults
            to ``True`` (unassigned code points are prohibited).

        :return: The SASLprep'ed version of `data`.
         c                   s$   g | ]} |s|rd n|qS ) r   ).0elt)in_table_b1in_table_c12r   r   
<listcomp>X   s   $ zsaslprep.<locals>.<listcomp>NFKCr   z$SASLprep: failed bidirectional checkc                 3  s    | ]}| V  qd S )Nr   )r   in_table)charr   r   	<genexpr>q   s    zsaslprep.<locals>.<genexpr>z+SASLprep: failed prohibited character check)r	   r
   _PROHIBITED
stringprepin_table_a1r   r   joinunicodedata	ucd_3_2_0	normalizein_table_d1
ValueErrorin_table_d2any)r   r   
prohibitedr"   r   )r   r   r   r   r   9   s,   
)T)r   r   r   r   r   r   )__doc__
__future__r   typingr   r   r   ImportErrorHAVE_STRINGPREPr   r   r   in_table_c21_c22in_table_c3in_table_c4in_table_c5in_table_c6in_table_c7in_table_c8in_table_c9r   r   r   r   r   <module>   s.   