o
    >ht                     @   s  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 deZG dd deZe	eG dd dZe	eG dd dZe	eG dd dZe	eG dd dZG dd dZG dd dZee jZee jZee jZee jZee j Z!ee j"Z#ee j$Z%ee j&Z'ee j(Z)ee j*Z+ee j,Z-ee j.Z/ee j0Z1ee/e1geeeee!e#e%e'e)e+e-eg dgdZ2ee/geeee!e#e%e'e)e+e-g
dZ3e Z4dS )     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d ZdS )ILookupTablez1
    Interface for character lookup classes.
    c                 C      dS )z<
        Return whether character is in this table.
        N cr   r   /var/www/vedio/testing/chatpythonscript.ninositsolution.com/env/lib/python3.10/site-packages/twisted/words/protocols/jabber/xmpp_stringprep.pylookup       zILookupTable.lookupN)__name__
__module____qualname____doc__r   r   r   r   r   r          r   c                   @   r   )IMappingTablez2
    Interface for character mapping classes.
    c                 C   r   )z/
        Return mapping for character.
        Nr   r   r   r   r   map)   r   zIMappingTable.mapN)r   r   r   r   r   r   r   r   r   r   $   r   r   c                   @      e Zd Zdd ZdS )LookupTableFromFunctionc                 C   
   || _ d S N)r   selfin_table_functionr   r   r   __init__1      
z LookupTableFromFunction.__init__Nr   r   r   r$   r   r   r   r   r   /       r   c                   @      e Zd Zdd Zdd ZdS )LookupTablec                 C   r   r    _table)r"   tabler   r   r   r$   7   r%   zLookupTable.__init__c                 C   s
   || j v S r    r*   r"   r   r   r   r   r   :   r%   zLookupTable.lookupN)r   r   r   r$   r   r   r   r   r   r)   5       r)   c                   @   r   )MappingTableFromFunctionc                 C   r   r    )r   )r"   map_table_functionr   r   r   r$   @   r%   z!MappingTableFromFunction.__init__Nr&   r   r   r   r   r/   >   r'   r/   c                   @   r(   )EmptyMappingTablec                 C   r   r    _in_table_functionr!   r   r   r   r$   F   r%   zEmptyMappingTable.__init__c                 C   s   |  |rd S |S r    r2   r-   r   r   r   r   I   s   
zEmptyMappingTable.mapN)r   r   r   r$   r   r   r   r   r   r1   D   r.   r1   c                   @   sH   e Zd Zg dg ddfddZdd Zdd Zdd	 Zd
d Zdd ZdS )ProfileTc                 C   s"   || _ || _|| _|| _|| _d S r    )mappings	normalizeprohibitedsdo_check_unassignedsdo_check_bidi)r"   r5   r6   r7   check_unassigneds
check_bidir   r   r   r$   Q   s
   
zProfile.__init__c                 C   sJ   |  |}| jrtd|}| | | jr| | | jr#| | |S )NNFKC)r   r6   unicodedatacheck_prohibitedsr8   r:   r9   check_bidirectionals)r"   stringresultr   r   r   prepare_   s   



zProfile.preparec                 C   sP   g }|D ]}|}| j D ]}||}||kr nq|d ur"|| qd|S )N )r5   r   appendjoin)r"   r@   rA   r   result_cmappingr   r   r   r   j   s   



zProfile.mapc                 C   s4   |D ]}| j D ]}||rtdt| qqd S NzInvalid character %s)r7   r   UnicodeErrorrepr)r"   r@   r   r,   r   r   r   r>   z   s   

zProfile.check_prohibitedsc                 C   s(   |D ]}t |rtdt| qd S )NzUnassigned code point %s)
stringprepin_table_a1rI   rJ   r"   r@   r   r   r   r   r:      
   
zProfile.check_unassignedsc                 C   sn   d}d}|D ]}t |rd}t |rd}q|r|rtd|r3t |d r/t |d s5tdd S d S )NFTzViolation of BIDI Requirement 2r   zViolation of BIDI Requirement 3)rK   in_table_d1in_table_d2rI   )r"   r@   
found_LCatfound_RandALCatr   r   r   r   r?      s"   

zProfile.check_bidirectionalsN)	r   r   r   r$   rB   r   r>   r:   r?   r   r   r   r   r4   P   s    
r4   c                	   @   s`   e Zd ZdZdd eeddeddedd	ed
deddD Zdd Zdd Zdd Z	dS )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).

    c                 C   s   g | ]}t |qS r   )chr).0nr   r   r   
<listcomp>   s    zNamePrep.<listcomp>r   -   .   0   :   A   [   a   {      c                 C   s\   g }t j|}|rt|d dkrd}|d= nd}|D ]
}|| | qd|| S )NrO   r   .rC   )r   dotssplitlenrD   namepreprE   )r"   r@   rA   labelstrailing_dotlabelr   r   r   rB      s   zNamePrep.preparec                 C   s(   |D ]}|| j v rtdt| qd S rH   )r7   rI   rJ   rM   r   r   r   r>      rN   zNamePrep.check_prohibitedsc                 C   s@   t |}| | |d dkrtd|d dkrtd|S )Nr   -zInvalid leading hyphen-minusrO   zInvalid trailing hyphen-minus)r   rf   r>   rI   )r"   ri   r   r   r   rf      s   

zNamePrep.nameprepN)
r   r   r   r   r   ranger7   rB   r>   rf   r   r   r   r   rT      s    rT   )"&'/:<>@)r5   r7   )5rK   	encodingsr   	itertoolsr   r=   r   zope.interfacer   r   incrementalr   twisted.python.deprecater   r   r   r   r   r   r)   r/   r1   r4   rT   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resourcepreprf   r   r   r   r   <module>   st   H
A













