+
    4jkU                        R t Rt^ RIt]P                  R8H  t ]  ^ RI	t
RtRitRjRkRlRRP                  RR	4      3RmRnRoRpRqRrRsRtRuRvRw3tRxtRytR t. RzOt]! ]! ]]4      R
R
R
R
R
RRRRRR7      t]! R{/ ]B tR t]! 4       t]! R ]! 4       P7                  4        4       4      tR t]! R ]P7                  4        4       4      t]! R ]P7                  4        4       4      tR|R lt / ] n!        R}R lt"]
PF                  ! R4      t$R~t%R}R lt&R t'RR lt(] ! R4      t)] ! R4      t*R t+RR lt,R],n-        / RRbRR bR!R bR"R#bR$R%bR&R'bR(R)bR*R+bR,R-bR.R/bR0R1bR2R3bR4R5bR6R7bR	RbR8R9bR:R9b/ R;R<bR=R<bR>R?bR@RAbRBRAbRCR%bRDR%bRER%bRFR%bRGR%bRHRIbRJRKbRLRMbRNRObRPR?bRQR#bRRRSbCRTRURVRWRXRYRZR[R\R]R^R_R`Ra/C],n.        Rb t/]0Rc8X  d   ]Pb                  Rd,          '       g(   ]2! Re4       ]2! RfPg                  ]4! ]4      4      4       R# ]Pb                  ^,          Rg8X  d*   ] F!  t5]2! ]5Rh,           4       ]2! ]]5,          4       K#  	  R# ]Pb                  Rd,           F  t5]2! ]]5,          4       K  	  R# R#   ] d    ]t ELVi ; i  ] d    ^ RIt
Rt ELci ; i)uu	  
Parsing and validation of URIs (RFC 3986) and IRIs (RFC 3987).

This module provides regular expressions according to `RFC 3986 "Uniform
Resource Identifier (URI): Generic Syntax"
<http://tools.ietf.org/html/rfc3986>`_ and `RFC 3987 "Internationalized
Resource Identifiers (IRIs)" <http://tools.ietf.org/html/rfc3987>`_, and
utilities for composition and relative resolution of references.


API
---

**match** (string, rule='IRI_reference')
    {match.__doc__}

**parse** (string, rule='IRI_reference')
    {parse.__doc__}

**compose** (\*\*parts)
    {compose.__doc__}

**resolve** (base, uriref, strict=True, return_parts=False)
    {resolve.__doc__}

**patterns**
    A dict of regular expressions with useful group names.
    Compilable (with regex_ only) without need for any particular compilation
    flag.

**[bmp_][u]patterns[_no_names]**
    Alternative versions of `patterns`.
    [u]nicode strings without group names for the re_ module.
    BMP only for narrow builds.

**get_compiled_pattern** (rule, flags=0)
    {get_compiled_pattern.__doc__}

**format_patterns** (\*\*names)
    {format_patterns.__doc__}


Dependencies
------------

Some features require regex_.

This package's docstrings are tested on python 2.6, 2.7, and 3.2 to 3.6.
Note that in python<=3.2, characters beyond the Basic Multilingual Plane are
not supported on narrow builds (see `issue12729
<http://bugs.python.org/issue12729>`_).


Release notes
-------------

version 1.3.8:

- fixed deprecated escape sequence

version 1.3.6:

- fixed a bug in IPv6 pattern:

  >>> assert match('::0:0:0:0:0.0.0.0', 'IPv6address')

version 1.3.4:

- allowed for lower case percent encoding

version 1.3.3:

- fixed a bug in `resolve` which left "../" at the beginning of some paths

version 1.3.2:

- convenience function `match`
- patterns restricted to the BMP for narrow builds
- adapted doctests for python 3.3
- compatibility with python 2.6 (thanks to Thijs Janssen)

version 1.3.1:

- some re_ compatibility: get_compiled_pattern, parse
- dropped regex_ from setup.py requirements

