+
    G8
kia  ã                   óü  € R t ^ RIt^ RIHtHt ^ RIHt ^ RIHt ^ RIH	t	H
t
Ht ^ RIHt ^ RIHtHtHt ^ RIHt ^ R	IHt ^ R
IHtHtHtHt  ! R R]P6                  4      t ! R R]4      t ! R R]P<                  4      t ! R R]P<                  4      t ]]
R]!]	,          ]"]
]#R3,          ]	3,          ]"]
]#R3,          ]	]$]#]	3,          3,          ]"]
]#R3,          ]	]$]#]	3,          ]#3,          3,          ,          t% ! R R]4      t& ! R R]]&4      t' ! R R4      t( ! R R4      t) ! R R])4      t* ! R R])4      t+ ! R R ])4      t, ! R! R"])4      t- ! R# R$](4      t.]R% R& l4       t/]R' R( l4       t/R) R* lt/R# )+ap  Flexible routing implementation.

Tornado routes HTTP requests to appropriate handlers using `Router`
class implementations. The `tornado.web.Application` class is a
`Router` implementation and may be used directly, or the classes in
this module may be used for additional flexibility. The `RuleRouter`
class can match on more criteria than `.Application`, or the `Router`
interface can be subclassed for maximum customization.

`Router` interface extends `~.httputil.HTTPServerConnectionDelegate`
to provide additional routing capabilities. This also means that any
`Router` implementation can be used directly as a ``request_callback``
for `~.httpserver.HTTPServer` constructor.

`Router` subclass must implement a ``find_handler`` method to provide
a suitable `~.httputil.HTTPMessageDelegate` instance to handle the
request:

.. code-block:: python

    class CustomRouter(Router):
        def find_handler(self, request, **kwargs):
            # some routing logic providing a suitable HTTPMessageDelegate instance
            return MessageDelegate(request.connection)

    class MessageDelegate(HTTPMessageDelegate):
        def __init__(self, connection):
            self.connection = connection

        def finish(self):
            self.connection.write_headers(
                ResponseStartLine("HTTP/1.1", 200, "OK"),
                HTTPHeaders({"Content-Length": "2"}),
                b"OK")
            self.connection.finish()

    router = CustomRouter()
    server = HTTPServer(router)

The main responsibility of `Router` implementation is to provide a
mapping from a request to `~.httputil.HTTPMessageDelegate` instance
that will handle this request. In the example above we can see that
routing is possible even without instantiating an `~.web.Application`.

For routing to `~.web.RequestHandler` implementations we need an
`~.web.Application` instance. `~.web.Application.get_handler_delegate`
provides a convenient way to create `~.httputil.HTTPMessageDelegate`
for a given request and `~.web.RequestHandler`.

Here is a simple example of how we can we route to
`~.web.RequestHandler` subclasses by HTTP method:

.. code-block:: python

    resources = {}

    class GetResource(RequestHandler):
        def get(self, path):
            if path not in resources:
                raise HTTPError(404)

            self.finish(resources[path])

    class PostResource(RequestHandler):
        def post(self, path):
            resources[path] = self.request.body

    class HTTPMethodRouter(Router):
        def __init__(self, app):
            self.app = app

        def find_handler(self, request, **kwargs):
            handler = GetResource if request.method == "GET" else PostResource
            return self.app.get_handler_delegate(request, handler, path_args=[request.path])

    router = HTTPMethodRouter(Application())
    server = HTTPServer(router)

`ReversibleRouter` interface adds the ability to distinguish between
the routes and reverse them to the original urls using route's name
and additional arguments. `~.web.Application` is itself an
implementation of `ReversibleRouter` class.

`RuleRouter` and `ReversibleRuleRouter` are implementations of
`Router` and `ReversibleRouter` interfaces and can be used for
creating rule-based routing configurations.

Rules are instances of `Rule` class. They contain a `Matcher`, which
provides the logic for determining whether the rule is a match for a
particular request and a target, which can be one of the following.

1) An instance of `~.httputil.HTTPServerConnectionDelegate`:

.. code-block:: python

    router = RuleRouter([
        Rule(PathMatches("/handler"), ConnectionDelegate()),
        # ... more rules
    ])

    class ConnectionDelegate(HTTPServerConnectionDelegate):
        def start_request(self, server_conn, request_conn):
            return MessageDelegate(request_conn)

2) A callable accepting a single argument of `~.httputil.HTTPServerRequest` type:

.. code-block:: python

    router = RuleRouter([
        Rule(PathMatches("/callable"), request_callable)
    ])

    def request_callable(request):
        request.write(b"HTTP/1.1 200 OK\r\nContent-Length: 2\r\n\r\nOK")
        request.finish()

3) Another `Router` instance:

.. code-block:: python

    router = RuleRouter([
        Rule(PathMatches("/router.*"), CustomRouter())
    ])

Of course a nested `RuleRouter` or a `~.web.Application` is allowed:

.. code-block:: python

    router = RuleRouter([
        Rule(HostMatches("example.com"), RuleRouter([
            Rule(PathMatches("/app1/.*"), Application([(r"/app1/handler", Handler)])),
        ]))
    ])

    server = HTTPServer(router)

In the example below `RuleRouter` is used to route between applications:

.. code-block:: python

    app1 = Application([
        (r"/app1/handler", Handler1),
        # other handlers ...
    ])

    app2 = Application([
        (r"/app2/handler", Handler2),
        # other handlers ...
    ])

    router = RuleRouter([
        Rule(PathMatches("/app1.*"), app1),
        Rule(PathMatches("/app2.*"), app2)
    ])

    server = HTTPServer(router)

For more information on application-level routing see docs for `~.web.Application`.

.. versionadded:: 4.5

