/usr/lib/python3/dist-packages/twisted/python/__pycache__
Edit: /usr/lib/python3/dist-packages/twisted/python/__pycache__/urlpath.cpython-310.pyc (9282B)
o
b @ sd d Z ddlmZ ddlmZmZmZ ddl m
Z ddd e
dd D Zd
d ZG dd
d
ZdS )z(
L{URLPath}, a representation of a URL.
)cast)quoteunquote
urlunsplit)URL c C s g | ] }t |d qS )ascii)chrencode).0x r
8/usr/lib/python3/dist-packages/twisted/python/urlpath.py
s r c s" d| t fdd fddS )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.
_c s
t | S N)getattrselfprivateNamer
r
z"_rereconstituter..c s( t | t|tr
|n|dp| S )Ncharmap)setattr
isinstancebytesr
_reconstitute)r valuer r
r r s )property)namer
r r _rereconstituter s
r# c @ s e Zd ZdZ d+ddZdd ZedZed Zed
Z edZ
edZed
d Z
d,ddZedd Zedd Zedd Zdd Zd-ddZd-ddZd-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 localhostc C s2 |pd| _ || _|pd| _|| _|| _| d S )Ns http /)_scheme_netloc_path_query _fragmentr )r schemenetlocpathqueryfragmentr
r
r __init__= s
zURLPath.__init__c C s@ t t| j| j| j| j| jftd}t |
dd| _dS )zM
Reconstitute this L{URLPath} from all its given attributes.
safer N)
urlquoter r' r( r) r* r+ _allascii_URLfromTextr
decode_url)r urltextr
r
r r G s zURLPath._reconstituter, r- r. r/ r0 c C s | | }|j|jpdgd|_|jjd|_|j d|_t |jjdd
d|_t |jj
d
ddd |_|jjd|_|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. r T)r. rooted)r/ r N)__new__replacer. r9 r, r
r' authorityr( r6 asURIasTextr) r/ r* r0 r+ )clsurlInstancer r
r
r _fromURLY s
&zURLPath._fromURLFTc s8 | j j}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}
c S s
| dS )Nr )r
)r r
r
r r { r z"URLPath.pathList..c S s |t | S r )
urlunquote)r mr
r
r r } s r c s g | ]} |qS r
r
)r segmentmapperr
r r ~ s z$URLPath.pathList..)r9 r. )r r copysegmentsr
rH r pathListo s
zURLPath.pathListc C s" t |ts 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
ValueErrorrD r6 r7 )klassurlr
r
r
fromString s
zURLPath.fromStringc C s( t |ts tdt|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 )r r rN r4 r5 rQ )rO rP quotedr
r
r fromBytes s
zURLPath.fromBytesc C s | | 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 s zURLPath.fromRequestc C s&