Ñò
mÈKc           @   s®  d  Z  d d d d d d d d g Z d	 d
 d d d d d d d d d d d d d g Z d	 d
 d d d d d d d d d d d d d d d d d d g Z d d d d d d d d d  d! g
 Z d	 d d d
 d d d d d d  d! d d d g Z d
 d d d d d d d d d  d! d g Z d	 d d
 d d d d d d d d d d g Z d" Z d# Z	 h  Z
 d$ „  Z d% e f d& „  ƒ  YZ d' d( k l Z d) e d) d* ƒ e f d+ „  ƒ  YZ d, e d, d- ƒ e f d. „  ƒ  YZ d e d/ „ Z d0 „  Z d1 d2 „ Z d e d3 „ Z d4 „  Z d5 „  Z e d6 „ Z d7 „  Z e d8 „  e d9 ƒ Dƒ ƒ Z e i d: „  e d9 ƒ Dƒ ƒ d; „  Z d1 d1 d< „ Z  d1 d1 d= „ Z! d> Z" d? „  Z# e$ d@ j o e# ƒ  n dA S(B   s   Parse (absolute and relative) URLs.

See RFC 1808: "Relative Uniform Resource Locators", by R. Fielding,
UC Irvine, June 1995.
t   urlparset
   urlunparset   urljoint	   urldefragt   urlsplitt
   urlunsplitt   parse_qst	   parse_qslt   ftpt   httpt   gophert   nntpt   imapt   waist   filet   httpst   shttpt   mmst   prosperot   rtspt   rtsput    t   sftpt   telnett   snewst   rsynct   svns   svn+ssht   hdlt   mailtot   newst   sipt   sipssA   abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+-.i   c           C   s   t  i ƒ  d S(   s   Clear the parse cache.N(   t   _parse_cachet   clear(    (    (    s   /usr/lib/python2.6/urlparse.pyt   clear_cache&   s    t   ResultMixinc           B   sJ   e  Z d  Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z RS(   s-   Shared methods for the parsed result objects.c         C   s\   |  i  } d | j oB | i d d ƒ d } d | j o | i d d ƒ d } n | Sd  S(   Nt   @i   i    t   :(   t   netloct   rsplitt   splitt   None(   t   selfR&   t   userinfo(    (    s   /usr/lib/python2.6/urlparse.pyt   username.   s    	c         C   sV   |  i  } d | j o< | i d d ƒ d } d | j o | i d d ƒ d Sn d  S(   NR$   i   i    R%   (   R&   R'   R(   R)   (   R*   R&   R+   (    (    s   /usr/lib/python2.6/urlparse.pyt   password8   s    	c         C   sh   |  i  } d | j o | i d d ƒ d } n d | j o | i d d ƒ d } n | i ƒ  p d  S(   NR$   i   R%   i    (   R&   R'   R(   t   lowerR)   (   R*   R&   (    (    s   /usr/lib/python2.6/urlparse.pyt   hostnameA   s    	c         C   se   |  i  } d | j o | i d d ƒ d } n d | j o$ | i d d ƒ d } t | d ƒ Sd  S(   NR$   i   R%   i
   (   R&   R'   R(   t   intR)   (   R*   R&   t   port(    (    s   /usr/lib/python2.6/urlparse.pyR1   J   s    	(   t   __name__t
   __module__t   __doc__t   propertyR,   R-   R/   R1   (    (    (    s   /usr/lib/python2.6/urlparse.pyR#   +   s
   
		iÿÿÿÿ(   t
   namedtuplet   SplitResults!   scheme netloc path query fragmentc           B   s   e  Z d Z d  „  Z RS(   c         C   s
   t  |  ƒ S(   N(   R   (   R*   (    (    s   /usr/lib/python2.6/urlparse.pyt   geturlZ   s    (    (   R2   R3   t	   __slots__R8   (    (    (    s   /usr/lib/python2.6/urlparse.pyR7   V   s   t   ParseResults(   scheme netloc path params query fragmentc           B   s   e  Z d Z d  „  Z RS(   c         C   s
   t  |  ƒ S(   N(   R   (   R*   (    (    s   /usr/lib/python2.6/urlparse.pyR8   b   s    (    (   R2   R3   R9   R8   (    (    (    s   /usr/lib/python2.6/urlparse.pyR:   ^   s   c         C   sv   t  |  | | ƒ } | \ } } }  } } | t j o# d |  j o t |  ƒ \ }  } n d } t | | |  | | | ƒ S(   s#  Parse a URL into 6 components:
    <scheme>://<netloc>/<path>;<params>?<query>#<fragment>
    Return a 6-tuple: (scheme, netloc, path, params, query, fragment).
    Note that we don't break the components up in smaller bits
    (e.g. netloc is a single string) and we don't expand % escapes.t   ;R   (   R   t   uses_paramst   _splitparamsR:   (   t   urlt   schemet   allow_fragmentst   tupleR&   t   queryt   fragmentt   params(    (    s   /usr/lib/python2.6/urlparse.pyR    f   s    c         C   si   d |  j o7 |  i  d |  i d ƒ ƒ } | d j  o |  d f Sn |  i  d ƒ } |  |  |  | d f S(   Nt   /R;   i    R   i   (   t   findt   rfind(   R>   t   i(    (    s   /usr/lib/python2.6/urlparse.pyR=   t   s    i    c         C   sd   t  |  ƒ } x@ d D]8 } |  i | | ƒ } | d j o t | | ƒ } q q W|  | | !|  | f S(   Ns   /?#i    (   t   lenRF   t   min(   R>   t   startt   delimt   ct   wdelim(    (    s   /usr/lib/python2.6/urlparse.pyt   _splitnetloc}   s     c         C   sy  t  | ƒ } |  | | t |  ƒ t | ƒ f } t i | d
 ƒ } | o | St t ƒ t j o t ƒ  n d } } } |  i d ƒ } | d j o#|  |  d j oÈ |  |  i	 ƒ  } |  | d }  |  d  d j o t
 |  d ƒ \ } }  n | o) d |  j o |  i d d ƒ \ }  } n d	 |  j o |  i d	 d ƒ \ }  } n t | | |  | | ƒ }	 |	 t | <|	 SxG |  |  D] }
 |
 t j o PqwqwW|  |  i	 ƒ  |  | d } }  n |  d  d j o t
 |  d ƒ \ } }  n | o6 | t j o) d |  j o |  i d d ƒ \ }  } n | t j o) d	 |  j o |  i d	 d ƒ \ }  } n t | | |  | | ƒ }	 |	 t | <|	 S(   s  Parse a URL into 5 components:
    <scheme>://<netloc>/<path>?<query>#<fragment>
    Return a 5-tuple: (scheme, netloc, path, query, fragment).
    Note that we don't break the components up in smaller bits
    (e.g. netloc is a single string) and we don't expand % escapes.R   R%   i    R	   i   i   s   //t   #t   ?N(   t   boolt   typeR    t   getR)   RI   t   MAX_CACHE_SIZER"   RF   R.   RO   R(   R7   t   scheme_charst   uses_fragmentt
   uses_query(   R>   R?   R@   t   keyt   cachedR&   RB   RC   RH   t   vRM   (    (    s   /usr/lib/python2.6/urlparse.pyR   …   sH    !
 	#!
c         C   sL   |  \ } } } } } } | o d | | f } n t  | | | | | f ƒ S(   sú   Put a parsed URL back together again.  This may result in a
    slightly different, but equivalent URL, if the URL that was parsed
    originally had redundant delimiters, e.g. a ? with an empty query
    (the draft states that these are equivalent).s   %s;%s(   R   (   t   dataR?   R&   R>   RD   RB   RC   (    (    s   /usr/lib/python2.6/urlparse.pyR   ±   s    c         C   sÏ   |  \ } } } } } | p% | o] | t  j oP | d  d j o? | o | d  d j o d | } n d | p d | } n | o | d | } n | o | d | } n | o | d | } n | S(	   Ni   s   //i   RE   R   R%   RQ   RP   (   t   uses_netloc(   R\   R?   R&   R>   RB   RC   (    (    s   /usr/lib/python2.6/urlparse.pyR   »   s    , c      
   C   s¯  |  p | S| p |  St  |  d | ƒ \ } } } } } } t  | | | ƒ \ }	 }
 } } } } |	 | j p |	 t j o | S|	 t j o. |
 o t |	 |
 | | | | f ƒ S| }
 n | d  d j o t |	 |
 | | | | f ƒ S| pk | } | p
 | } n' | d  } t |	 |
 | | | | f ƒ S| p
 | } n t |	 |
 | | | | f ƒ S| i d ƒ d  | i d ƒ } | d d j o d | d <n x d | j o | i d ƒ qœWxv d } t | ƒ d } xZ | | j  oK | | d j o, | | d d	 j o | | d | d 5Pn | d } q×WPq¾| d d g j o d | d <n6 t | ƒ d j o" | d d j o d g | d )n t |	 |
 d i | ƒ | | | f ƒ S(
   sa   Join a base URL and a possibly relative URL to form an absolute
    interpretation of the latter.R   i   RE   iÿÿÿÿt   .s   ..i   iþÿÿÿ(   R   s   ..(   R    t   uses_relativeR]   R   R(   t   removeRI   t   join(   t   baseR>   R@   t   bschemet   bnetloct   bpatht   bparamst   bqueryt	   bfragmentR?   R&   t   pathRD   RB   RC   t   segmentsRH   t   n(    (    s   /usr/lib/python2.6/urlparse.pyR   È   sd    $$



   $c         C   sb   d |  j oG t  |  ƒ \ } } } } } } t | | | | | d f ƒ } | | f S|  d f Sd S(   s¿   Removes any existing fragment from URL.

    Returns a tuple of the defragmented URL and the fragment.  If
    the URL contained no fragments, the second element is the
    empty string.
    RP   R   N(   R    R   (   R>   t   sRk   t   pt   at   qt   fragt   defrag(    (    s   /usr/lib/python2.6/urlparse.pyR     s
    c         c   s)   x" |  ] } d  | t  | ƒ f Vq Wd S(   s   %02xN(   t   chr(   t   .0RH   (    (    s   /usr/lib/python2.6/urlparse.pys	   <genexpr>  s   	 i   c         c   s)   x" |  ] } d  | t  | ƒ f Vq Wd S(   s   %02XN(   Rr   (   Rs   RH   (    (    s   /usr/lib/python2.6/urlparse.pys	   <genexpr>  s   	 c      	   C   s¿   |  i  d ƒ } x  t d t | ƒ ƒ D]‰ } | | } y t | d  | d | | <Wq% t j
 o d | | | <q% t j
 o, t t | d  d ƒ ƒ | d | | <q% Xq% Wd i | ƒ S(   s"   unquote('abc%20def') -> 'abc def'.t   %i   i   i   R   (	   R(   t   xrangeRI   t	   _hextochrt   KeyErrort   UnicodeDecodeErrort   unichrR0   Ra   (   Rl   t   resRH   t   item(    (    s   /usr/lib/python2.6/urlparse.pyt   unquote  s     
.c         C   s\   h  } xO t  |  | | ƒ D]; \ } } | | j o | | i | ƒ q | g | | <q W| S(   sª  Parse a query given as a string argument.

        Arguments:

        qs: URL-encoded query string to be parsed

        keep_blank_values: flag indicating whether blank values in
            URL encoded queries should be treated as blank strings.
            A true value indicates that blanks should be retained as
            blank strings.  The default false value indicates that
            blank values are to be ignored and treated as if they were
            not included.

        strict_parsing: flag indicating what to do with parsing errors.
            If false (the default), errors are silently ignored.
            If true, errors raise a ValueError exception.
    (   R   t   append(   t   qst   keep_blank_valuest   strict_parsingt   dictt   namet   value(    (    s   /usr/lib/python2.6/urlparse.pyR   #  s     c         C   s8  g  } |  i  d ƒ D]# } | i  d ƒ D] } | | q' q ~ } g  } xë | D]ã } | o | o qM n | i  d d ƒ }	 t |	 ƒ d j o: | o t d | f ‚ n | o |	 i d ƒ qÉ qM n t |	 d ƒ p | oO t |	 d i d	 d
 ƒ ƒ }
 t |	 d i d	 d
 ƒ ƒ } | i |
 | f ƒ qM qM W| S(   sž  Parse a query given as a string argument.

    Arguments:

    qs: URL-encoded query string to be parsed

    keep_blank_values: flag indicating whether blank values in
        URL encoded queries should be treated as blank strings.  A
        true value indicates that blanks should be retained as blank
        strings.  The default false value indicates that blank values
        are to be ignored and treated as if they were  not included.

    strict_parsing: flag indicating what to do with parsing errors. If
        false (the default), errors are silently ignored. If true,
        errors raise a ValueError exception.

    Returns a list, as G-d intended.
    t   &R;   t   =i   i   s   bad query field: %rR   i    t   +t    (   R(   RI   t
   ValueErrorR}   R|   t   replace(   R~   R   R€   t   _[1]t   s1t   s2t   pairst   rt
   name_valuet   nvR‚   Rƒ   (    (    s   /usr/lib/python2.6/urlparse.pyR   =  s$    @ s™  
      http://a/b/c/d

      g:h        = <URL:g:h>
      http:g     = <URL:http://a/b/c/g>
      http:      = <URL:http://a/b/c/d>
      g          = <URL:http://a/b/c/g>
      ./g        = <URL:http://a/b/c/g>
      g/         = <URL:http://a/b/c/g/>
      /g         = <URL:http://a/g>
      //g        = <URL:http://g>
      ?y         = <URL:http://a/b/c/d?y>
      g?y        = <URL:http://a/b/c/g?y>
      g?y/./x    = <URL:http://a/b/c/g?y/./x>
      .          = <URL:http://a/b/c/>
      ./         = <URL:http://a/b/c/>
      ..         = <URL:http://a/b/>
      ../        = <URL:http://a/b/>
      ../g       = <URL:http://a/b/g>
      ../..      = <URL:http://a/>
      ../../g    = <URL:http://a/g>
      ../../../g = <URL:http://a/../g>
      ./../g     = <URL:http://a/b/g>
      ./g/.      = <URL:http://a/b/c/g/>
      /./g       = <URL:http://a/./g>
      g/./h      = <URL:http://a/b/c/g/h>
      g/../h     = <URL:http://a/b/c/h>
      http:g     = <URL:http://a/b/c/g>
      http:      = <URL:http://a/b/c/d>
      http:?y         = <URL:http://a/b/c/d?y>
      http:g?y        = <URL:http://a/b/c/g?y>
      http:g?y/./x    = <URL:http://a/b/c/g?y/./x>
c       
   C   sx  d d  k  }  d } |  i d o7 |  i d } | d j o |  i } q t | ƒ } nG y d d k l } Wn# t j
 o d d k l } n X| t ƒ } xÔ | D]Ì } | i ƒ  } | p q¤ n | d } t	 | ƒ } d | | f GHt
 | | ƒ }	 | p
 |	 } n d |	 }
 d	 | |
 f GHt | ƒ d
 j o; | d d j o* |
 | d j o d G| d Gd GHqpq¤ q¤ Wd  S(   NiÿÿÿÿR   i   t   -(   t   StringIOi    s
   %-10s : %ss   <URL:%s>s
   %-10s = %si   R…   i   t   EXPECTEDs
   !!!!!!!!!!(   t   syst   argvt   stdint   opent	   cStringIOR’   t   ImportErrort
   test_inputR(   R    R   RI   (   R”   Rb   t   fnt   fpR’   t   linet   wordsR>   t   partst   abst   wrapped(    (    s   /usr/lib/python2.6/urlparse.pyt   testˆ  s8     


$t   __main__N(%   R4   t   __all__R_   R]   t   non_hierarchicalR<   RX   RW   RV   RU   R    R"   t   objectR#   t   collectionsR6   R7   R:   t   TrueR    R=   RO   R   R   R   R   R   R   t   rangeRv   t   updateR|   R   R   Rš   R¢   R2   (    (    (    s   /usr/lib/python2.6/urlparse.pyt   <module>   sX   	)""		,	
	9		I	