N)Ú	AwaitableÚSequence)Úpartial)ÚPattern)ÚAnyÚUnionÚoverload)Úhttputil)Ú
url_escapeÚurl_unescapeÚutf8)Ú_CallableAdapter)Úapp_log)Úbasestring_typeÚimport_objectÚre_unescapeÚunicode_typec                   óH   a € ] tR t^Ãt o RtV 3R lR ltV 3R lR ltRtV tR# )ÚRouterzAbstract router interface.c                ób   <€ V ^8„  d   QhRS[ P                  RS[RS[ P                  R,          /# ©é   ÚrequestÚkwargsÚreturnN©r	   ÚHTTPServerRequestr   ÚHTTPMessageDelegate)ÚformatÚ__classdict__s   "€Ú†/opt/data/installs/351f81cc06284494/environments/aa258815729c481f8402f54f4c368f83/venv/lib/python3.14/site-packages/tornado/routing.pyÚ__annotate__ÚRouter.__annotate__Æ   s6   ø€ ÷ $ñ $Ù×1Ñ1ð$Ù=@ð$á	×	%Ñ	%¨Õ	,ñ$ó    c                ó   € \        4       h)aº  Must be implemented to return an appropriate instance of `~.httputil.HTTPMessageDelegate`
that can serve the request.
Routing implementations may pass additional kwargs to extend the routing logic.

:arg httputil.HTTPServerRequest request: current HTTP request.
:arg kwargs: additional keyword arguments passed by routing implementation.
:returns: an instance of `~.httputil.HTTPMessageDelegate` that will be used to
    process the request.
©ÚNotImplementedError)Úselfr   r   s   &&,r    Úfind_handlerÚRouter.find_handlerÆ   s   € ô "Ó#Ð#r#   c                óT   <€ V ^8„  d   QhRS[ RS[P                  RS[P                  /# )r   Úserver_connÚrequest_connr   )Úobjectr	   ÚHTTPConnectionr   )r   r   s   "€r    r!   r"   Ô   s6   ø€ ÷ Añ AÙ!ðAÙ19×1HÑ1HðAá	×	%Ñ	%ñAr#   c                ó   € \        WV4      # ©N)Ú_RoutingDelegate)r'   r+   r,   s   &&&r    Ústart_requestÚRouter.start_requestÔ   s   € ô   °<Ó@Ð@r#   © N)	Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r(   r2   Ú__static_attributes__Ú__classdictcell__©r   s   @r    r   r   Ã   s   ø‡ € Ù$÷$ð $÷Aö Ar#   r   c                   ó6   a € ] tR t^Út o RtV 3R lR ltRtV tR# )ÚReversibleRouterzpAbstract router interface for routers that can handle named routes
and support reversing them to original urls.
c                ó:   <€ V ^8„  d   QhRS[ RS[RS[ R,          /# ©r   ÚnameÚargsr   N©Ústrr   )r   r   s   "€r    r!   ÚReversibleRouter.__annotate__ß   s&   ø€ ÷ $ñ $¡ð $©Cð $±C¸$µJñ $r#   c                ó   € \        4       h)zÙReturns url string for a given route name and arguments
or ``None`` if no match is found.

:arg str name: route name.
:arg args: url parameters.
:returns: parametrized url string for a given route name (or ``None``).
r%   )r'   rA   rB   s   &&*r    Úreverse_urlÚReversibleRouter.reverse_urlß   s   € ô "Ó#Ð#r#   r4   N)r5   r6   r7   r8   r9   rG   r:   r;   r<   s   @r    r>   r>   Ú   s   ø‡ € ñ÷$ö $r#   r>   c                   óz   a € ] tR t^êt o V 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltV 3R	 lR
 ltRt	V t
R# )r1   c                óD   <€ V ^8„  d   QhRS[ RS[RS[P                  RR/# )r   Úrouterr+   r,   r   N)r   r-   r	   r.   )r   r   s   "€r    r!   Ú_RoutingDelegate.__annotate__ë   s3   ø€ ÷ %ñ %Ùð%Ù+1ð%ÙAI×AXÑAXð%à	ñ%r#   c                ó8   € W n         W0n        R V n        Wn        R # r0   )r+   r,   ÚdelegaterK   )r'   rK   r+   r,   s   &&&&r    Ú__init__Ú_RoutingDelegate.__init__ë   s   € ð 'ÔØ(ÔØ=AˆŒØ$Žr#   c                ó”   <€ V ^8„  d   QhRS[ P                  S[ P                  ,          RS[ P                  RS[R,          R,          /# )r   Ú
start_lineÚheadersr   N)r	   ÚRequestStartLineÚResponseStartLineÚHTTPHeadersr   )r   r   s   "€r    r!   rL   ó   sN   ø€ ÷ Cñ Cá×-Ñ-±×0JÑ0JÕJðCñ ×%Ñ%ðCñ 
�4�˜4Õ	ñ	Cr#   c                óÀ  € \        V\        P                  4      '       g   Q h\        P                  ! V P                  V P
                  VVR 7      pV P                  P                  V4      V n        V P                  fG   \        P                  ! RVP                  VP                  4       \        V P                  4      V n        V P                  P                  W4      # ))Ú
