HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/lib/python3/dist-packages/twisted/words/protocols/jabber/__pycache__/jid.cpython-38.pyc
U


W[Q�@shdZddlmZmZddlmZmZmZGdd�de�Z	dd�Z
dd	�ZiZd
d�Z
Gdd
�d
e�ZdS)a$
Jabber Identifier support.

This module provides an object to represent Jabber Identifiers (JIDs) and
parse string representations into them with proper checking for illegal
characters, case folding and canonicalisation through L{stringprep<twisted.words.protocols.jabber.xmpp_stringprep>}.
�)�_PY3�unicode)�nodeprep�resourceprep�nameprepc@seZdZdZdS)�
InvalidFormatzT
    The given string could not be parsed into a valid Jabber Identifier (JID).
    N)�__name__�
__module__�__qualname__�__doc__�rr�D/usr/lib/python3/dist-packages/twisted/words/protocols/jabber/jid.pyrsrcCs�d}d}d}|�d�}|�d�}|dkrX|dkr6|}q�|d|�}||dd�pTd}n�|dkr�|d|�pnd}||dd�}nf||kr�|d|�p�d}||d|||�}||dd�p�d}n |d|�}||dd�p�d}t|||�S)a�
    Parse given JID string into its respective parts and apply stringprep.

    @param jidstring: string representation of a JID.
    @type jidstring: L{unicode}
    @return: tuple of (user, host, resource), each of type L{unicode} as
             the parsed and stringprep'd parts of the given JID. If the
             given string did not have a user or resource part, the respective
             field in the tuple will hold L{None}.
    @rtype: L{tuple}
    N�@�/���r�)�find�prep)�	jidstring�user�host�resourceZuser_sepZres_seprrr
�parses(

rcCs�|r6zt�t|��}Wq:tk
r2td��Yq:Xnd}|sHtd��n0zt�t|��}Wntk
rvtd��YnX|r�zt�t|��}Wq�tk
r�td��Yq�Xnd}|||fS)a\
    Perform stringprep on all JID fragments.

    @param user: The user part of the JID.
    @type user: L{unicode}
    @param host: The host part of the JID.
    @type host: L{unicode}
    @param resource: The resource part of the JID.
    @type resource: L{unicode}
    @return: The given parts with stringprep applied.
    @rtype: L{tuple}
    zInvalid character in usernameNzServer address required.zInvalid character in hostnamezInvalid character in resource)rZpreparer�UnicodeErrorrrr)rrrrrr
rDs&
rcCs(|tkrt|St|�}|t|<|SdS)z2
    Return interned JID.

    @rtype: L{JID}
    N)�__internJIDs�JID)r�jrrr
�	internJIDns
rc@sbeZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZerVeZ
dd�ZdS)rz�
    Represents a stringprep'd Jabber ID.

    JID objects are hashable so they can be used in sets and as keys in
    dictionaries.
    NcCsH|s|std��|r$t|�\}}}nt|�\}}}||_||_||_dS)Nz?You must provide a value for either 'str' or 'tuple' arguments.)�RuntimeErrorrrrrr)�self�str�tuplerr�resrrr
�__init__�szJID.__init__cCs |jrd|j|jfS|jSdS)z�
        Extract the bare JID as a unicode string.

        A bare JID does not have a resource part, so this returns either
        C{user@host} or just C{host}.

        @rtype: L{unicode}
        �%s@%sN)rr�rrrr
�userhost�s	zJID.userhostcCs|jrt|���S|SdS)a�
        Extract the bare JID.

        A bare JID does not have a resource part, so this returns a
        L{JID} object representing either C{user@host} or just C{host}.

        If the object this method is called upon doesn't have a resource
        set, it will return itself. Otherwise, the bare JID object will
        be created, interned using L{internJID}.

        @rtype: L{JID}
        N)rrr&r%rrr
�userhostJID�s
zJID.userhostJIDcCsR|jr2|jr d|j|j|jfSd|j|jfSn|jrHd|j|jfS|jSdS)z[
        Return the string representation of this JID.

        @rtype: L{unicode}
        z%s@%s/%sr$z%s/%sN)rrrr%rrr
�full�szJID.fullcCs6t|t�r.|j|jko,|j|jko,|j|jkStSdS)z�
        Equality comparison.

        L{JID}s compare equal if their user, host and resource parts all
        compare equal.  When comparing against instances of other types, it
        uses the default comparison.
        N)�
isinstancerrrr�NotImplemented)r�otherrrr
�__eq__�s

�
�z
JID.__eq__cCs |�|�}|tkr|S|SdS)z�
        Inequality comparison.

        This negates L{__eq__} for comparison with JIDs and uses the default
        comparison for other types.
        N)r,r*)rr+�resultrrr
�__ne__�s
z
JID.__ne__cCst|j|j|jf�S)a
        Calculate hash.

        L{JID}s with identical constituent user, host and resource parts have
        equal hash values.  In combination with the comparison defined on JIDs,
        this allows for using L{JID}s in sets and as dictionary keys.
        )�hashrrrr%rrr
�__hash__�szJID.__hash__cCs|��S)z�
        Get unicode representation.

        Return the string representation of this JID as a unicode string.
        @see: L{full}
        �r(r%rrr
�__unicode__�szJID.__unicode__cCsd|��S)z�
        Get object representation.

        Returns a string that would create a new JID object that compares equal
        to this one.
        zJID(%r)r1r%rrr
�__repr__�szJID.__repr__)NN)rr	r
rr#r&r'r(r,r.r0r2r�__str__r3rrrr
r|s



rN)rZtwisted.python.compatrrZ.twisted.words.protocols.jabber.xmpp_stringpreprrr�	Exceptionrrrrr�objectrrrrr
�<module>s.(