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: //proc/thread-self/root/lib/python3/dist-packages/twisted/python/__pycache__/urlpath.cpython-38.pyc
U


W[|#�@srdZddlmZmZddlmZmZmZm	Z	m
Z
ddlmZ
d�dd�edd	�D��Zd
d�ZGdd
�d
e�ZdS)z(
L{URLPath}, a representation of a URL.
�)�division�absolute_import)�nativeString�unicode�urllib_parse�
urlunquote�urlquote)�URL�cCsg|]}t|��d��qS)�ascii)�chr�encode)�.0�x�r�8/usr/lib/python3/dist-packages/twisted/python/urlpath.py�
<listcomp>sr��cs&td�|�t�fdd��fdd��S)a
    Attriute declaration to preserve mutability on L{URLPath}.

    @param name: a public attribute name
    @type name: native L{str}

    @return: a descriptor which retrieves the private version of the attribute
        on get and calls rerealize on set.
    �_cs
t|��S�N)�getattr��self�ZprivateNamerr�<lambda>r
z"_rereconstituter.<locals>.<lambda>cs(t|�t|t�r|n|�d��p&|��S)N�charmap)�setattr�
isinstance�bytesr
�
_reconstitute)r�valuerrrr s�)r�property)�namerrr�_rereconstituters



�r$c@s�eZdZdZd*dd�Zdd�Zed�Zed	�Zed
�Z	ed�Z
ed�Zed
d��Z
d+dd�Zedd��Zedd��Zedd��Zdd�Zd,dd�Zd-dd�Zd.dd �Zd/d!d"�Zd#d$�Zd%d&�Zd'd(�Zd)S)0�URLPatha�
    A representation of a URL.

    @ivar scheme: The scheme of the URL (e.g. 'http').
    @type scheme: L{bytes}

    @ivar netloc: The network location ("host").
    @type netloc: L{bytes}

    @ivar path: The path on the network location.
    @type path: L{bytes}

    @ivar query: The query argument (the portion after ?  in the URL).
    @type query: L{bytes}

    @ivar fragment: The page fragment (the portion after # in the URL).
    @type fragment: L{bytes}
    r
�	localhostcCs2|pd|_||_|pd|_||_||_|��dS)Nshttp�/)�_scheme�_netloc�_path�_query�	_fragmentr )r�scheme�netloc�path�query�fragmentrrr�__init__;s

zURLPath.__init__cCsBtt�|j|j|j|j|jf�td�}t	�
|�d��d��|_
dS)zM
        Reconstitute this L{URLPath} from all its given attributes.
        �ZsaferN)r�urlparseZ
urlunsplitr(r)r*r+r,�	_allascii�_URL�fromTextr
�decode�_url)rZurltextrrrr Es��zURLPath._reconstituter-r.r/r0r1cCs�|�|�}|j|jpdgd�|_|jj�d�|_|j���d�|_t	|jjdd��
����d�|_t	|jj
d��
����d�dd�|_|jj�d�|_|S)	a
        Reconstruct all the public instance variables of this L{URLPath} from
        its underlying L{_URL}.

        @param urlInstance: the object to base this L{URLPath} on.
        @type urlInstance: L{_URL}

        @return: a new L{URLPath}
        �)r/rT)r/Zrooted)r0rN)�__new__�replacer/r9r-r
r(Z	authorityr)r6�asURI�asTextr*r0r+r1r,)�clsZurlInstancerrrr�_fromURLWs 
����
zURLPath._fromURLFTcs8|jj}dd��|r �fdd��dg�fdd�|D�S)a
        Split this URL's path into its components.

        @param unquote: whether to remove %-encoding from the returned strings.

        @param copy: (ignored, do not use)

        @return: The components of C{self.path}
        @rtype: L{list} of L{bytes}
        cSs
|�d�S)Nr)r
)rrrrr{r
z"URLPath.pathList.<locals>.<lambda>cSs|t|��Sr)r)r�mrrrr}r
r
csg|]}�|��qSrr)rZsegment�Zmapperrrr~sz$URLPath.pathList.<locals>.<listcomp>)r9r/)rZunquote�copyZsegmentsrrBr�pathListos
zURLPath.pathListcCs:t|ttf�std��t|t�r*|�|�S|�t�|��S)z�
        Make a L{URLPath} from a L{str} or L{unicode}.

        @param url: A L{str} representation of a URL.
        @type url: L{str} or L{unicode}.

        @return: a new L{URLPath} derived from the given string.
        @rtype: L{URLPath}
        z'url' must be a str or unicode)	r�strr�
ValueErrorr�	fromBytesr@r6r7)�klass�urlrrr�
fromString�s


zURLPath.fromStringcCs<t|t�std��t|td�}t|t�r2|�d�}|�|�S)z�
        Make a L{URLPath} from a L{bytes}.

        @param url: A L{bytes} representation of a URL.
        @type url: L{bytes}

        @return: a new L{URLPath} derived from the given L{bytes}.
        @rtype: L{URLPath}

        @since: 15.4
        z'url' must be bytesr3r)rrrFrr5r8rJ)rHrIZquotedrrrrG�s


zURLPath.fromBytescCs|�|���S)a
        Make a L{URLPath} from a L{twisted.web.http.Request}.

        @param request: A L{twisted.web.http.Request} to make the L{URLPath}
            from.

        @return: a new L{URLPath} derived from the given request.
        @rtype: L{URLPath}
        )rGZ
prePathURL)rHZrequestrrr�fromRequest�szURLPath.fromRequestcCs |�|jd|r|jjndd��S)a�
        Return a modified copy of C{self} using C{newURL}, keeping the query
        string if C{keepQuery} is C{True}.

        @param newURL: a L{URL} to derive a new L{URLPath} from
        @type newURL: L{URL}

        @param keepQuery: if C{True}, preserve the query parameters from
            C{self} on the new L{URLPath}; if C{False}, give the new L{URLPath}
            no query parameters.
        @type keepQuery: L{bool}

        @return: a new L{URLPath}
        r:r)r1r0)r@r<r9r0)rZnewURL�	keepQueryrrr�_mod�s�zURLPath._modcCs|�|j�|�d��|�S)a�
        Get the sibling of the current L{URLPath}.  A sibling is a file which
        is in the same directory as the current file.

        @param path: The path of the sibling.
        @type path: L{bytes}

        @param keepQuery: Whether to keep the query parameters on the returned
            L{URLPath}.
        @type: keepQuery: L{bool}

        @return: a new L{URLPath}
        r)rMr9�siblingr8�rr/rLrrrrN�szURLPath.siblingcCs|�|j�|�d��|�S)a*
        Get the child of this L{URLPath}.

        @param path: The path of the child.
        @type path: L{bytes}

        @param keepQuery: Whether to keep the query parameters on the returned
            L{URLPath}.
        @type: keepQuery: L{bool}

        @return: a new L{URLPath}
        r)rMr9�childr8rOrrrrP�s
z
URLPath.childcCs|�|j�d�|�S)z�
        Get the parent directory of this L{URLPath}.

        @param keepQuery: Whether to keep the query parameters on the returned
            L{URLPath}.
        @type: keepQuery: L{bool}

        @return: a new L{URLPath}
        z..�rMr9�click�rrLrrr�parent�s
zURLPath.parentcCs|�|j�d�|�S)z�
        Get the current directory of this L{URLPath}.

        @param keepQuery: Whether to keep the query parameters on the returned
            L{URLPath}.
        @type: keepQuery: L{bool}

        @return: a new L{URLPath}
        �.rQrSrrr�here�s
zURLPath.herecCs|�|j�|�d���S)a7
        Return a path which is the URL where a browser would presumably take
        you if you clicked on a link with an HREF as given.

        @param st: A relative URL, to be interpreted relative to C{self} as the
            base URL.
        @type st: L{bytes}

        @return: a new L{URLPath}
        r)r@r9rRr8)r�strrrrR
sz
URLPath.clickcCst|j�����S)z=
        The L{str} of a L{URLPath} is its URL text.
        )rr9r=r>rrrr�__str__szURLPath.__str__cCsd|j|j|j|j|jfS)z{
        The L{repr} of a L{URLPath} is an eval-able expression which will
        construct a similar L{URLPath}.
        z=URLPath(scheme=%r, netloc=%r, path=%r, query=%r, fragment=%r))r-r.r/r0r1rrrr�__repr__s
��zURLPath.__repr__N)r
r&r
r
r
)FT)F)F)F)F)�__name__�
__module__�__qualname__�__doc__r2r r$r-r.r/r0r1�classmethodr@rDrJrGrKrMrNrPrTrVrRrXrYrrrrr%(s8�












r%N)r]Z
__future__rrZtwisted.python.compatrrrr4rrZ	hyperlinkr	r6�join�ranger5r$�objectr%rrrr�<module>s