connectionÚserver_connectionrR   rS   z$Delegate for %s %s request not found)Ú
isinstancer	   rT   r   r,   r+   rK   r(   rN   r   ÚdebugÚmethodÚpathÚ_DefaultMessageDelegateÚheaders_received)r'   rR   rS   r   s   &&& r    r_   Ú!_RoutingDelegate.headers_receivedó   s¯   € ô
 ˜*¤h×&?Ñ&?×@Ò@Ð@Ð@Ü×,Ò,Ø×(Ñ(Ø"×.Ñ.Ø!Øô	
ˆð Ÿ™×0Ñ0°Ó9ˆŒØ�=‰=Ò Ü�MŠMØ6Ø×!Ñ!Ø—‘ôô
 4°D×4EÑ4EÓFˆDŒMà�}‰}×-Ñ-¨jÓBÐBr#   c                óB   <€ V ^8„  d   QhRS[ RS[R,          R,          /# )r   Úchunkr   N)Úbytesr   )r   r   s   "€r    r!   rL     s$   ø€ ÷ 2ñ 2¡5ð 2©Y°t­_¸tÕ-Cñ 2r#   c                óX   € V P                   f   Q hV P                   P                  V4      # r0   )rN   Údata_received)r'   rb   s   &&r    re   Ú_RoutingDelegate.data_received  s'   € Ø�}‰}Ò(Ð(Ð(Ø�}‰}×*Ñ*¨5Ó1Ð1r#   c                ó   <€ V ^8„  d   QhRR/# ©r   r   Nr4   )r   r   s   "€r    r!   rL     s   ø€ ÷ ñ ˜ñ r#   c                óZ   € V P                   f   Q hV P                   P                  4        R # r0   )rN   Úfinish©r'   s   &r    rj   Ú_RoutingDelegate.finish  s"   € Ø�}‰}Ò(Ð(Ð(Ø�‰×ÑÖr#   c                ó   <€ V ^8„  d   QhRR/# rh   r4   )r   r   s   "€r    r!   rL     s   ø€ ÷ 0ñ 0 Tñ 0r#   c                óZ   € V P                   e   V P                   P                  4        R # R # r0   )rN   Úon_connection_closerk   s   &r    ro   Ú$_RoutingDelegate.on_connection_close  s!   € Ø�=‰=Ò$Ø�M‰M×-Ñ-Ö/ñ %r#   )rN   r,   rK   r+   N)r5   r6   r7   r8   rO   r_   re   rj   ro   r:   r;   r<   s   @r    r1   r1   ê   s9   ø‡ € ÷%ð %÷Cð C÷02ð 2÷ð ÷0ö 0r#   r1   c                   óD   a € ] tR tRt o V 3R lR ltV 3R lR ltRtV tR# )r^   i  c                ó8   <€ V ^8„  d   QhRS[ P                  RR/# )r   rX   r   N)r	   r.   )r   r   s   "€r    r!   Ú$_DefaultMessageDelegate.__annotate__  s!   ø€ ÷ %ñ %¡8×#:Ñ#:ð %¸tñ %r#   c                ó   € Wn         R # r0   ©rX   )r'   rX   s   &&r    rO   Ú _DefaultMessageDelegate.__init__  s   € Ø$Žr#   c                ó   <€ V ^8„  d   QhRR/# rh   r4   )r   r   s   "€r    r!   rs     s   ø€ ÷ !ñ !˜ñ !r#   c                óÄ   € V P                   P                  \        P                  ! R RR4      \        P                  ! 4       4       V P                   P                  4        R# )zHTTP/1.1i”  z	Not FoundN)rX   Úwrite_headersr	   rU   rV   rj   rk   s   &r    rj   Ú_DefaultMessageDelegate.finish  sD   € Ø�‰×%Ñ%Ü×&Ò& z°3¸ÓDÜ× Ò Ó"ô	
ð 	�‰×ÑÖ r#   ru   N)r5   r6   r7   r8   rO   rj   r:   r;   r<   s   @r    r^   r^     s   ø‡ € ÷%ð %÷!ö !r#   r^   ÚRuleÚMatcherc                   ó‚   a € ] tR tRt o RtRV 3R lR lltV 3R lR ltV 3R lR	 ltV 3R
 lR ltV 3R lR lt	Rt
V tR# )Ú
RuleRouteri1  z!Rule-based router implementation.Nc                ó2   <€ V ^8„  d   QhRS[ R,          RR/# ©r   ÚrulesNr   ©Ú	_RuleList)r   r   s   "€r    r!   ÚRuleRouter.__annotate__4  s    ø€ ÷ "ñ "™i¨$Õ.ð "¸$ñ "r#   c                óJ   € . V n         V'       d   V P                  V4       R# R# )a¹  Constructs a router from an ordered list of rules::

    RuleRouter([
        Rule(PathMatches("/handler"), Target),
        # ... more rules
    ])

You can also omit explicit `Rule` constructor and use tuples of arguments::

    RuleRouter([
        (PathMatches("/handler"), Target),
    ])

`PathMatches` is a default matcher, so the example above can be simplified::

    RuleRouter([
        ("/handler", Target),
    ])

In the examples above, ``Target`` can be a nested `Router` instance, an instance of
`~.httputil.HTTPServerConnectionDelegate` or an old-style callable,
accepting a request argument.

:arg rules: a list of `Rule` instances or tuples of `Rule`
    constructor arguments.
N)r�   Ú	add_rules)r'   r�   s   &&r    rO   ÚRuleRouter.__init__4  s   € ð6 "$ˆŒ
ßØ�N‰N˜5Ö!ñ r#   c                ó$   <€ V ^8„  d   QhRS[ RR/# )r   r�   r   Nr‚   )r   r   s   "€r    r!   r„   S  s   ø€ ÷ 7ñ 7™yð 7¨Tñ 7r#   c                ó^  € V F¦  p\        V\        \        34      '       d^   \        V4      R9   g   Q h\        V^ ,          \        4      '       d&   \        \        V^ ,          4      .VR,          O5!  pM	\        V!  pV P                  P                  V P                  V4      4       K¨  	  R# )z‹Appends new rules to the router.

:arg rules: a list of Rule instances (or tuples of arguments, which are
    passed to Rule constructor).