version 1.3.0:

- python 3.x compatibility
- format_patterns

version 1.2.1:

- compose, resolve


.. _re: http://docs.python.org/library/re
.. _regex: http://pypi.python.org/pypi/regex


Support
-------
This is free software. You may show your appreciation with a `donation`_.

.. _donation: http://danielgerber.net/¤#Thanks-for-python-package-rfc3987

z1.3.8Ni  TFIPv6addressa  (?:                             (?:{h16}:){{6}} {ls32}|                            :: (?:{h16}:){{5}} {ls32}| (?:                {h16})? :: (?:{h16}:){{4}} {ls32}| (?:(?:{h16}:)?     {h16})? :: (?:{h16}:){{3}} {ls32}| (?:(?:{h16}:){{,2}}{h16})? :: (?:{h16}:){{2}} {ls32}| (?:(?:{h16}:){{,3}}{h16})? :: (?:{h16}:)      {ls32}| (?:(?:{h16}:){{,4}}{h16})? ::                 {ls32}| (?:(?:{h16}:){{,5}}{h16})? ::                 {h16} | (?:(?:{h16}:){{,6}}{h16})? ::                      )  pathipathc                    / p\         RRR1,          \        RRR1,          ,           \        RRR1,          ,            FL  w  r#W 9   d.   W,          p\        V4      '       d
   V! V4      pMRV: RV: R2pVP                  ! R/ VB W&   KN  	  V# )at  Returns a dict of patterns (regular expressions) keyed by
`rule names for URIs`_ and `rule names for IRIs`_.

See also the module level dicts of patterns, and `get_compiled_pattern`.

To wrap a rule in a named capture group, pass it as keyword argument:
rule_name='group_name'. By default, the formatted patterns contain no
named groups.

Patterns are `str` instances (be it in python 2.x or 3.x) containing ASCII
characters only.

Caveats:

  - with re_, named capture groups cannot occur on multiple branches of an
    alternation

  - with re_ before python 3.3, ``\u`` and ``\U`` escapes must be
    preprocessed (see `issue3665 <http://bugs.python.org/issue3665>`_)

  - on narrow builds, character ranges beyond BMP are not supported

.. _rule names for URIs: http://tools.ietf.org/html/rfc3986#appendix-A
.. _rule names for IRIs: http://tools.ietf.org/html/rfc3987#section-2.2
Nz(?P<>) )_common_rules
_uri_rules
_iri_rulescallableformat)names	formattednamepatns   ,    Y/home/user/pdf2html-billing-ledger-validate/.venv/lib/python3.14/site-packages/rfc3987.pyformat_patternsr   !  s    4 I"4R4(:dd+;;j2>NNN	=A{{f  '(-**1y1	 O     )
path_abemptypath_absolutepath_noschemepath_rootless
path_emptyipath_abemptyipath_absoluteipath_noschemeipath_rootlessipath_emptyc                 B    V P                  R 4      P                  R4      # )asciizraw-unicode-escape)encodedecode)strings   &r   _interpret_unicode_escapesr(   ^  s    ==!(()=>>r   c              #   @   "   T F  w  rV\        V4      3x  K  	  R # 5iN)r(   .0kvs   &  r   	<genexpr>r/   e  s&      86 BE18;<6   c                 2    \         P                  ! R RV 4      # )z\\U[0-9A-F]{8}-\\U[0-9A-F]{8}r   )_resub)ss   &r   <lambda>r5   h  s    92qAr   c              #   @   "   T F  w  rV\        V4      3x  K  	  R # 5ir*   )_bmpr+   s   &  r   r/   r/   k  s     =,<SQQQL,<r0   c              #   R   "   T F  w  rV\        \        V4      4      3x  K  	  R # 5ir*   )r(   r7   r+   s   &  r   r/   r/   m  s)      D)B#!  !"<T!W"EF)Bs   %'c                .   \         P                  W3r2W29  dw   \        '       d   \        '       d   \        M\
        pM\        '       d   \        M\        pVP                  V 4      ;'       g	    W,          p\        P                  ! WQ4      W#&   W#,          # )a  Returns a compiled pattern object for a rule name or template string.

