o
    C©Ì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   ú_/var/www/html/Moveonwheels/move_on_wheels/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.   þýô