3
OÉ6b³  ã               @   s€   d Z ddlmZ yddlZW n  ek
r<   dZdd„ ZY n@X 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„ZdS )
z&An implementation of RFC4013 SASLprep.é    )Ú	text_typeNFc             C   s   t | tƒrtdƒ‚| S )zSASLprep dummyzVThe stringprep module is not available. Usernames and passwords must be ASCII strings.)Ú
isinstanceÚ
_text_typeÚ	TypeError)Údata© r   úO/var/www/html/sandeepIITI/myenv/lib/python3.6/site-packages/pymongo/saslprep.pyÚsaslprep   s    
r	   Tc                sÆ   t | tƒs| S |r ttjf }nt}tj‰tj‰dj‡‡fdd„| D ƒƒ} tj	j
d| ƒ} tj}|| d ƒrŒ|| d ƒs~tdƒ‚|tjf }n
||f }x*| D ]"‰ t‡ fdd	„|D ƒƒrœtd
ƒ‚qœW | S )aŒ  An implementation of RFC4013 SASLprep.

        :Parameters:
          - `data`: The string to SASLprep. Unicode strings
            (python 2.x unicode, 3.x str) are supported. Byte strings
            (python 2.x str, 3.x bytes) are ignored.
          - `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).

        :Returns:
        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>O   s   zsaslprep.<locals>.<listcomp>ÚNFKCr   é   z$SASLprep: failed bidirectional checkc             3   s   | ]}|ˆ ƒV  qd S )Nr   )r   Zin_table)Úcharr   r   ú	<genexpr>h   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   Zprohibit_unassigned_code_pointsZ
prohibitedr   r   )r   r   r   r   r	   0   s,    




)T)Ú__doc__Zbson.py3compatr   r   r   ÚImportErrorZ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$   