Ϫf dZddlmZddlmZmZmZddl m Z dje ddDcgc]}e|jdc}Zd ZGd d Zy cc}w) z( L{URLPath}, a representation of a URL. )cast)quoteunquote urlunsplit)URLasciic2d|ztfdfdS)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. _ct|SN)getattr)self privateNames 8/usr/lib/python3/dist-packages/twisted/python/urlpath.pyz"_rereconstituter..sWT;/rct|t|tr|n|jdxs|j S)Ncharmap)setattr isinstancebytesencode _reconstitute)rvaluers rrz"_rereconstituter..s@ #E51u||I7N  $ !!# r)property)namers @r_rereconstituterrs#*K /   rceZdZdZ ddZdZedZedZedZ edZ edZ e d Z dd Ze d Ze d Ze d ZdZddZddZddZddZdZdefdZdefdZy)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} cz|xsd|_||_|xsd|_||_||_|j y)Nshttp/)_scheme_netloc_path_query _fragmentr)rschemenetlocpathqueryfragments r__init__zURLPath.__init__=s<(  \T  ! rc tt|j|j|j|j |j ft}tj|jdjd|_ y)zM Reconstitute this L{URLPath} from all its given attributes. safer N) urlquoterr$r%r&r'r( _allascii_URLfromTextrdecode_url)rurltexts rrzURLPath._reconstituteGsc t||TZZdnnU    MM'.."9"@"@"IJ rr)r*r+r,r-c|j|}|j|jxsdg|_|jjj d|_|jjj d|_t|jjdjjj d|_ t|jjjjj ddd|_|jjj 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+r T)r+rooted)r,r N)__new__replacer+r7r)rr$ authorityr%r4asURIasTextr&r,r'r-r()cls urlInstancers r_fromURLzURLPath._fromURLYs{{3''[-=-=-E"'F yy''..w7 yy**,33G< diinnT 2 8 8 : A A C J J7 S $))//288:AACJJ7SUVUWX ++227; rc|jj}d}|r|fd}dg|Dcgc] }|| c}zScc}w)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$|jdS)Nr )rxs rrz"URLPath.pathList..{s188G,rc$|t|Sr) urlunquote)rGms rrz"URLPath.pathList..}s:a=)9rr)r7r+)rrcopysegmentsmappersegments rpathListzURLPath.pathListos@99>>, !'9Fux@Gw@@@@s;ct|ts td|jt j |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)rstr ValueErrorrCr4r5)klassurls r fromStringzURLPath.fromStrings2#s#23 3~~dmmC011rc|t|ts tdt|t}|j |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 bytesr0)rrrRr2r3rU)rSrTquoteds r fromByteszURLPath.fromBytess7#u%23 3#I.''rc@|j|jS)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} )rX prePathURL)rSrequests r fromRequestzURLPath.fromRequestsw11344rc|j|jd|r|jjSdS)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-r,)rCr=r7r,)rnewURL keepQuerys r_modz URLPath._modsA}} NNBdiiooN S  PRN S  rcv|j|jj|jd|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 )rar7siblingr6rr+r`s rrczURLPath.siblings-yy**4;;w+?@)LLrcv|j|jj|jd|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 )rar7childr6rds rrfz URLPath.childs+yyW)=> JJrcX|j|jjd|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..rar7clickrr`s rparentzURLPath.parents"yy. ::rcX|j|jjd|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} .rhrjs rherez URLPath.heres"yy-y99rct|j|jj|jdS)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 )rCr7rir6)rsts rriz URLPath.clicks)}}TYY__RYYw-?@AArreturncntt|jjj S)z= The L{str} of a L{URLPath} is its URL text. )rrQr7r?r@rs r__str__zURLPath.__str__s%C*11344rcdj|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,r-rss r__repr__zURLPath.__repr__ s; Y__ KK KK II JJ MM   rN)rs localhostrrr)FT)F)__name__ __module__ __qualname____doc__r.rrr)r*r+r,r- classmethodrCrOrUrXr\rarcrfrkrnrirQrtrwr^rrr!r!)s(NQ Kh 'F h 'F F #D W %E +H*A" 2 2((" 5 5 &M K ; : B55  #  rr!N)r{typingr urllib.parserr2rrIr hyperlinkrr4joinrangechrrr3rr!rFs0rrs[ MM! HHeAsmDc!fmmG,D E 0m m 7EsA"