
    Vht                        d dl Z d dlmZ d dlmZ d dlmZ d dlmZm	Z	 d dl
mZ d dlmZ dZ e ed	d
dd       ded        G d de      Z G d de      Z e	e       G d d             Z e	e       G d d             Z e	e       G d d             Z e	e       G d d             Z G d d      Z G d d      Z ee j0                        Z ee j4                        Z ee j8                        Z ee j<                        Z ee j@                        Z! ee jD                        Z# ee jH                        Z% ee jL                        Z' ee jP                        Z) ee jT                        Z+ ee jX                        Z- ee j\                        Z/ ee j`                        Z1 ee/e1geeeee!e#e%e'e)e+e- eg d      g      Z2 ee/geeee!e#e%e'e)e+e-g
      Z3 e       Z4y)     N)idna)chain)	ucd_3_2_0)	Interfaceimplementer)Version)deprecatedModuleAttributeFTwisted      zcrippled is always Falsecrippledc                       e Zd ZdZd Zy)ILookupTablez1
    Interface for character lookup classes.
    c                      y)z<
        Return whether character is in this table.
        N cs    ^/home/dcms/DCMS/lib/python3.12/site-packages/twisted/words/protocols/jabber/xmpp_stringprep.pylookupzILookupTable.lookup           N)__name__
__module____qualname____doc__r   r   r   r   r   r          r   r   c                       e Zd ZdZd Zy)IMappingTablez2
    Interface for character mapping classes.
    c                      y)z/
        Return mapping for character.
        Nr   r   s    r   mapzIMappingTable.map)   r   r   N)r   r   r   r   r    r   r   r   r   r   $   r   r   r   c                       e Zd Zd Zy)LookupTableFromFunctionc                     || _         y N)r   selfin_table_functions     r   __init__z LookupTableFromFunction.__init__1   s	    'r   Nr   r   r   r(   r   r   r   r"   r"   /   s    (r   r"   c                       e Zd Zd Zd Zy)LookupTablec                     || _         y r$   _table)r&   tables     r   r(   zLookupTable.__init__7   s	    r   c                     || j                   v S r$   r-   r&   r   s     r   r   zLookupTable.lookup:   s    DKKr   N)r   r   r   r(   r   r   r   r   r+   r+   5   s     r   r+   c                       e Zd Zd Zy)MappingTableFromFunctionc                     || _         y r$   )r    )r&   map_table_functions     r   r(   z!MappingTableFromFunction.__init__@   s	    %r   Nr)   r   r   r   r3   r3   >   s    &r   r3   c                       e Zd Zd Zd Zy)EmptyMappingTablec                     || _         y r$   _in_table_functionr%   s     r   r(   zEmptyMappingTable.__init__F   s
    "3r   c                 *    | j                  |      ry |S r$   r9   r1   s     r   r    zEmptyMappingTable.mapI   s    ""1%Hr   N)r   r   r   r(   r    r   r   r   r7   r7   D   s    4r   r7   c                   <    e Zd Zg dg ddfdZd Zd Zd Zd Zd Zy)	ProfileTc                 J    || _         || _        || _        || _        || _        y r$   )mappings	normalizeprohibitedsdo_check_unassignedsdo_check_bidi)r&   r?   r@   rA   check_unassigneds