Usage for validation::

    >>> uri = get_compiled_pattern('^%(URI)s$')
    >>> assert uri.match('http://tools.ietf.org/html/rfc3986#appendix-A')
    >>> assert not get_compiled_pattern('^%(relative_ref)s$').match('#f#g')
    >>> from unicodedata import lookup
    >>> smp = 'urn:' + lookup('OLD ITALIC LETTER A')  # U+00010300
    >>> assert not uri.match(smp)
    >>> m = get_compiled_pattern('^%(IRI)s$').match(smp)

On narrow builds, non-BMP characters are (incorrectly) excluded::

    >>> assert NARROW_BUILD == (not m)

For parsing, some subcomponents are captured in named groups (*only if*
regex_ is available, otherwise see `parse`)::

    >>> match = uri.match('http://tools.ietf.org/html/rfc3986#appendix-A')
    >>> d = match.groupdict()
    >>> if REGEX:
    ...     assert all([ d['scheme'] == 'http',
    ...                  d['authority'] == 'tools.ietf.org',
    ...                  d['path'] == '/html/rfc3986',
    ...                  d['query'] == None,
    ...                  d['fragment'] == 'appendix-A' ])

    >>> for r in patterns.keys():
    ...     assert get_compiled_pattern(r)

)get_compiled_patterncacheNARROW_BUILDREGEXbmp_patternsbmp_upatterns_no_namespatternsupatterns_no_namesgetr2   compile)ruleflagsr;   keypatsps   &&    r   r:   r:   q  sf    B &++d]3
<#(5<.DD$u8*<DHHTN))dk[[*
:r   c                D    \        RV,          4      P                  V 4      # )zConvenience function for checking if `string` matches a specific rule.

Returns a match object or None::

    >>> assert match('%C7X', 'pct_encoded') is None
    >>> assert match('%C7', 'pct_encoded')
    >>> assert match('%c7', 'pct_encoded')

z	^%%(%s)s$)r:   match)r'   rD   s   &&r   rJ   rJ     s      d 2399&AAr   zm^((?P<scheme>[^:/?#]+):)?(//(?P<authority>[^/?#]*))?(?P<path>[^?#]*)(\?(?P<query>[^#]*))?(#(?P<fragment>.*))?c                T   \         '       g   V'       d   V\        9  d   \        V4      hV'       dL   \        W4      pV'       g   \        V : RV: R24      h\         '       d   \	        VP                  4       4      # \	        \        P                  V 4      P                  4       4      # )a  Parses `string` according to `rule` into a dict of subcomponents.

If `rule` is None, parse an IRI_reference `without validation
<http://tools.ietf.org/html/rfc3986#appendix-B>`_.

If regex_ is available, any rule is supported; with re_, `rule` must be
'IRI_reference' or some special case thereof ('IRI', 'absolute_IRI',
'irelative_ref', 'irelative_part', 'URI_reference', 'URI', 'absolute_URI',
'relative_ref', 'relative_part'). ::

    >>> d = parse('http://tools.ietf.org/html/rfc3986#appendix-A',
    ...           rule='URI')
    >>> assert all([ d['scheme'] == 'http',
    ...              d['authority'] == 'tools.ietf.org',
    ...              d['path'] == '/html/rfc3986',
    ...              d['query'] == None,
    ...              d['fragment'] == 'appendix-A' ])

