CasperSecurity

Current Path : /lib/python3/dist-packages/twisted/python/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/twisted/python/__pycache__/urlpath.cpython-310.pyc

o

�b� �@sddZddlmZddlmZmZmZddl	m
Zd�dd�e
dd	�D��Zd
d�ZGdd
�d
�ZdS)z(
L{URLPath}, a representation of a URL.
�)�cast)�quote�unquote�
urlunsplit)�URL�cCsg|]	}t|��d��qS)�ascii)�chr�encode)�.0�x�r
�8/usr/lib/python3/dist-packages/twisted/python/urlpath.py�
<listcomp>sr��cs"d|�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��privateNamer
r�<lambda>�
z"_rereconstituter.<locals>.<lambda>cs(t|�t|t�r
|n|�d��p|��S)N�charmap)�setattr�
isinstance�bytesr
�
_reconstitute)r�valuerr
rrs�)�property)�namer
rr�_rereconstituters



�r#c@s�eZdZdZ	d+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%efd&d'�Zd%efd(d)�Zd*S).�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�fragmentr
r
r�__init__=s

zURLPath.__init__cCs@tt|j|j|j|j|jf�td�}t�	|�
d��d��|_dS)zM
        Reconstitute this L{URLPath} from all its given attributes.
        ��saferN)
�urlquoterr'r(r)r*r+�	_allascii�_URL�fromTextr
�decode�_url)r�urltextr
r
rrGs��zURLPath._reconstituter,r-r.r/r0cCs�|�|�}|j|jpdgd�|_|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.�rooted)r/rN)�__new__�replacer.r9r,r
r'�	authorityr(r6�asURI�asTextr)r/r*r0r+)�cls�urlInstancerr
r
r�_fromURLYs
�&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
)rr
r
rr{rz"URLPath.pathList.<locals>.<lambda>cSs|t|��Sr)�
urlunquote)r�mr
r
rr}srcsg|]}�|��qSr
r
)r�segment��mapperr
rr~sz$URLPath.pathList.<locals>.<listcomp>)r9r.)rr�copy�segmentsr
rHr�pathListos
zURLPath.pathListcCs"t|t�s	td��|�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)r�str�
ValueErrorrDr6r7)�klass�urlr
r
r�
fromString�s
zURLPath.fromStringcCs(t|t�s	td��t|td�}|�|�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 bytesr2)rrrNr4r5rQ)rOrP�quotedr
r
r�	fromBytes�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}
        )rS�
prePathURL)rO�requestr
r
r�fromRequest�szURLPath.fromRequestcCs&|�|jd|r|jjd��Sdd��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
)r0r/)rDr>r9r/)r�newURL�	keepQueryr
r
r�_mod�s
��zURLPath._modcC�|�|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)rYr9�siblingr8�rr.rXr
r
rr[�szURLPath.siblingcCrZ)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)rYr9�childr8r\r
r
rr]�s
z
URLPath.childcC�|�|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..�rYr9�click�rrXr
r
r�parent��
zURLPath.parentcCr^)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}
        �.r_rar
r
r�here�rcz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)rDr9r`r8)r�str
r
rr`�sz
URLPath.click�returncCstt|j�����S)z=
        The L{str} of a L{URLPath} is its URL text.
        )rrMr9r@rArr
r
r�__str__szURLPath.__str__cCsd�|j|j|j|j|j�S)z{
        The L{repr} of a L{URLPath} is an eval-able expression which will
        construct a similar L{URLPath}.
        zGURLPath(scheme={!r}, netloc={!r}, path={!r}, query={!r}, fragment={!r}))�formatr,r-r.r/r0rr
r
r�__repr__s�zURLPath.__repr__N)rr%rrr)FT)F)�__name__�
__module__�__qualname__�__doc__r1rr#r,r-r.r/r0�classmethodrDrLrQrSrVrYr[r]rbrer`rMrhrjr
r
r
rr$)s6
�










r$N)rn�typingr�urllib.parserr4rrEr�	hyperlinkrr6�join�ranger5r#r$r
r
r
r�<module>s
Hacker Blog, Shell İndir, Sql İnjection, XSS Attacks, LFI Attacks, Social Hacking, Exploit Bot, Proxy Tools, Web Shell, PHP Shell, Alfa Shell İndir, Hacking Training Set, DDoS Script, Denial Of Service, Botnet, RFI Attacks, Encryption
Telegram @BIBIL_0DAY