check_bidis         r   r(   zProfile.__init__Q   s*     !"&$5!'r   c                    | j                  |      }| j                  rt        j                  d|      }| j                  |       | j                  r| j                  |       | j                  r| j                  |       |S )NNFKC)r    r@   unicodedatacheck_prohibitedsrB   rD   rC   check_bidirectionals)r&   stringresults      r   preparezProfile.prepare_   sj    &!>> **66:Fv&$$""6*%%f-r   c                     g }|D ]A  }|}| j                   D ]  }|j                  |      }||k7  s n |1|j                  |       C dj                  |      S )N )r?   r    appendjoin)r&   rK   rL   r   result_cmappings         r   r    zProfile.mapj   si     		(AH== ";;q>q=
 #h'		( wwvr   c                     |D ];  }| j                   D ]*  }|j                  |      st        dt        |      z         = y NzInvalid character %s)rA   r   UnicodeErrorrepr)r&   rK   r   r/   s       r   rI   zProfile.check_prohibitedsz   sJ     	IA)) I<<?&'=Q'GHHI	Ir   c                 j    |D ].  }t        j                  |      st        dt        |      z         y )NzUnassigned code point %s)
stringprepin_table_a1rV   rW   r&   rK   r   s      r   rD   zProfile.check_unassigneds   s6     	IA%%a("#=Q#GHH	Ir   c                    d}d}|D ]1  }t        j                  |      rd}t        j                  |      s0d}3 |r|rt        d      |r<t        j                  |d         rt        j                  |d         st        d      y y )NFTzViolation of BIDI Requirement 2r   zViolation of BIDI Requirement 3)rY   in_table_d1in_table_d2rV   )r&   rK   
found_LCatfound_RandALCatr   s        r   rJ   zProfile.check_bidirectionals   s    
 	"A%%a("&%%a(!
		" /@AA""6!9-*2H2HPR2T@AA 3U r   N)	r   r   r   r(   rM   r    rI   rD   rJ   r   r   r   r=   r=   P   s4     (	 II
Br   r=   c            
           e Zd ZdZ e edd       edd       edd       edd	       ed
d            D  cg c]  }t        |       c}}} Zd Zd Z	d Z
yc c}}} w )NamePrepa  Implements preparation of internationalized domain names.

    This class implements preparing internationalized domain names using the
    rules defined in RFC 3491, section 4 (Conversion operations).

    We do not perform step 4 since we deal with unicode representations of
    domain names and do not convert from or to ASCII representations using
    punycode encoding. When such a conversion is needed, the C{idna} standard
    library provides the C{ToUnicode()} and C{ToASCII()} functions. Note that
    C{idna} itself assumes UseSTD3ASCIIRules to be false.

    The following steps are performed by C{prepare()}:

      - Split the domain name in labels at the dots (RFC 3490, 3.1)
      - Apply nameprep proper on each label (RFC 3491)
      - Enforce the restrictions on ASCII characters in host names by
        assuming STD3ASCIIRules to be true. (STD 3)
      - Rejoin the labels using the label separator U+002E (full stop).

    r   -   .   0   :   A   [   a   {      c                     g }t         j                  j                  |      }|rt        |d         dk(  rd}|d= nd}|D ]"  }|j	                  | j                  |             $ dj                  |      |z   S )Nr]   r   .rO   )r   dotssplitlenrP   namepreprQ   )r&   rK   rL   labelstrailing_dotlabels         r   rM   zNamePrep.prepare   sv    (c&*o*Lr
L 	0EMM$--./	0 xx,..r   c                 \    |D ]'  }|| j                   v st        dt        |      z         y rU   )rA   rV   rW   r[   s      r   rI   zNamePrep.check_prohibiteds   s6     	EAD$$$"#9DG#CDD	Er   c                     t        j                  |      }| j                  |       |d   dk(  rt        d      |d   dk(  rt        d      |S )Nr   -zInvalid leading hyphen-minusr]   zInvalid trailing hyphen-minus)r   rr   rI   rV   )r&   ru   s     r   rr   zNamePrep.nameprep   sR    e$u%8s?=>>9>??r   N)r   r   r   r   r   rangechrrA   rM   rI   rr   ).0nrz   s   000r   rc   rc      sw    0 $!$!$!$!$!
	 	 	A	K/ E
A	s   Arc   )"&'/:<>@)r?   rA   )5rY   	encodingsr   	itertoolsr   rH   r   zope.interfacer   r   incrementalr   twisted.python.deprecater	   r   r   r   r   r"   r+   r3   r7   r=   rc   in_table_c11C_11in_table_c12C_12in_table_c21C_21in_table_c22C_22in_table_c3C_3in_table_c4C_4in_table_c5C_5in_table_c6C_6in_table_c7C_7in_table_c8C_8in_table_c9C_9in_table_b1B_1map_table_b2B_2nodeprepresourcepreprr   r   r   r   <module>r      s3      1 1  > Ir1a "<h

9 I  \( ( (
 \      ]& & &
 ]  EB EBP> >B z667z667z667z667j445j445j445j445j445j445j445
../z6673Z<=$  tT3S#sCE	 :r   