z is not a valid .)r=   REFERENCE_RULES
ValueErrorrJ   _i2u	groupdict_iri_non_validating_re)r'   rD   ms   && r   parserS     ss    ( 5Td/9&EFF5&&&,,V4>>@AAr   c                 l    R F-  w  rV P                  V4      e   K  V P                  V4      W&   K/  	  V # )	authority))rU   
iauthority)r   r   )queryiquery)fragment	ifragment)rB   )dicr   inames   &  r   rO   rO     s6    J774= CIJ Jr   c	                    \        \        4       4       Rp
V e   WR,           ,          p
Ve   V
RV,           ,          p
Y;'       g    R,          p
Ve   V
RV,           ,          p
Ve   V
RV,           ,          p
V
# )ziReturns an URI composed_ from named parts.

.. _composed: http://tools.ietf.org/html/rfc3986#section-5.3
r   :z//?#)rO   locals)schemerU   r   rW   rY   rV   r   rX   rZ   kwress   &&&&&&&&&, r   composere     st     	N
C|ti::2CsU{sX~Jr   z$^(?:\.{1,2}(?:/|$))+|(?<=/)\.(?:/|$)z/?%(segment)s/\.{2}(?:/|$)c                 |    \         P                  R V 4      p ^pV'       d   \        P                  RV ^4      w  rK#  V # )r   /)_dot_segmentsr3   _2dots_segmentssubn)r   cs   & r   _remove_dot_segmentsrl     s9    b$'D	A
"''T15aKr   c                F   \        V \        4      '       d   \        V R4      pM\        \	        V 4      4      pVP                  R4      '       g   \        RV ,          4      h\        V\        4      '       d   \        VR4      pM\        \	        V4      4      pVR,          '       d"   V'       g   VR,          VR,          8w  d   TpEM1/ pVR,          VR&   VR,          e&   VR,          VR&   VR,          VR&   VR,          VR&   MVR,          VR&   VR,          '       d   VR,          R,          R	8X  d   VR,          VR&   MmVR,          e$   VR,          '       g   R
VR,          ,          VR&   M?RP                  VR,          P                  R	4      R,          4      VR,          ,           VR&   VR,          VR&   M0VR,          VR&   VR,          e   VR,          VR&   MVR,          VR&   VR,          VR&   \        VR,          4      VR&   V'       d   V# \        R/ VB # )a  Resolves_ an `URI reference` relative to a `base` URI.

`Test cases <http://tools.ietf.org/html/rfc3986#section-5.4>`_::

    >>> base = resolve.test_cases_base
    >>> for relative, resolved in resolve.test_cases.items():
    ...     assert resolve(base, relative) == resolved

If `return_parts` is True, returns a dict of named parts instead of
a string.

Examples::

    >>> assert resolve('urn:rootless', '../../name') == 'urn:name'
    >>> assert resolve('urn:root/less', '../../name') == 'urn:/name'
    >>> assert resolve('http://a/b', 'http:g') == 'http:g'
    >>> assert resolve('http://a/b', 'http:g', strict=False) == 'http://a/g'

.. _Resolves: http://tools.ietf.org/html/rfc3986#section-5.2

IRIrb   z&Expected an IRI (with scheme), not %r.IRI_referencerU   r   rW   :N   Nrg   z/%sr   :N   NrY   r   )
isinstance
basestringrS   rO   dictrB   rN   join
rpartitionrl   re   )baseurirefstrictreturn_partsBRTs   &&&&   r   resolver~     s   . $
##$d55??ADHII&*%%&/*f 	{{!H+8"<k([>%{^AkN&	AfI7AgJ{^AkNyyV9R=C' !&	AfI{^/&		 %&	 1AfI "&	(<(<S(A"(E F6 RAfIwZ'
fI&	W:)!"7AgJ!"7AgJ**$QvY/AfI||r   zhttp://a/b/c/d;p?qzg:hgzhttp://a/b/c/gz./gzg/zhttp://a/b/c/g/z/gz
http://a/gz//gzhttp://gz?yzhttp://a/b/c/d;p?yzg?yzhttp://a/b/c/g?yz#szhttp://a/b/c/d;p?q#szg#szhttp://a/b/c/g#szg?y#szhttp://a/b/c/g?y#sz;xzhttp://a/b/c/;xzg;xzhttp://a/b/c/g;xzg;x?y#szhttp://a/b/c/g;x?y#srL   zhttp://a/b/c/z./z..zhttp://a/b/z../z../gzhttp://a/b/gz../..z	http://a/z../../z../../gz
../../../gz../../../../gz/./gz/../gzg.zhttp://a/b/c/g.z.gzhttp://a/b/c/.gzg..zhttp://a/b/c/g..z..gzhttp://a/b/c/..gz./../gz./g/.zg/./hzhttp://a/b/c/g/hzg/../hzhttp://a/b/c/hz	g;x=1/./yzhttp://a/b/c/g;x=1/yz
g;x=1/../yzhttp://a/b/c/yzg?y/./xzhttp://a/b/c/g?y/./xzg?y/../xzhttp://a/b/c/g?y/../xzg#s/./xzhttp://a/b/c/g#s/./xzg#s/../xzhttp://a/b/c/g#s/../xc                    \         h)zSyntax-Based Normalization)NotImplementedError)uris   &r   	normalizer   o  s
     r   __main__:rp   NNz/Valid arguments are "--all" or rule names from:z  z--allr^   )r:   rS   r   r@   re   r~   rJ   )rb   z[a-zA-Z][a-zA-Z0-9+.-]*)portz[0-9]*)
