3
,î[» ã @ s– d Z ddlmZ ddlZdZdZdZdeƒ Zdeƒ Z d Z
d
Zdeƒ Zdeƒ Z
d
eƒ Zdeƒ Zdeƒ Zdeƒ Zdeƒ Zdeƒ Zdeƒ Zdeƒ Zdeƒ Zdeƒ Zdeƒ Zdeƒ Zdeƒ Zdeƒ Zdeƒ Zdeƒ Zdeƒ Zdeƒ Zdeƒ Z d eƒ Z!d!Z"d"eƒ Z#d#eƒ Z$d#eƒ Z%d$eƒ Z&d%eƒ Z'd&eƒ Z(d'eƒ Z)d(eƒ Z*d)eƒ Z+d*d+„ Z,d,d-„ Z-d.d/„ Z.dS )0a
Regex for URIs
These regex are directly derived from the collected ABNF in RFC3986
(except for DIGIT, ALPHA and HEXDIG, defined by RFC2234).
They should be processed with re.VERBOSE.
Thanks Mark Nottingham for this code - https://gist.github.com/138549
é )Úunicode_literalsNz[\x30-\x39]z[\x41-\x5A\x61-\x7A]z[\x30-\x39A-Fa-f]z %% %(HEXDIG)s %(HEXDIG)sz-(?: %(ALPHA)s | %(DIGIT)s | \- | \. | _ | ~ )z#(?: : | / | \? | \# | \[ | \] | @ )zI(?: ! | \$ | & | ' | \( | \) |
\* | \+ | , | ; | = )z?(?: %(unreserved)s | %(pct_encoded)s | %(sub_delims)s | : | @ )z%(?: %(gen_delims)s | %(sub_delims)s )z5%(ALPHA)s (?: %(ALPHA)s | %(DIGIT)s | \+ | \- | \. )*zÄ(?: %(DIGIT)s |
[\x31-\x39] %(DIGIT)s |
1 %(DIGIT)s{2} |
2 [\x30-\x34] %(DIGIT)s |
25 [\x30-\x35]
)
z@%(dec_octet)s \. %(dec_octet)s \. %(dec_octet)s \. %(dec_octet)sz(?: %(HEXDIG)s ){1,4}z/(?: (?: %(h16)s : %(h16)s ) | %(IPv4address)s )aá (?: (?: %(h16)s : ){6} %(ls32)s |
:: (?: %(h16)s : ){5} %(ls32)s |
%(h16)s :: (?: %(h16)s : ){4} %(ls32)s |
(?: %(h16)s : ) %(h16)s :: (?: %(h16)s : ){3} %(ls32)s |
(?: %(h16)s : ){2} %(h16)s :: (?: %(h16)s : ){2} %(ls32)s |
(?: %(h16)s : ){3} %(h16)s :: %(h16)s : %(ls32)s |
(?: %(h16)s : ){4} %(h16)s :: %(ls32)s |
(?: %(h16)s : ){5} %(h16)s :: %(h16)s |
(?: %(h16)s : ){6} %(h16)s ::
)
z;v %(HEXDIG)s+ \. (?: %(unreserved)s | %(sub_delims)s | : )+z+\[ (?: %(IPv6address)s | %(IPvFuture)s ) \]z8(?: %(unreserved)s | %(pct_encoded)s | %(sub_delims)s )*z;(?: %(unreserved)s | %(pct_encoded)s | %(sub_delims)s | : )z5(?: %(IP_literal)s | %(IPv4address)s | %(reg_name)s )z(?: %(DIGIT)s )*z.(?: %(userinfo)s @)? %(host)s (?: : %(port)s)?z
%(pchar)s*z
%(pchar)s+z<(?: %(unreserved)s | %(pct_encoded)s | %(sub_delims)s | @ )+z(?: / %(segment)s )*z,/ (?: %(segment_nz)s (?: / %(segment)s )* )?z&%(segment_nz_nc)s (?: / %(segment)s )*z#%(segment_nz)s (?: / %(segment)s )*Ú z¬(?: %(path_abempty)s |
%(path_absolute)s |
%(path_noscheme)s |
%(path_rootless)s |
%(path_empty)s
)
z(?: %(pchar)s | / | \? )*z³(?: (?: // %(authority)s %(path_abempty)s ) |
%(path_absolute)s |
%(path_rootless)s |
%(path_empty)s
)
zÃ(?: (?: // %(authority)s %(path_abempty)s ) |
%(path_absolute)s |
%(path_noscheme)s |
%(path_empty)s
)
z:%(relative_part)s (?: \? %(query)s)? (?: \# %(fragment)s)?zM^(?: %(scheme)s : %(hier_part)s (?: \? %(query)s )? (?: \# %(fragment)s )? )$z"^(?: %(URI)s | %(relative_ref)s )$z6^(?: %(scheme)s : %(hier_part)s (?: \? %(query)s )? )$c C s t jt| t jƒS )N)ÚreÚmatchÚURIÚVERBOSE)Úuri© r ú"/usr/lib/python3.6/uri_validate.pyÚis_uriÏ s r c C s t jt| t jƒS )N)r r Ú
URI_referencer )r r r r
Úis_uri_referenceÓ s r
c C s t jt| t jƒS )N)r r Úabsolute_URIr )r r r r
Úis_absolute_uri× s r )/Ú__doc__Z
__future__r r ZDIGITZALPHAZHEXDIGÚlocalsZpct_encodedZ
unreservedZ
gen_delimsZ
sub_delimsZpcharZreservedÚschemeZ dec_octetZIPv4addressZh16Zls32ZIPv6addressZ IPvFutureZ
IP_literalZreg_nameZuserinfoÚhostZportZ authorityZsegmentZ
segment_nzZ
segment_nz_ncZpath_abemptyZ
path_absoluteZ
path_noschemeZ
path_rootlessZ
path_emptyÚpathZqueryZfragmentZ hier_partZ
relative_partZrelative_refr r r r r
r r r r r
Ú