ºé   NNN)r   é   é   )
rZ   ÚtupleÚlistÚlenr   r{   ÚPathMatchesr�   ÚappendÚprocess_rule)r'   r�   Úrules   && r    r†   ÚRuleRouter.add_rulesS  s„   € ó ˆDÜ˜$¤¬ ×.Ò.Ü˜4“y IÔ-Ð-Ð-Ü˜d 1�g¤×7Ò7Ü¤¨D°­GÓ 4Ð@°t¸BµxÓ@‘Dä ™;�Dà�J‰J×Ñ˜d×/Ñ/°Ó5Ö6ó r#   c                ó"   <€ V ^8„  d   QhRRRR/# ©r   r”   r{   r   r4   )r   r   s   "€r    r!   r„   c  s   ø€ ÷ ñ  ð ¨Fñ r#   c                ó   € V# )z—Override this method for additional preprocessing of each rule.

:arg Rule rule: a rule to be processed.
:returns: the same or modified Rule instance.
r4   )r'   r”   s   &&r    r“   ÚRuleRouter.process_rulec  s	   € ð ˆr#   c                ób   <€ V ^8„  d   QhRS[ P                  RS[RS[ P                  R,          /# r   r   )r   r   s   "€r    r!   r„   k  s6   ø€ ÷ ñ Ù×1Ñ1ðÙ=@ðá	×	%Ñ	%¨Õ	,ñr#   c                óü   € V P                    Fk  pVP                  P                  V4      pVf   K$  VP                  '       d   VP                  VR&   V P                  ! VP
                  V3/ VB pVf   Ki  Vu # 	  R # )NÚtarget_kwargs)r�   ÚmatcherÚmatchrœ   Úget_target_delegateÚtarget)r'   r   r   r”   Útarget_paramsrN   s   &&,   r    r(   ÚRuleRouter.find_handlerk  s{   € ð —J”JˆDØ ŸL™L×.Ñ.¨wÓ7ˆMØÔ(Ø×%×%Ð%Ø59×5GÑ5G�M /Ñ2à×3Ò3Ø—K‘K ñØ,9ñ�ð Ô'Ø#’Oñ ñ r#   c          	      óh   <€ V ^8„  d   QhRS[ RS[P                  RS[ RS[P                  R,          /# )r   r    r   r¡   r   N)r   r	   r   r   )r   r   s   "€r    r!   r„   }  s>   ø€ ÷ ñ ÙðÙ$,×$>Ñ$>ðÙQTðá	×	%Ñ	%¨Õ	,ñr#   c                ó†  € \        V\        4      '       d   VP                  ! V3/ VB # \        V\        P                  4      '       d7   VP
                  f   Q hVP                  VP                  VP
                  4      # \        V4      '       d1   VP
                  f   Q h\        \        V3/ VB VP
                  4      # R# )ax  Returns an instance of `~.httputil.HTTPMessageDelegate` for a
Rule's target. This method is called by `~.find_handler` and can be
extended to provide additional target types.

:arg target: a Rule's target.
:arg httputil.HTTPServerRequest request: current request.
:arg target_params: additional parameters that can be useful
    for `~.httputil.HTTPMessageDelegate` creation.
N)rZ   r   r(   r	   ÚHTTPServerConnectionDelegaterX   r2   rY   Úcallabler   r   )r'   r    r   r¡   s   &&&,r    rŸ   ÚRuleRouter.get_target_delegate}  s¯   € ô �fœf×%Ò%Ø×&Ò& wÑ@°-Ñ@Ð@ä˜¤× EÑ E×FÒFØ×%Ñ%Ò1Ð1Ð1Ø×'Ñ'¨×(AÑ(AÀ7×CUÑCUÓVÐVä�f×ÒØ×%Ñ%Ò1Ð1Ð1Ü#Ü˜Ñ0 -Ñ0°'×2DÑ2Dóð ñ r#   )r�   r0   )r5   r6   r7   r8   r9   rO   r†   r“   r(   rŸ   r:   r;   r<   s   @r    r~   r~   1  s:   ø‡ € Ù+÷"ò "÷>7ð 7÷ ð ÷ð ÷$ö r#   r~   c                   óp   a a€ ] tR tRt oRtR
V3R lV 3R llltV3R lV 3R lltV3R lR ltR	tVt	V ;t
# )ÚReversibleRuleRouteri™  zþA rule-based router that implements ``reverse_url`` method.