IP_literalz!\[(?:{IPv6address}|{IPvFuture})\])ls32z(?:{h16}:{h16}|{IPv4address}))h16z{hexdig}{{1,4}})IPv4addressz!(?:{dec_octet}\.){{3}}{dec_octet})	dec_octetz((?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))	IPvFuturez,v{hexdig}+\.(?:{unreserved}|{sub_delims}|:)+)
unreservedz[a-zA-Z0-9_.~-])reservedz(?:{gen_delims}|{sub_delims}))pct_encodedz%{hexdig}{{2}})
gen_delimsz
[:/?#[\]@])
sub_delimsz[!$&'()*+,;=])hexdigz[0-9A-Fa-f]))URI_referencez(?:{URI}|{relative_ref}))URIz{absolute_URI}(?:\#{fragment})?)absolute_URIz"{scheme}:{hier_part}(?:\?{query})?)relative_refz.{relative_part}(?:\?{query})?(?:\#{fragment})?)	hier_partzL(?://{authority}{path_abempty}|{path_absolute}|{path_rootless}|{path_empty}))relative_partzL(?://{authority}{path_abempty}|{path_absolute}|{path_noscheme}|{path_empty}))rU   z"(?:{userinfo}@)?{host}(?::{port})?)hostz)(?:{IP_literal}|{IPv4address}|{reg_name}))userinfoz.(?:{unreserved}|{pct_encoded}|{sub_delims}|:)*)reg_namez,(?:{unreserved}|{pct_encoded}|{sub_delims})*)r   zO(?:{path_abempty}|{path_absolute}|{path_noscheme}|{path_rootless}|{path_empty}))r   z(?:/{segment})*)r   z!/(?:{segment_nz}(?:/{segment})*)?)r   z{segment_nz_nc}(?:/{segment})*)r   z{segment_nz}(?:/{segment})*)r   r   )segmentz{pchar}*)
segment_nzz{pchar}+)segment_nz_ncz.(?:{unreserved}|{pct_encoded}|{sub_delims}|@)+)rW   (?:{pchar}|/|\?)*)rY   r   )pcharz/(?:{unreserved}|{pct_encoded}|{sub_delims}|:|@)))ro   z(?:{IRI}|{irelative_ref}))rn   z {absolute_IRI}(?:\#{ifragment})?)absolute_IRIz${scheme}:{ihier_part}(?:\?{iquery})?)irelative_refz5(?:{irelative_part}(?:\?{iquery})?(?:\#{ifragment})?))
ihier_partzQ(?://{iauthority}{ipath_abempty}|{ipath_absolute}|{ipath_rootless}|{ipath_empty}))irelative_partzQ(?://{iauthority}{ipath_abempty}|{ipath_absolute}|{ipath_noscheme}|{ipath_empty}))rV   z$(?:{iuserinfo}@)?{ihost}(?::{port})?)	iuserinfoz/(?:{iunreserved}|{pct_encoded}|{sub_delims}|:)*)ihostz*(?:{IP_literal}|{IPv4address}|{ireg_name}))	ireg_namez-(?:{iunreserved}|{pct_encoded}|{sub_delims})*)r   zT(?:{ipath_abempty}|{ipath_absolute}|{ipath_noscheme}|{ipath_rootless}|{ipath_empty}))r"   r   )r!   z{isegment_nz}(?:/{isegment})*)r    z {isegment_nz_nc}(?:/{isegment})*)r   z#/(?:{isegment_nz}(?:/{isegment})*)?)r   z(?:/{isegment})*)isegment_nz_ncz/(?:{iunreserved}|{pct_encoded}|{sub_delims}|@)+)isegment_nzz	{ipchar}+)isegmentz	{ipchar}*)rX   z(?:{ipchar}|{iprivate}|/|\?)*)rZ   z(?:{ipchar}|/|\?)*)ipcharz0(?:{iunreserved}|{pct_encoded}|{sub_delims}|:|@))iunreservedz(?:[a-zA-Z0-9._~-]|{ucschar}))iprivatez9[\uE000-\uF8FF\U000F0000-\U000FFFFD\U00100000-\U0010FFFD])ucscharaM  [\xA0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF\U00010000-\U0001FFFD\U00020000-\U0002FFFD\U00030000-\U0003FFFD\U00040000-\U0004FFFD\U00050000-\U0005FFFD\U00060000-\U0006FFFD\U00070000-\U0007FFFD\U00080000-\U0008FFFD\U00090000-\U0009FFFD\U000A0000-\U000AFFFD\U000B0000-\U000BFFFD\U000C0000-\U000CFFFD\U000D0000-\U000DFFFD\U000E1000-\U000EFFFD])rb   r   r   r   r   r   r   r   r   r   rU   r   r   r   rW   rY   ro   rn   r   r   r   rV   r   r   r   rX   rZ   r   )    )ro   )
ro   rn   r   r   r   r   r   r   r   r   )	NNNNNNNNN)TF)6__doc____version__sys_sys
maxunicoder<   rs   	NameErrorstrregexr2   r=   ImportErrorre__all__replacer   r   r   r   _GROUP_NAMES_BASErt   zipDEFAULT_GROUP_NAMESr@   r(   patterns_no_namesitemsrA   r7   r>   r?   r:   r;   rJ   rC   rQ   rM   rS   rO   re   rh   ri   rl   r~   test_cases_base
test_casesr   __name__argvprintru   sortedr   r   r   r   <module>r      s  &jV  &(E
* 1   ; O  R(	* 7(:AE *7($'%A"J)
\7
t#L
  301BCvVV''	1  101? $%   8,.4468 8  B =HNN,<== D):)@)@)BD D )T    
B AB 4
B>( %%LM&'DEDL / *	u*'* 
'* 	(	*
 	|* 
z* 	+* 
)* 	-* 
)* +* 	(* 
)* -* +*  !*" 	#*$ 	}%*& 
}'*( ~)** {+*, {-*. |/*0 |1*2 |3*4 |5*6 |7*8 	(9*: 	(;*< 
)=*> 
)?*@ ~A*B (C*D )E*F '-'-.-.S* Z z99R==?@diix()*	1	 D$*(4.!  IIbMMD(4.! " _  J  Es"   I% I5 %	I21I25JJ