o ^K @s*dZeZgdZddlZzeWn eyeZYnwidddddd 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 e e fZ dMZdNZdOZdPeZdQZdRe eeeefZdSe eeeefZdTZdUZdVe eeefZdWeeefZeeejZeeejZdXdYZdZd[Zd\d]ZGd^d_d_e Z!Gd`dadaZ"dbdcddiZ#ee#ejej$BZ%edeZ&dfdgZ'dS)hz/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(?:%s@)?%s(?::%s)?)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//%s%s|%s|%s|%s)z!(?P//%s%s|%s|%s|%s)z=(?P(?:[-a-z0-9._~!$&\'()*+,;=:@/?\[\]]|%[0-9a-f]{2})*)z<(?P(?:[-a-z0-9._~!$&\'()*+,;=:@/?]|%[0-9a-f]{2})*)z%s:%s(?:\?%s)?(?:#%s)?$z%s(?:\?%s)?(?:#%s)?$cCs2|r |dkr d|S|d}|d|d|S)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. rL/N)rfind)basepathrelpath has_authorityslashrT//usr/lib/python3/dist-packages/lazr/uri/_uri.pyrs  rcCsg}|rz|dr|dd}nh|dr|dd}n\|ds%|dkr.d|dd}nJ|d s7|d krId|d d}t|d krH|d =n/|dvrPd}n(|dr\|dd}n|d}|d krit|}||d|||d}|sd|S)zqRemove '.' and '..' segments from a URI path. Follows the rules specified in Section 5.2.4 of RFC 3986. z../Nz./z/./z/.rMz/../z/..r).z..rLrN) startswithlenfindappendjoin)pathoutputrSrTrTrUrs0       rc Cs|d}d}t|D]=\}}|dkrq z t|ddd}Wn ty(Yq wt||vrReturn a URI with the path normalised to not end with a slash.rMr)r`rrrstriprrTrTrU ensureNoSlashs zURI.ensureNoSlash)NNNNNNNN)rprqrrrsrrpropertyrzrrrrrrrrr^rrrrrTrTrTrUrs, A   2  ra \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:@/\?]* )? rkz-a-zA-Z0-9._~%!$&'()*+,;=z ([,.?:);>]+)$c csPt|D]}|}td|}zt|}Wn ty!Yqw|VqdS)z8Scan a block of text for URIs, and yield the ones found.rLN)possible_uri_patfinditerruri_trailers_patsubrr)textr uri_stringrrTrTrUrAs   r)(rstype __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 IGNORECASErrrrro ExceptionrrrVERBOSErrrrTrTrTrUs        !"%&4A(*