^K $dZeZgdZddlZ eidddddd d d d d dddddddddddddddddddd d!d"d#d$id%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d2d4d5d6d7d8d9d:d;dd=d?d@dAd@dBdCd@ddDdEdDdDdFdDdGZdHZ dIZ dJZ dKZ dLe dMe dNe dOZ dPZdQZdRZdSezZdTZdUe edVedVedVedW ZdXe edVedVedVedW ZdYZdZZe d[ed\ed]ed^Zed\ed]ed^Zej2eej4Zej2eej4Zd_Zd`ZdaZGdbdce Z!GdddeZ"dfdgdhizZ#ej2e#ej4ejHzZ%ej2diZ&djZ'y#e$reZY~wxYw)kz/Functions for working with generic syntax URIs.)URIInvalidURIErrorfind_uris_in_textpossible_uri_remergeremove_dot_segmentsNacap674dav80dict2628dns53ftp21go1096gopher70h3231720httphttps443imap143ipp631z iris.beep702ldap389mtqp1038mupdate3905nfs2049nntp119pop110rtsp554sip5060sips5061snmp161z soap.beep605z soap.beepstelnet23tftp69tip3372vemmi575z xmlrpc.beep602z xmlrpc.beepszz39.50r210zz39.50sprospero15252266673690)waisbzr+httpbzr+sshircsftpsshsvnsvn+sshz(?P[a-z][-a-z0-9+.]*)z9(?P(?:[-a-z0-9._~!$&\'()*+,;=:]|%[0-9a-f]{2})*)zs(?P[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}|(?:[-a-z0-9._~!$&\'()*+,;=]|%[0-9a-f]{2})*|\[[0-9a-z:.]+\])z(?P[0-9]*)z(?P(?:z@)?z(?::z)?)z2(?:/(?:[-a-z0-9._~!$&\'()*+,;=:@]|%[0-9a-f]{2})*)*z](?:[-a-z0-9._~!$&\'()*+,;=@]|%[0-9a-f]{2})+(?:/(?:[-a-z0-9._~!$&\'()*+,;=:@]|%[0-9a-f]{2})*)*z^(?:[-a-z0-9._~!$&\'()*+,;=:@]|%[0-9a-f]{2})+(?:/(?:[-a-z0-9._~!$&\'()*+,;=:@]|%[0-9a-f]{2})*)*z/(?:%s)?z(?P//|)z(?P//z=(?P(?:[-a-z0-9._~!$&\'()*+,;=:@/?\[\]]|%[0-9a-f]{2})*)z<(?P(?:[-a-z0-9._~!$&\'()*+,;=:@/?]|%[0-9a-f]{2})*):z(?:\?z)?(?:#z)?$cR|r |dk(rd|zS|jd}|d|dz|zS)a/Merge two URI path components into a single path component. Follows rules specified in Section 5.2.3 of RFC 3986. The algorithm in the RFC treats the empty basepath edge case differently for URIs with and without an authority section, which is why the third argument is necessary. rM/N)rfind)basepathrelpath has_authorityslashs //usr/lib/python3/dist-packages/lazr/uri/_uri.pyrrs;RW} NN3 E HU1W  ''cg}|r|jdr|dd}n|jdr|dd}n|jds|dk(r d|ddz}n|jd s|d k(rd|d dz}t|d kDri|d =ne|dvrd}n^|jdr|jdd}n|jd}|d kr t|}|j|d|||d}|rdj |S)zqRemove '.' and '..' segments from a URI path. Follows the rules specified in Section 5.2.4 of RFC 3986. z../Nz./z/./z/.rRz/../z/..r).z..rMrS) startswithlenfindappendjoin)pathoutputrXs rYrrs F  ??5 !8D __T "8D __U #tt|ab>D __V $ ab>D6{Q2J [ Ds# #q) #qyD  MM$v, 'd||ddfz||<Ldj |S#t$rYiwxYw) zReturn a version of 's' where no unreserved characters are encoded. Unreserved characters are defined in Section 2.3 of RFC 3986. Percent encoded sequences are normalised to upper case. %zBABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~rNr]z%%%02X%srM)split enumerateint ValueErrorchrre)stringresult unreservedindexitemchs rYnormalise_unreservedrvs\\# F#J!( 8 t A:  T"1Xr"B r7j Gd12h.F5M&"d12h7F5M 8 776?    sA== B B ceZdZdZy)rz Invalid URIN)__name__ __module__ __qualname____doc__rZrYrrsrZrceZdZdZ ddZdZedZedZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZy)rzA class that represents a URI. This class can represent arbitrary URIs that conform to the generic syntax described in RFC 3986. Nc || | ||||| |Jd|t|tr |jdt j |} | t d|z| jd|_| jd|_ | jd|_ | jd |_ | jd } | jd } | | |_ n| d t| zd|_ | jd |_| jd|_n\| t d||| t d| t d||_||_ ||_ ||_ ||_ ||_||_|j!|jdvr%|jst d|jzyy#t$r t dwxYw)zCreate a URI instance. Can be called with either a string URI or the component parts of the URI as keyword arguments. In either case, all arguments are expected to be appropriately URI encoded. NzeURI() must be called with a single string argument or with URI components given as keyword arguments.ASCIIz%URIs must consist of ASCII charactersz"%s" is not a valid URIschemeuserinfohostporthierpart authorityr]queryfragmentzURIs must have a schemez*host must be given if userinfo or port arezURIs must have a path) rrrrr6rmmsr-rKrLbzrrFrGz%s URIs must have a host name) isinstanceunicodeencodeUnicodeEncodeErrorruri_patmatchgrouprrrrrfrbrr _normalise) selfurirrrrrfrrrrrs rY__init__z URI.__init__sFNx7G $, ("2s{ ? > ?C ?#w'AJJw'MM#&E}%&?#&EFF++h/DK!KK 3DM F+DI F+DI{{:.H K0I $ %Qs9~%5%67 W-DJ!KK 3DM~%&?@@|!59I%@BB|%&=>> DK$DMDIDIDIDJ$DM  KK9 9 !"A"&++#./ / 9K*A)?AAAs G G c|jj|_|jt|j|_|j(t|jj|_|j dk(rd|_n?|j 3|j t j|jk(rd|_|j|jdk(rd|_tt|j|_|jt|j|_ |jt|j|_ yy)z(Perform normalisation of URI components.NrMrR) rlowerrrvrr _default_portgetrfrrrrs rYrzURI._normaliseskk'') == $0?DM 99 ,TYY__->?DI 99?DI YY "yyM--dkk::  99 TYY"_DI()>22CI>>rZcDt||jr|j|jk(xrj|j|jk(xrO|j|jk(xr4|j |j k(xr|j |j k(StSN)rrrrrfrrNotImplemented)rothers rY__eq__z URI.__eq__Ss eT^^ ,KK5<</4NNeoo54II+4JJ%++-4MMU^^3  5 " !rZcH|j|}|tk(rtS| Sr)rr)rrequals rY__ne__z URI.__ne__]s& E" N "! !9 rZct|j|j|j|j|j fSr)hashrrrfrrrs rY__hash__z URI.__hash__ds6 KKDJJ OP PrZc |s|St|j|j|j|j|j |j |j}|j||jdi|S)z;Replace one or more parts of the URI, returning the result.)rrrrrfrrr|) r rrrrrfrrupdater)rparts basepartss rYreplacez URI.replacehsiK;;]]**]]$  t~~* **rZc |j|S#t$rYnwxYwtj|}| tdt |j }|j d}|}|j d|d<|j d|d<|j d|d<t|j dd t|zd|d <|j d |d <n|j d}|j d }|d k(r'|j|d <|||d <nm|j|d <n]|jd rt||d <n8t|j||jdu|d <t|d |d <||d <|j|d<|j|d<|j|d<|j d|d<|jdi|S)zResolve the given URI reference relative to this URI. Uses the rules from Section 5.2 of RFC 3986 to resolve the new URI. NzInvalid relative reference)rrrrr relativepartr]rfrrMrR)rWrr|)rrrelative_ref_patrr rrrrbrfrrarrrr)r referencerrrrfrs rYresolvez URI.resolvews >>), ,   !&&y1 =!">? ?DKK(KK ,  % J 7E* !KK/E&M!KK/E&M/ N+Ac)n,<,=>@E&M"[[1E'N;;~.DKK(Erz $ f $%*E'N%)ZZE'N??3'$7$=E&M$)$))T8< 8M%OE&M$7f $FE&M!&g $ E*  IIE&M IIE&M!KK 3jt~~&&&s  cf|jdrJ|jj|S)zAppend the given path to this URI. The path must not start with a slash, but a slash is added to base URI (before appending the path), in case it doesn't end with a slash. rR)ra ensureSlashr)rrfs rYrdz URI.appends0??3'''!))$//rZcF|j|jk7s|j|jk7ry|j|jk(ry|j}|jds|dz }|j}|jds|dz }|j |S)z9Returns True if the URI 'other' is contained by this one.FTrR)rrrfendswithra)rrrU otherpaths rYcontainsz URI.containss KK5<< ' NNeoo - 99 "99  % OHJJ !!#&  I##H--rZct|dk(ry|jjd}|jd}|t| d|k(S)z@Return True if the given domain name a parent of the URL's host.rTr`N)rbrrk)rdomain our_segmentsdomain_segmentss rY underDomainzURI.underDomainsL v;! yys+  ,,s+S1123FFrZcz|jjdr|S|j|jdzS)z:Return a URI with the path normalised to end with a slash.rRrf)rfrrrs rYrzURI.ensureSlashs2 99  c "K<Return a URI with the path normalised to not end with a slash.rRr)rfrrrstriprs rY ensureNoSlashzURI.ensureNoSlashs9 99  c "</B@,  55?"P +0'd0 .G6rZra \b (?:about|gopher|http|https|sftp|news|ftp|mailto|file|irc|jabber|xmpp) : (?: (?: # "//" authority path-abempty // (?: # userinfo [%(unreserved)s:]* @ )? (?: # host \d+\.\d+\.\d+\.\d+ | [%(unreserved)s]* ) (?: # port : \d* )? (?: / [%(unreserved)s:@]* )* ) | (?: # path-absolute / (?: [%(unreserved)s:@]+ (?: / [%(unreserved)s:@]* )* )? ) | (?: # path-rootless [%(unreserved)s@] [%(unreserved)s:@]* (?: / [%(unreserved)s:@]* )* ) ) (?: # query \? [%(unreserved)s:@/\?\[\]]* )? (?: # fragment \# [%(unreserved)s:@/\?]* )? rrz-a-zA-Z0-9._~%!$&'()*+,;=z ([,.?:);>]+)$c#Ktj|D]8}|j}tj d|} t |}|:y#t $rYGwxYww)z8Scan a block of text for URIs, and yield the ones found.rMN)possible_uri_patfinditerruri_trailers_patsubrr)textr uri_stringrs rYrrAsg!**40 [[] &))"j9  j/C     s)?A# A A# A A#A  A#)(r{type __metaclass____all__rer NameErrorrr scheme_re userinfo_rehost_report_re authority_repath_abempty_repath_noscheme_repath_rootless_repath_absolute_re path_empty_re hier_part_rerelative_part_requery_re fragment_reuri_rerelative_ref_recompile IGNORECASErrrrrv ExceptionrrrVERBOSErrrr|rZrYrs`"6    0 E0 40 F 0  4 0  4 0 &0 d0 F0 D0 U0 E0 500 E0  F!0"v#0$ 6%0& E'0( 5)0* E+0, 6-0. F/00 E102304%506 d708 D90: 6;0< U=0>5?0@EA0BuC0DuE0JK0L     _0 h - J   '# HJJ!11 /#35E /#35E LM |X{ 4h - "**VR]] +2::or}}= (>2iAA~ (P01Q(2T2::or}}rzz/IJ2::./ AGsFFF