�
��][kU � �8 � d Z dZddlZej dk Z e n
# e$ r eZY nw xY w ddl Z
dZn# e$ r ddl
Z
dZY nw xY wdZdd d
dd� d
d� � fdddddddddddfZdZdZd� Zg d�Z e eee� � dddddddddd� � � Z edxi e��Zd!� Z e� � Z ed"� e� � � � � D � � � � Zd#� Z ed$� e� � � D � � � � Z ed%� e� � � D � � � � Zdyd&�Z i e _! dzd(�Z" e
j# d)� � Z$d*Z%dzd+�Z&d,� Z' d{d-�Z( e d.� � Z) e d/� � Z*d0� Z+d|d1�Z,d2e,_- i d3d3�d4d5�d6d5�d7d8�d9d:�d;d<�d=d>�d?d@�dAdB�dCdD�dEdF�dGdH�dIdJ�dKdL�dd2�dMdN�dOdN�i dPdQ�dRdQ�dSdT�dUdV�dWdV�dXd:�dYd:�dZd:�d[d:�d\d:�d]d^�d_d`�dadb�dcdd�dedT�dfd8�dgdh��didjdkdldmdndodp��e,_. dq� Z/e0drk r�ej1 dsd� s4 e2dt� � e2du�3 e4e� � � � � � dS ej1 ds dvk r&eD ]!Z5 e2e5dwz � � e2ee5 � � �"dS ej1 dsd� D ]Z5 e2ee5 � � �dS dS )}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
z1.3.8� Ni�� TF)�get_compiled_pattern�parse�format_patterns�patterns�compose�resolve�match)�schemez[a-zA-Z][a-zA-Z0-9+.-]*)�portz[0-9]*)�
IP_literalz!\[(?:{IPv6address}|{IPvFuture})\]�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})? :: )� � )�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}))� authorityz"(?:{userinfo}@)?{host}(?::{port})?)�hostz)(?:{IP_literal}|{IPv4address}|{reg_name}))�userinfoz.(?:{unreserved}|{pct_encoded}|{sub_delims}|:)*)�reg_namez,(?:{unreserved}|{pct_encoded}|{sub_delims})*)�pathzO(?:{path_abempty}|{path_absolute}|{path_noscheme}|{path_rootless}|{path_empty}))�path_abemptyz(?:/{segment})*)�
path_absolutez!/(?:{segment_nz}(?:/{segment})*)?)�
path_noschemez{segment_nz_nc}(?:/{segment})*)�
path_rootlessz{segment_nz}(?:/{segment})*)�
path_emptyr )�segmentz{pchar}*)�
segment_nzz{pchar}+)�
segment_nz_ncz.(?:{unreserved}|{pct_encoded}|{sub_delims}|@)+)�query�(?:{pchar}|/|\?)*)�fragmentr/ )�pcharz/(?:{unreserved}|{pct_encoded}|{sub_delims}|:|@)))�
IRI_referencez(?:{IRI}|{irelative_ref}))�IRIz {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}))�
iauthorityz$(?:{iuserinfo}@)?{ihost}(?::{port})?)� iuserinfoz/(?:{iunreserved}|{pct_encoded}|{sub_delims}|:)*)�ihostz*(?:{IP_literal}|{IPv4address}|{ireg_name}))� ireg_namez-(?:{iunreserved}|{pct_encoded}|{sub_delims})*)�ipathzT(?:{ipath_abempty}|{ipath_absolute}|{ipath_noscheme}|{ipath_rootless}|{ipath_empty}))�ipath_emptyr )�ipath_rootlessz{isegment_nz}(?:/{isegment})*)�ipath_noschemez {isegment_nz_nc}(?:/{isegment})*)�ipath_absolutez#/(?:{isegment_nz}(?:/{isegment})*)?)�
ipath_abemptyz(?:/{isegment})*)�isegment_nz_ncz/(?:{iunreserved}|{pct_encoded}|{sub_delims}|@)+)�isegment_nzz {ipchar}+)�isegmentz {ipchar}*)�iqueryz(?:{ipchar}|{iprivate}|/|\?)*)� ifragmentz(?:{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]c � � i }t ddd� t ddd� z t ddd� z D ]E\ }}|| v r,| | }t |� � r ||� � }n d|�d|�d�} |j di |��||< |