Each rule added to this router may have a ``name`` attribute that can be
used to reconstruct an original uri. The actual reconstruction takes place
in a rule's matcher (see `Matcher.reverse`).
c                ó2   <€ V ^8„  d   QhRS[ R,          RR/# r€   r‚   )r   r   s   "€r    r!   Ú!ReversibleRuleRouter.__annotate__¡  s    ø€ ÷  ñ  ™i¨$Õ.ð  ¸$ñ  r#   c                ó4   <€ / V n         \        SV `	  V4       R # r0   )Únamed_rulesÚsuperrO   )r'   r�   Ú	__class__s   &&€r    rO   ÚReversibleRuleRouter.__init__¡  s   ø€ Ø+-ˆÔÜ‰Ñ˜Ör#   c                ó"   <€ V ^8„  d   QhRRRR/# r—   r4   )r   r   s   "€r    r!   r«   ¥  s   ø€ ÷ 
ñ 
 ð 
¨Fñ 
r#   c                óò   <€ \         SV `  V4      pVP                  '       dU   VP                  V P                  9   d"   \        P
                  ! R VP                  4       WP                  VP                  &   V# )z4Multiple handlers named %s; replacing previous value)r®   r“   rA   r­   r   Úwarning)r'   r”   r¯   s   &&€r    r“   Ú!ReversibleRuleRouter.process_rule¥  s[   ø€ Ü‰wÑ# DÓ)ˆà�9�9ˆ9Ø�y‰y˜D×,Ñ,Ô,Ü—’ØJÈDÏIÉIôð +/×Ñ˜TŸY™YÑ'àˆr#   c                ó:   <€ V ^8„  d   QhRS[ RS[RS[ R,          /# r@   rC   )r   r   s   "€r    r!   r«   ±  s&   ø€ ÷ 
ñ 
¡ð 
©Cð 
±C¸$µJñ 
r#   c                ó2  € WP                   9   d,   V P                   V,          P                  P                  ! V!  # V P                   FK  p\	        VP
                  \        4      '       g   K%  VP
                  P                  ! V.VO5!  pVf   KI  Vu # 	  R # r0   )r­   r�   Úreverser�   rZ   r    r>   rG   )r'   rA   rB   r”   Úreversed_urls   &&*  r    rG   Ú ReversibleRuleRouter.reverse_url±  sz   € Ø×#Ñ#Ô#Ø×#Ñ# DÕ)×1Ñ1×9Ò9¸4Ñ@Ð@à—J”JˆDÜ˜$Ÿ+™+Ô'7×8Ô8Ø#Ÿ{™{×6Ò6°tÐC¸dÓC�ØÔ+Ø'Ò'ñ	 ñ r#   )r­   r0   )r5   r6   r7   r8   r9   rO   r“   rG   r:   r;   Ú__classcell__©r¯   r   s   @@r    r©   r©   ™  s-   ù‡ € ñ÷ õ  ÷
ó 
÷
÷ 
ð 
r#   r©   c                   ó^   a € ] tR tRt o RtRV 3R lR lltV 3R lR ltV 3R lR	 ltR
tV t	R# )r{   i¾  zA routing rule.Nc          
      óf   <€ V ^8„  d   QhRRRS[ RS[S[S[ 3,          R,          RS[R,          RR/# )r   r�   r|   r    rœ   NrA   r   )r   ÚdictrD   )r   r   s   "€r    r!   ÚRule.__annotate__Á  sN   ø€ ÷ ñ àðñ ðñ ™C¡˜H•~¨Õ,ð	ñ
 �D�jðð 
ñr#   c                óŽ   € \        V\        4      '       d   \        V4      pWn        W n        V'       d   TM/ V n        W@n        R# )aô  Constructs a Rule instance.

:arg Matcher matcher: a `Matcher` instance used for determining
    whether the rule should be considered a match for a specific
    request.
:arg target: a Rule's target (typically a ``RequestHandler`` or
    `~.httputil.HTTPServerConnectionDelegate` subclass or even a nested `Router`,
    depending on routing implementation).
:arg dict target_kwargs: a dict of parameters that can be useful
    at the moment of target instantiation (for example, ``status_code``
    for a ``RequestHandler`` subclass). They end up in
    ``target_params['target_kwargs']`` of `RuleRouter.get_target_delegate`
    method.
:arg str name: the name of the rule that can be used to find it
    in `ReversibleRouter.reverse_url` implementation.
N)rZ   rD   r   r�   r    rœ   rA   )r'   r�   r    rœ   rA   s   &&&&&r    rO   ÚRule.__init__Á  s8   € ô. �fœc×"Ò"ô # 6Ó*ˆFà 'ŒØŒß.;™]ÀˆÔØŽ	r#   c                ó4   <€ V ^8„  d   QhRS[ RS[R,          /# ©r   rB   r   N©r   rD   )r   r   s   "€r    r!   r¿   â  s   ø€ ÷ +ñ +™Sð +¡S¨4¥Zñ +r#   c                ó6   € V P                   P                  ! V!  # r0   )r�   r·   ©r'   rB   s   &*r    r·   ÚRule.reverseâ  s   € Ø�|‰|×#Ò# TÑ*Ð*r#   c                ó    <€ V ^8„  d   QhRS[ /# ©r   r   ©rD   )r   r   s   "€r    r!   r¿   å  ó   ø€ ÷ 
ñ 
™#ñ 
r#   c                ó¤   € R P                  V P                  P                  V P                  V P                  V P
                  V P                  4      # ©z${}({!r}, {}, kwargs={!r}, name={!r}))r   r¯   r5   r�   r    rœ   rA   rk   s   &r    Ú__repr__ÚRule.__repr__å  s@   € Ø5×<Ñ<Ø�N‰N×#Ñ#Ø�L‰LØ�K‰KØ×ÑØ�I‰Ió
ð 	
r#   )r�   rA   r    rœ   ©NN)
r5   r6   r7   r8   r9   rO   r·   rÎ   r:   r;   r<   s   @r    r{   r{   ¾  s'   ø‡ € Ù÷ò ÷B+ð +÷
ö 
r#   c                   óH   a € ] tR tRt o RtV 3R lR ltV 3R lR ltRtV tR# )	r|   iï  z*Represents a matcher for request features.c                ó^   <€ V ^8„  d   QhRS[ P                  RS[S[S[3,          R,          /# ©r   r   r   N©r	   r   r¾   rD   r   )r   r   s   "€r    r!   ÚMatcher.__annotate__ò  s.   ø€ ÷ 
$ñ 
$™X×7Ñ7ð 
$¹DÁÁcÀ½NÈTÕ<Qñ 
$r#   c                ó   € \        4       h)aù  Matches current instance against the request.

:arg httputil.HTTPServerRequest request: current HTTP request
:returns: a dict of parameters to be passed to the target handler
    (for example, ``handler_kwargs``, ``path_args``, ``path_kwargs``
    can be passed for proper `~.web.RequestHandler` instantiation).
    An empty dict is a valid (and common) return value to indicate a match
    when the argument-passing features are not used.
    ``None`` must be returned to indicate that there is no match.r%   ©r'   r   s   &&r    rž   ÚMatcher.matchò  s   € ô "Ó#Ð#r#   c                ó4   <€ V ^8„  d   QhRS[ RS[R,          /# rÃ   rÄ   )r   r   s   "€r    r!   rÕ   þ  s   ø€ ÷ ñ ™Sð ¡S¨4¥Zñ r#   c                ó   € R# )zEReconstructs full url from matcher instance and additional arguments.Nr4   rÆ   s   &*r    r·   ÚMatcher.reverseþ  s   € ár#   r4   N)	r5   r6   r7   r8   r9   rž   r·   r:   r;   r<   s   @r    r|   r|   ï  s   ø‡ € Ù4÷
$ð 
$÷ö r#   c                   ó6   a € ] tR tRt o RtV 3R lR ltRtV tR# )Ú
AnyMatchesi  zMatches any request.c                ó^   <€ V ^8„  d   QhRS[ P                  RS[S[S[3,          R,          /# rÓ   rÔ   )r   r   s   "€r    r!   ÚAnyMatches.__annotate__  s.   ø€ ÷ ñ ™X×7Ñ7ð ¹DÁÁcÀ½NÈTÕ<Qñ r#   c                ó   € / # r0   r4   r×   s   &&r    rž   ÚAnyMatches.match  s   € Øˆ	r#   r4   N)r5   r6   r7   r8   r9   rž   r:   r;   r<   s   @r    rÝ   rÝ     s   ø‡ € Ù÷ö r#   rÝ   c                   óH   a € ] tR tRt o RtV 3R lR ltV 3R lR ltRtV tR# )	ÚHostMatchesi
  z@Matches requests from hosts specified by ``host_pattern`` regex.c                ó4   <€ V ^8„  d   QhRS[ S[,          RR/# )r   Úhost_patternr   N©rD   r   )r   r   s   "€r    r!   ÚHostMatches.__annotate__  s   ø€ ÷ -ñ -¡S©7¥]ð -°tñ -r#   c                ó¸   € \        V\        4      '       d>   VP                  R 4      '       g
   VR ,          p\        P                  ! V4      V n        R# Wn        R# )Ú$N)rZ   r   ÚendswithÚreÚcompilerå   )r'   rå   s   &&r    rO   ÚHostMatches.__init__  sA   € Ü�l¤O×4Ò4Ø×(Ñ(¨×-Ò-Ø Õ#�Ü "§
¢
¨<Ó 8ˆDÖà ,Ör#   c                ó^   <€ V ^8„  d   QhRS[ P                  RS[S[S[3,          R,          /# rÓ   rÔ   )r   r   s   "€r    r!   rç     s.   ø€ ÷ ñ ™X×7Ñ7ð ¹DÁÁcÀ½NÈTÕ<Qñ r#   c                ó`   € V P                   P                  VP                  4      '       d   / # R # r0   )rå   rž   Ú	host_namer×   s   &&r    rž   ÚHostMatches.match  s'   € Ø×Ñ×"Ñ" 7×#4Ñ#4×5Ò5ØˆIár#   )rå   N©	r5   r6   r7   r8   r9   rO   rž   r:   r;   r<   s   @r    rã   rã   
  s   ø‡ € ÙJ÷-ð -÷ö r#   rã   c                   óH   a € ] tR tRt o RtV 3R lR ltV 3R lR ltRtV tR# )	ÚDefaultHostMatchesi  z„Matches requests from host that is equal to application's default_host.
Always returns no match if ``X-Real-Ip`` header is present.
c                ó*   <€ V ^8„  d   QhRS[ RS[RR/# )r   Úapplicationrå   r   N)r   r   )r   r   s   "€r    r!   ÚDefaultHostMatches.__annotate__!  s"   ø€ ÷ )ñ )¡Cð )±wð )À4ñ )r#   c                ó   € Wn         W n        R # r0   ©rö   rå   )r'   rö   rå   s   &&&r    rO   ÚDefaultHostMatches.__init__!  s   € Ø&ÔØ(Ör#   c                ó^   <€ V ^8„  d   QhRS[ P                  RS[S[S[3,          R,          /# rÓ   rÔ   )r   r   s   "€r    r!   r÷   %  s.   ø€ ÷ ñ ™X×7Ñ7ð ¹DÁÁcÀ½NÈTÕ<Qñ r#   c                ó–   € R VP                   9  d8   V P                  P                  V P                  P                  4      '       d   / # R# )z	X-Real-IpN)rS   rå   rž   rö   Údefault_hostr×   s   &&r    rž   ÚDefaultHostMatches.match%  s9   € à˜gŸo™oÔ-Ø× Ñ ×&Ñ& t×'7Ñ'7×'DÑ'D×EÒEØ�	Ùr#   rù   Nrò   r<   s   @r    rô   rô     s   ø‡ € ñ÷)ð )÷ö r#   rô   c                   ól   a € ] tR tRt o RtV 3R lR ltV 3R lR ltV 3R lR ltV 3R	 lR
 ltRt	V t
R# )r‘   i-  z@Matches requests with paths specified by ``path_pattern`` regex.c                ó4   <€ V ^8„  d   QhRS[ S[,          RR/# )r   Úpath_patternr   Nræ   )r   r   s   "€r    r!   ÚPathMatches.__annotate__0  s   ø€ ÷ <ñ <¡S©7¥]ð <°tñ <r#   c                ó¨  € \        V\        4      '       d=   VP                  R 4      '       g
   VR ,          p\        P                  ! V4      V n        MWn        \        V P
                  P                  4      ^ V P
                  P                  39   g#   Q RV P
                  P                  ,          4       hV P                  4       w  V n        V n        R# )ré   zDgroups in url regexes must either be all named or all positional: %rN)rZ   r   rê   rë   rì   Úregexr�   Ú
groupindexÚgroupsÚpatternÚ_find_groupsÚ_pathÚ_group_count)r'   r  s   &&r    rO   ÚPathMatches.__init__0  s£   € Ü�l¤O×4Ò4Ø×(Ñ(¨×-Ò-Ø Õ#�ÜŸš LÓ1ˆD�Jà%ŒJä�4—:‘:×(Ñ(Ó)¨a°·±×1BÑ1BÐ-CÔCð 	
ðØ#Ÿz™z×1Ñ1õ2ó	
ÐCð
 )-×(9Ñ(9Ó(;Ñ%ˆŒ
�DÖ%r#   c                ó^   <€ V ^8„  d   QhRS[ P                  RS[S[S[3,          R,          /# rÓ   rÔ   )r   r   s   "€r    r!   r  ?  s2   ø€ ÷ Bñ B™X×7Ñ7ð B¹DÁÁcÀ½NÈTÕ<Qñ Br#   c                óÜ  € V P                   P                  VP                  4      pVf   R # V P                   P                  '       g   / # . p/ pV P                   P                  '       dF   VP                  4       P                  4        UUu/ uF  w  rV\        V4      \        V4      bK  	  pppM(VP                  4        Uu. uF  p\        V4      NK  	  pp\        W4R7      # u uppi u upi )N)Ú	path_argsÚpath_kwargs)
r  rž   r]   r  r  Ú	groupdictÚitemsrD   Ú_unquote_or_noner¾   )r'   r   rž   r  r  ÚkÚvÚss   &&      r    rž   ÚPathMatches.match?  sË   € Ø—
‘
× Ñ  §¡Ó.ˆØŠ=ÙØ�z‰z× × Ð ØˆIà!#ˆ	Ø(*ˆð �:‰:× × Ð à:?¿/¹/Ó:K×:QÑ:QÔ:SôÙ:S±°”�A“Ô(¨Ó+Ò+Ñ:Sð ñ ˆKð 7<·l±l´nÓE±n°Ô)¨!Ö,±nˆIÐEä˜iÔAÐAùóùò Fs   Â C#ÃC)c                ó4   <€ V ^8„  d   QhRS[ RS[R,          /# rÃ   rÄ   )r   r   s   "€r    r!   r  V  s   ø€ ÷ 2ñ 2™Sð 2¡S¨4¥Zñ 2r#   c                óÌ  € V P                   f'   \        RV P                  P                  ,           4      h\	        V4      V P
                  8X  g   Q R4       h\	        V4      '       g   V P                   # . pV FO  p\        V\        \        34      '       g   \        V4      pVP                  \        \        V4      RR7      4       KQ  	  V P                   \        V4      ,          # )NzCannot reverse url regex z&required number of arguments not foundF)Úplus)r	  Ú
ValueErrorr  r  r�   r
  rZ   r   rc   rD   r’   r
   r   rŽ   )r'   rB   Úconverted_argsÚas   &*  r    r·   ÚPathMatches.reverseV  s·   € Ø�:‰:ÒÜÐ8¸4¿:¹:×;MÑ;MÕMÓNÐNÜ�4‹y˜D×-Ñ-Ô-ð 	
Ø7ó	
Ð-ô �4�yŠyØ—:‘:ÐØˆÛˆAÜ˜a¤,´Ð!6×7Ò7Ü˜“F�Ø×!Ñ!¤*¬T°!«W¸5Ô"AÖBñ ð �z‰zœE .Ó1Õ1Ð1r#   c                óR   <€ V ^8„  d   QhRS[ S[R,          S[R,          3,          /# rh   )rŽ   rD   Úint)r   r   s   "€r    r!   r  e  s&   ø€ ÷ &2ñ &2™e¡C¨$¥J±°dµ
Ð$:Õ;ñ &2r#   c                ó®  € V P                   P                  pVP                  R4      '       d
   VR,          pVP                  R4      '       d   VRR	 pV P                   P                  VP                  R4      8w  d   R
# . pVP                  R4       Fp  pRV9   dJ   VP                  R4      pV^ 8¼  d0    \        W4^,           R 4      pTP                  RT,           4       KQ  KS   \        V4      pTP                  T4       Kr  	  RP                  V4      V P                   P                  3#   \         d    R
u u # i ; i  \         d    R
u u # i ; i)zžReturns a tuple (reverse string, group count) for a url.

For example: Given the url pattern /([0-9]{4})/([a-z-]+)/, this method
would return ('/%s/%s/', 2).
Ú^rŠ   ré   NÚ(Ú)z%sÚ éÿÿÿÿrÐ   )r  r  Ú
startswithrê   r  ÚcountÚsplitÚindexr   r  r’   Újoin)r'   r  ÚpiecesÚfragmentÚ	paren_locÚunescaped_fragments   &     r    r  ÚPathMatches._find_groupse  sA  € ð —*‘*×$Ñ$ˆØ×Ñ˜c×"Ò"Ø˜b•kˆGØ×Ñ˜C× Ò Ø˜c˜r�lˆGà�:‰:×Ñ §¡¨cÓ 2Ô2ð ÐàˆØŸ™ cÖ*ˆHØ�hŒØ$ŸN™N¨3Ó/�	Ø ”>ð,Ü-8¸ÈaÅ-À/Ð9RÓ-SÐ*ð
 —M‘M $Ð);Õ";Ö<ñ "ð(Ü)4°XÓ)>Ð&ð
 —‘Ð0Ö1ñ% +ð( �w‰w�v‹ §
¡
× 1Ñ 1Ð1Ð1øô &ô ,ð  ,Ô+ð,ûô "ô (ð (Ô'ð(ús$   Â5D-Ã&EÄ-D?Ä>D?ÅEÅE)r
  r	  r  N)r5   r6   r7   r8   r9   rO   rž   r·   r  r:   r;   r<   s   @r    r‘   r‘   -  s2   ø‡ € ÙJ÷<ð <÷Bð B÷.2ð 2÷&2ö &2r#   r‘   c                   óX   a a€ ] tR tRt oRtRV3R lV 3R llltV3R lR ltRtVtV ;t	# )	ÚURLSpeciŽ  z½Specifies mappings between URLs and handlers.

.. versionchanged: 4.5
   `URLSpec` is now a subclass of a `Rule` with `PathMatches` matcher and is preserved for
   backwards compatibility.
c          
      óx   <€ V ^8„  d   QhRS[ S[,          RS[RS[S[ S[3,          R,          RS[ R,          RR/# )r   r  Úhandlerr   NrA   r   )rD   r   r   r¾   )r   r   s   "€r    r!   ÚURLSpec.__annotate__–  sR   ø€ ÷ ñ á‘w•ðñ ðñ ‘S™#�X• Õ%ð	ñ
 �D�jðð 
ñr#   c                óŽ   <€ \        V4      p\        SV `	  WRW44       VP                  V n        V P                  V n        W0n        R# )a+  Parameters:

* ``pattern``: Regular expression to be matched. Any capturing
  groups in the regex will be passed in to the handler's
  get/post/etc methods as arguments (by keyword if named, by
  position if unnamed. Named and unnamed capturing groups
  may not be mixed in the same rule).

* ``handler``: `~.web.RequestHandler` subclass to be invoked.

* ``kwargs`` (optional): A dictionary of additional arguments
  to be passed to the handler's constructor.

* ``name`` (optional): A name for this handler.  Used by
  `~.web.Application.reverse_url`.

N)r‘   r®   rO   r  r    Úhandler_classr   )r'   r  r3  r   rA   r�   r¯   s   &&&&& €r    rO   ÚURLSpec.__init__–  s:   ø€ ô0 ˜gÓ&ˆÜ‰Ñ˜¨6Ô8à—]‘]ˆŒ
Ø!Ÿ[™[ˆÔØŽr#   c                ó    <€ V ^8„  d   QhRS[ /# rÉ   rÊ   )r   r   s   "€r    r!   r4  µ  rË   r#   c                ó¸   € R P                  V P                  P                  V P                  P                  V P
                  V P                  V P                  4      # rÍ   )r   r¯   r5   r  r  r6  r   rA   rk   s   &r    rÎ   ÚURLSpec.__repr__µ  sF   € Ø5×<Ñ<Ø�N‰N×#Ñ#Ø�J‰J×ÑØ×ÑØ�K‰KØ�I‰Ió
ð 	
r#   )r6  r   r  rÐ   )
r5   r6   r7   r8   r9   rO   rÎ   r:   r;   rº   r»   s   @@r    r1  r1  Ž  s#   ù‡ € ñ÷õ ÷>
÷ 
ð 
r#   r1  c                ó0   € V ^8„  d   QhR\         R\        /# )r   r  r   ©rD   rc   )r   s   "r    r!   r!   À  s   € ÷ 	ñ 	œð 	¤ñ 	r#   c                 ó   € R # r0   r4   ©r  s   &r    r  r  ¿  ó   € ár#   c                ó    € V ^8„  d   QhRRRR/# ©r   r  Nr   r4   )r   s   "r    r!   r!   Å  s   € ÷ 	ñ 	˜ð 	 ñ 	r#   c                 ó   € R # r0   r4   r>  s   &r    r  r  Ä  r?  r#   c                óL   € V ^8„  d   QhR\         R,          R\        R,          /# rA  r<  )r   s   "r    r!   r!   É  s"   € ÷ 	6ñ 	6œ˜d�
ð 	6¤u¨t¥|ñ 	6r#   c                ó*   € V f   V # \        V RRR7      # )z©None-safe wrapper around url_unescape to handle unmatched optional
groups correctly.

Note that args are passed as bytes so the handler can decide what
encoding to use.
NF)Úencodingr  )r   r>  s   &r    r  r  É  s   € ð 	‚yØˆÜ˜ D¨uÔ5Ð5r#   )0r9   rë   Úcollections.abcr   r   Ú	functoolsr   r   Útypingr   r   r   Útornador	   Útornado.escaper
   r   r   Útornado.httpserverr   Útornado.logr   Útornado.utilr   r   r   r   r¥   r   r>   r   r1   r^   r�   rŽ   rD   r¾   rƒ   r~   r©   r{   r|   rÝ   rã   rô   r‘   r1  r  r4   r#   r    Ú<module>rN     s�  ðñaóF 
ß /Ý Ý ÷ñ õ ß 9Ñ 9Ý /Ý ß RÓ RôAˆX×2Ñ2ô Aô.$�vô $ô +0�x×3Ñ3ô +0ô\	!˜h×:Ñ:ô 	!ð Ø	ØØˆS�	Øˆe�C˜�NÕ# SÐ(Õ)Øˆe�C˜�NÕ# S¨$¨s°C¨x­.Ð8Õ9Øˆe�C˜�NÕ# S¨$¨s°C¨x­.¸#Ð=Õ>ð		@õõ€	ôe�ô eôP"Ð+¨Zô "÷J.
ñ .
÷bñ ô(�ô ô�'ô ô$˜ô ô"^2�'ô ^2ôB.
ˆdô .
ðb 
ô	ó 
ð	ð 
ô	ó 
ð	÷	6r#   