o Sb @sdZddlmZmZzddlZWney*dZd dedeedefd d Z YdSwdZddl Z ej ej ej ejejejejejejf Zd dedeedefd d Z dS) z&An implementation of RFC4013 SASLprep.)AnyOptionalNFTdataprohibit_unassigned_code_pointsreturncCst|tr td|S)zSASLprep dummyz[The stringprep module is not available. Usernames and passwords must be instances of bytes.) isinstancestr TypeError)rrr 7/tmp/pip-target-onvjaxws/lib/python/pymongo/saslprep.pysaslpreps r cst|ts|S|rttjf}nt}tjtjdfdd|D}tj d|}tj }||drF||ds?t d|tj f}n||f}|D]tfdd |Dr^t d qM|S) arAn implementation of RFC4013 SASLprep. :Parameters: - `data`: The string to SASLprep. Unicode strings (:class:`str`) are supported. Byte strings (:class:`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`. cs$g|]}|s|rdn|qS) r ).0elt) in_table_b1 in_table_c12r r Us$zsaslprep..NFKCrz$SASLprep: failed bidirectional checkc3s|]}|VqdS)Nr )rZin_table)charr r nszsaslprep..z+SASLprep: failed prohibited character check)rr _PROHIBITED stringprep in_table_a1rrjoin unicodedata ucd_3_2_0 normalize in_table_d1 ValueError in_table_d2any)rr prohibitedrr )rrrr r 4s,    )T)__doc__typingrrr ImportErrorZHAVE_STRINGPREPboolrr rrin_table_c21_c22 in_table_c3 in_table_c4 in_table_c5 in_table_c6 in_table_c7 in_table_c8 in_table_c9rr r r r s*  "