ó
`¾Tc        	   @   s}  d  Z  d d l Z d d l m Z m Z m Z m Z m Z m Z m	 Z	 m
 Z
 m Z d d l m Z m Z d d l m Z m Z d d l m Z e j d ƒ Z d Z d	 Z e d
 „  e Dƒ ƒ Z e e d d d d d d g ƒ ƒ Z d e f d „  ƒ  YZ e d e e f d „  ƒ  Yƒ Z d e e f d „  ƒ  YZ d d „ Z d „  Z  d d „ Z! d e# d „ Z$ d d d d d „ Z% d d d d  „ Z& d! „  Z' d d" d d# „ Z( d d" d$ „ Z) d d% „ Z* d d" d& „ Z+ d d e, d' „ Z- d e, e# d" d( d d) „ Z. d e, e# d" d( d d e, d* „ Z/ d+ „  Z0 d e, e, d d( d, „ Z1 d d e, e, d d( d- „ Z2 e# d. „ Z3 d/ e f d0 „  ƒ  YZ4 d S(1   sß   
    werkzeug.urls
    ~~~~~~~~~~~~~

    This module implements various URL related functions.

    :copyright: (c) 2014 by the Werkzeug Team, see AUTHORS for more details.
    :license: BSD, see LICENSE for more details.
iÿÿÿÿN(	   t	   text_typet   PY2t
   to_unicodet	   to_nativet   implements_to_stringt   try_coerce_nativet   normalize_string_tuplet   make_literal_wrappert   fix_tuple_repr(   t   _encode_idnat   _decode_idna(   t	   MultiDictt   iter_multi_items(   t
   namedtuples   ^[a-zA-Z0-9+-.]+$sB   abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_.-+t   0123456789ABCDEFabcdefc         c   s?   |  ]5 } t  D]( } | | j ƒ  t | | d  ƒ f Vq q d S(   i   N(   t
   _hexdigitst   encodet   int(   t   .0t   at   b(    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/urls.pys	   <genexpr>   s   t	   _URLTuplet   schemet   netloct   patht   queryt   fragmentt	   _URLMixinc           B   sà   e  Z d Z d  „  Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z	 e d „  ƒ Z
 e d „  ƒ Z e d „  ƒ Z d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   c         K   s   |  j  |   S(   s†   Return an URL with the same values, except for those parameters
        given new values by whichever keyword arguments are specified.(   t   _replace(   t   selft   kwargs(    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/urls.pyt   replace*   s    c         C   s   |  j  ƒ  d S(   s¹   The host part of the URL if available, otherwise `None`.  The
        host is either the hostname or the IP address mentioned in the
        URL.  It will not contain the port.
        i    (   t   _split_host(   R   (    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/urls.pyt   host/   s    c         C   sC   |  j  } | d k	 r3 t | t ƒ r3 t | ƒ } n  t | d d ƒ S(   s   Works exactly like :attr:`host` but will return a result that
        is restricted to ASCII.  If it finds a netloc that is not ASCII
        it will attempt to idna decode it.  This is useful for socket
        operations when the URL might include internationalized characters.
        t   asciit   ignoreN(   R!   t   Nonet
   isinstanceR    R	   R   (   R   t   rv(    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/urls.pyt
   ascii_host7   s    	c         C   s^   y@ t  t |  j ƒ  d ƒ ƒ } d | k o6 d k n r? | SWn t t f k
 rY n Xd S(   s}   The port in the URL as an integer if it was present, `None`
        otherwise.  This does not fill in default ports.
        i   i    iÿÿ  N(   R   R   R    t
   ValueErrort	   TypeError(   R   R&   (    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/urls.pyt   portC   s    c         C   s   |  j  ƒ  d S(   sS   The authentication part in the URL if available, `None`
        otherwise.
        i    (   t   _split_netloc(   R   (    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/urls.pyt   authO   s    c         C   s*   |  j  ƒ  d } | d k	 r& t | ƒ Sd S(   s‹   The username if it was part of the URL, `None` otherwise.
        This undergoes URL decoding and will always be a unicode string.
        i    N(   t   _split_authR$   t   _url_unquote_legacy(   R   R&   (    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/urls.pyt   usernameV   s    c         C   s   |  j  ƒ  d S(   s   The username if it was part of the URL, `None` otherwise.
        Unlike :attr:`username` this one is not being decoded.
        i    (   R-   (   R   (    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/urls.pyt   raw_username_   s    c         C   s*   |  j  ƒ  d } | d k	 r& t | ƒ Sd S(   s‹   The password if it was part of the URL, `None` otherwise.
        This undergoes URL decoding and will always be a unicode string.
        i   N(   R-   R$   R.   (   R   R&   (    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/urls.pyt   passwordf   s    c         C   s   |  j  ƒ  d S(   s   The password if it was part of the URL, `None` otherwise.
        Unlike :attr:`password` this one is not being decoded.
        i   (   R-   (   R   (    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/urls.pyt   raw_passwordo   s    c         O   s   t  |  j | | Ž S(   sØ   Decodes the query part of the URL.  Ths is a shortcut for
        calling :func:`url_decode` on the query argument.  The arguments and
        keyword arguments are forwarded to :func:`url_decode` unchanged.
        (   t
   url_decodeR   (   R   t   argsR   (    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/urls.pyt   decode_queryv   s    c         O   s   t  t |  | | Ž ƒ S(   s©   Joins this URL with another one.  This is just a convenience
        function for calling into :meth:`url_join` and then parsing the
        return value again.
        (   t	   url_parset   url_join(   R   R4   R   (    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/urls.pyt   join}   s    c         C   s
   t  |  ƒ S(   sº   Returns a URL string or bytes depending on the type of the
        information stored.  This is just a convenience function
        for calling :meth:`url_unparse` for this URL.
        (   t   url_unparse(   R   (    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/urls.pyt   to_url„   s    c      
   C   sµ   t  |  j p d ƒ } d | k r. d | } n  |  j } | d k	 rV d | | f } n  d j t d t |  j pq d d ƒ t |  j p† d d ƒ g ƒ ƒ } | r± d | | f } n  | S(   s&   Decodes the netloc part into a string.t    t   :s   [%s]s   %s:%ds   /:%@s   %s@%sN(	   R
   R!   R*   R$   R8   t   filterR.   R0   R2   (   R   R&   R*   R,   (    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/urls.pyt   decode_netloc‹   s    	!c         C   s   t  t |  ƒ j d ƒ ƒ S(   s*  Returns a :class:`BytesURL` tuple that holds a URI.  This will
        encode all the information in the URL properly to ASCII using the
        rules a web browser would follow.

        It's usually more interesting to directly call :meth:`iri_to_uri` which
        will return a string.
        R"   (   R6   t
   iri_to_uriR   (   R   (    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/urls.pyt   to_uri_tupleœ   s    c         C   s   t  t |  ƒ ƒ S(   sS  Returns a :class:`URL` tuple that holds a IRI.  This will try
        to decode as much information as possible in the URL without
        losing information similar to how a web browser does it for the
        URL bar.

        It's usually more interesting to directly call :meth:`uri_to_iri` which
        will return a string.
        (   R6   t
   uri_to_iri(   R   (    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/urls.pyt   to_iri_tuple¦   s    	c         C   s5   |  j  |  j k r( |  j j |  j  d ƒ Sd  |  j f S(   Ni   (   t   _atR   t   splitR$   (   R   (    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/urls.pyR+   ±   s    c         C   sF   |  j  ƒ  d } | s d S|  j | k r3 | d  f S| j |  j d ƒ S(   Ni    i   (   NN(   R+   R$   t   _colonRD   (   R   R,   (    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/urls.pyR-   ¶   s    
c         C   sÅ   |  j  ƒ  d } | s d S| j |  j ƒ sX |  j | k rN | j |  j d ƒ S| d  f S| j |  j ƒ } | d k  r€ | d  f S| d | !} | | d } | j |  j ƒ r» | | d f S| d  f S(   Ni   i    (   NN(   R+   R$   t
   startswitht	   _lbracketRE   RD   t   findt	   _rbracket(   R   R&   t   idxR!   t   rest(    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/urls.pyR    ¾   s    

(    (   t   __name__t
   __module__t	   __slots__R   t   propertyR!   R'   R*   R,   R/   R0   R1   R2   R5   R8   R:   R>   R@   RB   R+   R-   R    (    (    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/urls.pyR   '   s&   								
			t   URLc           B   sM   e  Z d  Z d
 Z d Z d Z d Z d Z d „  Z d „  Z	 d d d	 „ Z
 RS(   s“   Represents a parsed URL.  This behaves like a regular tuple but
    also has some extra attributes that give further insight into the
    URL.
    t   @R<   t   [t   ]c         C   s
   |  j  ƒ  S(   N(   R:   (   R   (    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/urls.pyt   __str__ß   s    c         C   sÄ   |  j  p d } d | k r( d | } n  |  j } | d
 k	 rP d | | f } n  d j t d
 t |  j pk d d d d ƒ t |  j p† d d d d ƒ g ƒ ƒ } | r· d | | f } n  | j d	 ƒ S(   s6   Encodes the netloc part to an ASCII safe URL as bytes.R;   R<   s   [%s]s   %s:%ds   utf-8t   stricts   /:%s   %s@%sR"   N(	   R'   R*   R$   R8   R=   t	   url_quoteR0   R2   R   (   R   R&   R*   R,   (    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/urls.pyt   encode_netlocâ   s    	's   utf-8R   c         C   sU   t  |  j j d ƒ |  j ƒ  |  j j | | ƒ |  j j | | ƒ |  j j | | ƒ ƒ S(   s€   Encodes the URL to a tuple made out of bytes.  The charset is
        only being used for the path, query and fragment.
        R"   (   t   BytesURLR   R   RW   R   R   R   (   R   t   charsett   errors(    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/urls.pyR   ò   s    	(    (   RL   RM   t   __doc__RN   RC   RE   RG   RI   RT   RW   R   (    (    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/urls.pyRP   Ó   s   		RX   c           B   sM   e  Z d  Z d
 Z d Z d Z d Z d Z d „  Z d „  Z	 d d d	 „ Z
 RS(   s!   Represents a parsed URL in bytes.RQ   R<   RR   RS   c         C   s   |  j  ƒ  j d d ƒ S(   Ns   utf-8R   (   R:   t   decode(   R   (    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/urls.pyRT     s    c         C   s   |  j  S(   s&   Returns the netloc unchanged as bytes.(   R   (   R   (    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/urls.pyRW   
  s    s   utf-8R   c         C   sU   t  |  j j d ƒ |  j ƒ  |  j j | | ƒ |  j j | | ƒ |  j j | | ƒ ƒ S(   s‚   Decodes the URL to a tuple made out of strings.  The charset is
        only being used for the path, query and fragment.
        R"   (   RP   R   R\   R>   R   R   R   (   R   RY   RZ   (    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/urls.pyR\     s    	(    (   RL   RM   R[   RN   RC   RE   RG   RI   RT   RW   R\   (    (    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/urls.pyRX   ÿ   s   		R;   c         C   s  t  |  t ƒ r! |  j d ƒ }  n  t  | t ƒ rB | j d ƒ } n  t t | ƒ ƒ } t |  j d ƒ ƒ } t t | d ƒ ƒ } x„ | D]| } yH t | d  } | | k r´ t	 ƒ  ‚ n  | j
 | ƒ | j | d ƒ Wq… t	 k
 r | j d ƒ | j | ƒ q… Xq… Wt | ƒ S(   Ns   utf-8t   %R;   i   (   R%   R    R   t	   frozensett	   bytearrayt   iterRD   t   nextt
   _hextobytet   KeyErrort   appendt   extendt   bytes(   t   stringt   unsafet   bitst   resultt   itemt   char(    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/urls.pyt   _unquote_to_bytes  s$    c         c   s»   t  |  ƒ } | r' t | d | ƒ} n  x | D]… \ } } | d  k rL q. n  t | t ƒ ss t | ƒ j | ƒ } n  t | t ƒ sš t | ƒ j | ƒ } n  t | ƒ d t | ƒ Vq. Wd  S(   Nt   keyt   =(   R   t   sortedR$   R%   Rf   R    R   t   url_quote_plus(   t   objRY   t   encode_keyst   sortRn   t   iterablet   value(    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/urls.pyt   _url_encode_impl0  s    c         C   sK   y  t  |  d d d d d | ƒSWn$ t k
 rF t  |  d d d | ƒSXd  S(   NRY   s   utf-8RZ   RU   Rh   t   latin1(   t   url_unquotet   UnicodeError(   Rv   Rh   (    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/urls.pyR.   >  s
    c            sG  t  |  ƒ ‰  t |  t ƒ } | d k r6 ˆ  d ƒ } n  ˆ  d ƒ } } } |  j ˆ  d ƒ ƒ } | d k rØ t j t |  |  d d ƒƒ rØ |  | d } | s» t ‡  f d †  | Dƒ ƒ rØ |  |  j	 ƒ  | } }  qØ n  |  d  ˆ  d	 ƒ k r³t
 |  ƒ }	 xD ˆ  d
 ƒ D]6 }
 |  j |
 d ƒ } | d k rt |	 | ƒ }	 qqW|  d |	 !|  |	 } }  ˆ  d ƒ | k r}ˆ  d ƒ | k s¡ˆ  d ƒ | k r³ˆ  d ƒ | k r³t d ƒ ‚ q³n  | rìˆ  d ƒ |  k rì|  j ˆ  d ƒ d ƒ \ }  } n  ˆ  d ƒ |  k r|  j ˆ  d ƒ d ƒ \ }  } n  | r+t p.t } | | | |  | | ƒ S(   s  Parses a URL from a string into a :class:`URL` tuple.  If the URL
    is lacking a scheme it can be provided as second argument. Otherwise,
    it is ignored.  Optionally fragments can be stripped from the URL
    by setting `allow_fragments` to `False`.

    The inverse of this function is :func:`url_unparse`.

    :param url: the URL to parse.
    :param scheme: the default schema to use if the URL is schemaless.
    :param allow_fragments: if set to `False` a fragment will be removed
                            from the URL.
    R;   R<   i    RZ   R   i   c         3   s!   |  ] } | ˆ  d  ƒ k Vq d S(   t
   0123456789N(    (   R   t   c(   t   s(    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/urls.pys	   <genexpr>^  s    i   s   //s   /?#RR   RS   s   Invalid IPv6 URLt   #t   ?N(   R   R%   R    R$   RH   t
   _scheme_ret   matchR   t   anyt   lowert   lent   minR(   RD   RP   RX   (   t   urlR   t   allow_fragmentst   is_text_basedR   R   R   t   iRK   t   delimR|   t   wdelimt   result_type(    (   R}   sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/urls.pyR6   F  s4    +#$$!!s   utf-8RU   s   /:c         C   s  t  |  t t t f ƒ s' t |  ƒ }  n  t  |  t ƒ rK |  j | | ƒ }  n  t  | t ƒ ro | j | | ƒ } n  t  | t ƒ r“ | j | | ƒ } n  t t | ƒ t ƒ t t | ƒ ƒ } t ƒ  } xJ t |  ƒ D]< } | | k rñ | j | ƒ qÏ | j d | j d ƒ ƒ qÏ Wt	 t | ƒ ƒ S(   sD  URL encode a single string with a given encoding.

    :param s: the string to quote.
    :param charset: the charset to be used.
    :param safe: an optional sequence of safe characters.
    :param unsafe: an optional sequence of unsafe characters.

    .. versionadded:: 0.9.2
       The `unsafe` parameter was added.
    s   %%%02XR"   (
   R%   R    Rf   R_   R   R^   t   _always_safeRd   Re   R   (   Rg   RY   RZ   t   safeRh   R&   Rl   (    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/urls.pyRV   v  s    &	c         C   s&   t  |  | | | d d ƒ j d d ƒ S(   sä   URL encode a single string with the given encoding and convert
    whitespace to "+".

    :param s: The string to quote.
    :param charset: The charset to be used.
    :param safe: An optional sequence of safe characters.
    t    t   +(   RV   R   (   Rg   RY   RZ   RŽ   (    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/urls.pyRq   “  s    c         C   s  t  |  ƒ \ } } } } } t | ƒ } | d ƒ } | sT | r¦ | j | d ƒ ƒ r¦ | rƒ | d  | d ƒ k rƒ | d ƒ | } n  | d ƒ | p› | d ƒ | } n | r¹ | | 7} n  | rÖ | | d ƒ | } n  | ró | | d ƒ | } n  | r| | d ƒ | } n  | S(   sþ   The reverse operation to :meth:`url_parse`.  This accepts arbitrary
    as well as :class:`URL` tuples and returns a URL as a string.

    :param components: the parsed URL as tuple which should be converted
                       into a URL string.
    R;   t   /i   s   //R<   R   R~   (   R   R   RF   (   t
   componentsR   R   R   R   R   R}   R†   (    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/urls.pyR9   ž  s     !#R   c         C   s4   t  |  | ƒ } | d k	 r0 | j | | ƒ } n  | S(   s‚  URL decode a single string with a given encoding.  If the charset
    is set to `None` no unicode decoding is performed and raw bytes
    are returned.

    :param s: the string to unquote.
    :param charset: the charset of the query string.  If set to `None`
                    no unicode decoding will take place.
    :param errors: the error handling for the charset decoding.
    N(   Rm   R$   R\   (   Rg   RY   RZ   Rh   R&   (    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/urls.pyRy   ½  s    
c         C   sF   t  |  t ƒ r$ |  j d d ƒ }  n |  j d d ƒ }  t |  | | ƒ S(   s  URL decode a single string with the given `charset` and decode "+" to
    whitespace.

    Per default encoding errors are ignored.  If you want a different behavior
    you can set `errors` to ``'replace'`` or ``'strict'``.  In strict mode a
    :exc:`HTTPUnicodeError` is raised.

    :param s: The string to unquote.
    :param charset: the charset of the query string.  If set to `None`
                    no unicode decoding will take place.
    :param errors: The error handling for the `charset` decoding.
    u   +u    R   R   (   R%   R    R   Ry   (   R}   RY   RZ   (    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/urls.pyt   url_unquote_plusÍ  s    c         C   sp   t  t |  | d ƒ ƒ \ } } } } } t | | d d ƒ} t | | d d ƒ} t t | | | | | f ƒ ƒ S(   s  Sometimes you get an URL by a user that just isn't a real URL because
    it contains unsafe characters like ' ' and so on. This function can fix
    some of the problems in a similar way browsers handle data entered by the
    user:

    >>> url_fix(u'http://de.wikipedia.org/wiki/Elf (Begriffskl\xe4rung)')
    'http://de.wikipedia.org/wiki/Elf%20(Begriffskl%C3%A4rung)'

    :param s: the string with the URL to fix.
    :param charset: The target charset for the URL if the url was given as
                    unicode string.
    R   RŽ   s
   /%+$!*'(),s   :&%=+$!*'(),(   R6   R   RV   Rq   R   R9   (   R}   RY   R   R   R   t   qst   anchor(    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/urls.pyt   url_fixá  s    'c         C   s   t  |  t ƒ r t |  ƒ }  n  t t |  | ƒ ƒ }  t |  j | | d ƒ } t |  j | | d ƒ } t |  j | | d ƒ } t |  j	 |  j
 ƒ  | | | f ƒ S(   s$  
    Converts a URI in a given charset to a IRI.

    Examples for URI versus IRI:

    >>> uri_to_iri(b'http://xn--n3h.net/')
    u'http://\u2603.net/'
    >>> uri_to_iri(b'http://%C3%BCser:p%C3%A4ssword@xn--n3h.net/p%C3%A5th')
    u'http://\xfcser:p\xe4ssword@\u2603.net/p\xe5th'

    Query strings are left unchanged:

    >>> uri_to_iri('/?foo=24&x=%26%2f')
    u'/?foo=24&x=%26%2f'

    .. versionadded:: 0.6

    :param uri: The URI to convert.
    :param charset: The charset of the URI.
    :param errors: The error handling on decode.
    s   %/;?s   %;/?:@&=+,$(   R%   t   tupleR9   R6   R   Ry   R   R   R   R   R>   (   t   uriRY   RZ   R   R   R   (    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/urls.pyRA   ô  s    c   
      C   s  t  |  t ƒ r t |  ƒ }  n  | ry y> t |  ƒ } t |  ƒ j d ƒ } | j ƒ  | g k ra | SWqy t k
 ru qy Xn  t t |  | | ƒ ƒ }  |  j	 ƒ  j
 d ƒ } t |  j | | d ƒ } t |  j | | d ƒ } t |  j | | d ƒ }	 t t |  j | | | |	 f ƒ ƒ S(   s¶  
    Converts any unicode based IRI to an acceptable ASCII URI. Werkzeug always
    uses utf-8 URLs internally because this is what browsers and HTTP do as
    well. In some places where it accepts an URL it also accepts a unicode IRI
    and converts it into a URI.

    Examples for IRI versus URI:

    >>> iri_to_uri(u'http://â˜ƒ.net/')
    'http://xn--n3h.net/'
    >>> iri_to_uri(u'http://Ã¼ser:pÃ¤ssword@â˜ƒ.net/pÃ¥th')
    'http://%C3%BCser:p%C3%A4ssword@xn--n3h.net/p%C3%A5th'

    There is a general problem with IRI and URI conversion with some
    protocols that appear in the wild that are in violation of the URI
    specification.  In places where Werkzeug goes through a forced IRI to
    URI conversion it will set the `safe_conversion` flag which will
    not perform a conversion if the end result is already ASCII.  This
    can mean that the return value is not an entirely correct URI but
    it will not destroy such invalid URLs in the process.

    As an example consider the following two IRIs::

      magnet:?xt=uri:whatever
      itms-services://?action=download-manifest

    The internal representation after parsing of those URLs is the same
    and there is no way to reconstruct the original one.  If safe
    conversion is enabled however this function becomes a noop for both of
    those strings as they both can be considered URIs.

    .. versionadded:: 0.6

    .. versionchanged:: 0.9.6
       The `safe_conversion` parameter was added.

    :param iri: The IRI to convert.
    :param charset: The charset for the URI.
    :param safe_conversion: indicates if a safe conversion should take place.
                            For more information see the explanation above.
    R"   s   /:~+%s   %&[]:;$*()+,!?*/=s   =%&[]:;$()+,!?*/(   R%   R—   R9   R   R   RD   Rz   R6   R   RW   R\   RV   R   R   R   R   (
   t   iriRY   RZ   t   safe_conversiont
   native_irit	   ascii_iriR   R   R   R   (    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/urls.pyR?     s"    *t   &c      
   C   s¨   | d k r t } n  t |  t ƒ rL t | t ƒ rL | j | pC d ƒ } n7 t |  t ƒ rƒ t | t ƒ rƒ | j | pz d ƒ } n  | t |  j | ƒ | | | | ƒ ƒ S(   sŒ  
    Parse a querystring and return it as :class:`MultiDict`.  There is a
    difference in key decoding on different Python versions.  On Python 3
    keys will always be fully decoded whereas on Python 2, keys will
    remain bytestrings if they fit into ASCII.  On 2.x keys can be forced
    to be unicode by setting `decode_keys` to `True`.

    If the charset is set to `None` no unicode decoding will happen and
    raw bytes will be returned.

    Per default a missing value for a key will default to an empty key.  If
    you don't want that behavior you can set `include_empty` to `False`.

    Per default encoding errors are ignored.  If you want a different behavior
    you can set `errors` to ``'replace'`` or ``'strict'``.  In strict mode a
    `HTTPUnicodeError` is raised.

    .. versionchanged:: 0.5
       In previous versions ";" and "&" could be used for url decoding.
       This changed in 0.5 where only "&" is supported.  If you want to
       use ";" instead a different `separator` can be provided.

       The `cls` parameter was added.

    :param s: a string with the query string to decode.
    :param charset: the charset of the query string.  If set to `None`
                    no unicode decoding will take place.
    :param decode_keys: Used on Python 2.x to control whether keys should
                        be forced to be unicode objects.  If set to `True`
                        then keys will be unicode in all cases. Otherwise,
                        they remain `str` if they fit into ASCII.
    :param include_empty: Set to `False` if you don't want empty values to
                          appear in the dict.
    :param errors: the decoding error behavior.
    :param separator: the pair separator to be used, defaults to ``&``
    :param cls: an optional dict class to use.  If this is not specified
                       or `None` the default :class:`MultiDict` is used.
    R"   N(	   R$   R   R%   R    R\   Rf   R   t   _url_decode_implRD   (   R}   RY   t   decode_keyst   include_emptyRZ   t	   separatort   cls(    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/urls.pyR3   U  s    (	c	         C   se   d d l  m }	 | r" d „  } n | d k r7 t } n  |	 |  | | ƒ }
 | t |
 | | | | ƒ ƒ S(   s¯  Works like :func:`url_decode` but decodes a stream.  The behavior
    of stream and limit follows functions like
    :func:`~werkzeug.wsgi.make_line_iter`.  The generator of pairs is
    directly fed to the `cls` so you can consume the data while it's
    parsed.

    .. versionadded:: 0.8

    :param stream: a stream with the encoded querystring
    :param charset: the charset of the query string.  If set to `None`
                    no unicode decoding will take place.
    :param decode_keys: Used on Python 2.x to control whether keys should
                        be forced to be unicode objects.  If set to `True`,
                        keys will be unicode in all cases. Otherwise, they
                        remain `str` if they fit into ASCII.
    :param include_empty: Set to `False` if you don't want empty values to
                          appear in the dict.
    :param errors: the decoding error behavior.
    :param separator: the pair separator to be used, defaults to ``&``
    :param cls: an optional dict class to use.  If this is not specified
                       or `None` the default :class:`MultiDict` is used.
    :param limit: the content length of the URL data.  Not necessary if
                  a limited stream is provided.
    :param return_iterator: if set to `True` the `cls` argument is ignored
                            and an iterator over all decoded pairs is
                            returned
    iÿÿÿÿ(   t   make_chunk_iterc         S   s   |  S(   N(    (   t   x(    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/urls.pyt   <lambda>§  s    N(   t   werkzeug.wsgiR£   R$   R   Rž   (   t   streamRY   RŸ   R    RZ   R¡   R¢   t   limitt   return_iteratorR£   t	   pair_iter(    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/urls.pyt   url_decode_stream‡  s    	c   
      c   sÏ   xÈ |  D]À } | s q n  t  | ƒ } | d ƒ } | | k rX | j | d ƒ \ } }	 n | sd q n  | } | d ƒ }	 t | | | ƒ } | d  k	 r° t r° | r° t | ƒ } n  | t |	 | | ƒ f Vq Wd  S(   NRo   i   R;   (   R   RD   R“   R$   R   R   (
   Rª   RY   RŸ   R    RZ   t   pairR}   t   equalRn   Rv   (    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/urls.pyRž   ¯  s    c         C   s.   t  | d ƒ } | j t |  | | | | ƒ ƒ S(   s¡  URL encode a dict/`MultiDict`.  If a value is `None` it will not appear
    in the result string.  Per default only values are encoded into the target
    charset strings.  If `encode_keys` is set to ``True`` unicode keys are
    supported too.

    If `sort` is set to `True` the items are sorted by `key` or the default
    sorting algorithm.

    .. versionadded:: 0.5
        `sort`, `key`, and `separator` were added.

    :param obj: the object to encode into a query string.
    :param charset: the charset of the query string.
    :param encode_keys: set to `True` if you have unicode keys. (Ignored on
                        Python 3.x)
    :param sort: set to `True` if you want parameters to be sorted by `key`.
    :param separator: the separator to be used for the pairs.
    :param key: an optional function to be used for sorting.  For more details
                check out the :func:`sorted` documentation.
    R"   (   R   R8   Rw   (   Rr   RY   Rs   Rt   Rn   R¡   (    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/urls.pyt
   url_encodeÂ  s    c   
      C   s{   t  | d ƒ } t |  | | | | ƒ } | d k r7 | Sx= t | ƒ D]/ \ } }	 | rf | j | ƒ n  | j |	 ƒ qD Wd S(   s  Like :meth:`url_encode` but writes the results to a stream
    object.  If the stream is `None` a generator over all encoded
    pairs is returned.

    .. versionadded:: 0.8

    :param obj: the object to encode into a query string.
    :param stream: a stream to write the encoded object into or `None` if
                   an iterator over the encoded pairs should be returned.  In
                   that case the separator argument is ignored.
    :param charset: the charset of the query string.
    :param encode_keys: set to `True` if you have unicode keys. (Ignored on
                        Python 3.x)
    :param sort: set to `True` if you want parameters to be sorted by `key`.
    :param separator: the separator to be used for the pairs.
    :param key: an optional function to be used for sorting.  For more details
                check out the :func:`sorted` documentation.
    R"   N(   R   Rw   R$   t	   enumeratet   write(
   Rr   R§   RY   Rs   Rt   Rn   R¡   t   genRJ   t   chunk(    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/urls.pyt   url_encode_streamÜ  s    c         C   s¶  t  |  t ƒ r t |  ƒ }  n  t  | t ƒ r< t | ƒ } n  t |  | f ƒ \ }  } t |  ƒ } |  sj | S| st |  St |  d | ƒ\ } } } } } t | | | ƒ \ }	 }
 } } } |	 | k rÆ | S|
 rå t |	 |
 | | | f ƒ S| }
 | d  | d ƒ k r| j | d ƒ ƒ } nY | sF| j | d ƒ ƒ } | sr| } qrn, | j | d ƒ ƒ d  | j | d ƒ ƒ } | d | d ƒ k r›| d ƒ | d <n  g  | D] } | | d ƒ k r¢| ^ q¢} x‰ d } t | ƒ d } xm | | k  rM| | | d ƒ k r@| | d | d ƒ | d ƒ f k r@| | d | d 5Pn  | d 7} qâWPqÉ| d ƒ | d ƒ g } x | d  | k r‡| d =qmW| d ƒ j | ƒ } t |	 |
 | | | f ƒ S(	   s	  Join a base URL and a possibly relative URL to form an absolute
    interpretation of the latter.

    :param base: the base URL for the join operation.
    :param url: the URL to join.
    :param allow_fragments: indicates whether fragments should be allowed.
    R‡   i   R‘   iÿÿÿÿt   .R;   s   ..i   (	   R%   R—   R9   R   R   R6   RD   R„   R8   (   t   baseR†   R‡   R}   t   bschemet   bnetloct   bpatht   bqueryt	   bfragmentR   R   R   R   R   t   segmentst   segmentR‰   t   nt   unwanted_marker(    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/urls.pyR7   ú  sT    !!,+&t   Hrefc           B   s5   e  Z d  Z d d e d d „ Z d „  Z d „  Z RS(   sÿ  Implements a callable that constructs URLs with the given base. The
    function can be called with any number of positional and keyword
    arguments which than are used to assemble the URL.  Works with URLs
    and posix paths.

    Positional arguments are appended as individual segments to
    the path of the URL:

    >>> href = Href('/foo')
    >>> href('bar', 23)
    '/foo/bar/23'
    >>> href('foo', bar=23)
    '/foo/foo?bar=23'

    If any of the arguments (positional or keyword) evaluates to `None` it
    will be skipped.  If no keyword arguments are given the last argument
    can be a :class:`dict` or :class:`MultiDict` (or any other dict subclass),
    otherwise the keyword arguments are used for the query parameters, cutting
    off the first trailing underscore of the parameter name:

    >>> href(is_=42)
    '/foo?is=42'
    >>> href({'foo': 'bar'})
    '/foo?foo=bar'

    Combining of both methods is not allowed:

    >>> href({'foo': 'bar'}, bar=42)
    Traceback (most recent call last):
      ...
    TypeError: keyword arguments and query-dicts can't be combined

    Accessing attributes on the href object creates a new href object with
    the attribute name as prefix:

    >>> bar_href = href.bar
    >>> bar_href("blub")
    '/foo/bar/blub'

    If `sort` is set to `True` the items are sorted by `key` or the default
    sorting algorithm:

    >>> href = Href("/", sort=True)
    >>> href(a=1, b=2, c=3)
    '/?a=1&b=2&c=3'

    .. versionadded:: 0.5
        `sort` and `key` were added.
    s   ./s   utf-8c         C   s7   | s d } n  | |  _  | |  _ | |  _ | |  _ d  S(   Ns   ./(   Rµ   RY   Rt   Rn   (   R   Rµ   RY   Rt   Rn   (    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/urls.pyt   __init__q  s    				c         C   sj   | d  d k r t  | ƒ ‚ n  |  j } | d d k rE | d 7} n  t t | | ƒ |  j |  j |  j ƒ S(   Ni   t   __iÿÿÿÿR‘   (   t   AttributeErrorRµ   R¿   R7   RY   Rt   Rn   (   R   t   nameRµ   (    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/urls.pyt   __getattr__y  s    	c         O   sn  | rF t  | d t ƒ rF | r. t d ƒ ‚ n  | d | d  } } nS | r™ t g  | j ƒ  D]1 \ } } | j d ƒ r | d  p„ | | f ^ q\ ƒ } n  d j g  | D]- } | d  k	 r¦ t t | |  j	 ƒ d ƒ ^ q¦ ƒ j
 d ƒ } |  j } | r&| j d ƒ s| d 7} n  t | d | ƒ } n  | rd| d t t | |  j	 d |  j d	 |  j ƒd ƒ 7} n  t | ƒ S(
   Niÿÿÿÿs3   keyword arguments and query-dicts can't be combinedt   _R‘   R"   s   ./R   Rt   Rn   (   R%   t   dictR)   t   itemst   endswithR8   R$   R   RV   RY   t   lstripRµ   R7   R®   Rt   Rn   R   (   R   R   R   t   kt   vR¤   R&   (    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/urls.pyt   __call__  s$    G	C	!N(   RL   RM   R[   t   FalseR$   RÀ   RÄ   RÌ   (    (    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/urls.pyR¿   >  s   1	(5   R[   t   ret   werkzeug._compatR    R   R   R   R   R   R   R   R   t   werkzeug._internalR	   R
   t   werkzeug.datastructuresR   R   t   collectionsR   t   compileR€   R   R   RÆ   Rb   R   t   objectR   RP   RX   Rm   Rw   R.   R$   t   TrueR6   RV   Rq   R9   Ry   R“   R–   RA   RÍ   R?   R3   R«   Rž   R®   R³   R7   R¿   (    (    (    sS   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/urls.pyt   <module>
   sR   @	¬+	0	 A	1	&		D