³ò
™›\Kc           @   s   d  Z  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  a
 d" „  Z d# e f d$ „  ƒ  YZ d% e f d& „  ƒ  YZ d' e f d( „  ƒ  YZ d e d) „ Z d* „  Z d+ d, „ Z d e d- „ Z d. „  Z d/ „  Z e d0 „ Z d1 „  Z d2 Z d3 „  Z e d4 j o e ƒ  n d5 S(6   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   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
   h  a  d S(   s   Clear the parse cache.N(   t   _parse_cache(    (    (    s   /usr/lib/python2.5/urlparse.pyt   clear_cache&   s    t
   BaseResultc           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 e d	 „  ƒ Z RS(   s  Base class for the parsed result objects.

    This provides the attributes shared by the two derived result
    objects as read-only properties.  The derived classes are
    responsible for checking the right number of arguments were
    supplied to the constructor.

    c         C   s   |  d S(   Ni    (    (   t   self(    (    s   /usr/lib/python2.5/urlparse.pyt   scheme:   s    c         C   s   |  d S(   Ni   (    (   R!   (    (    s   /usr/lib/python2.5/urlparse.pyt   netloc>   s    c         C   s   |  d S(   Ni   (    (   R!   (    (    s   /usr/lib/python2.5/urlparse.pyt   pathB   s    c         C   s   |  d S(   Niþÿÿÿ(    (   R!   (    (    s   /usr/lib/python2.5/urlparse.pyt   queryF   s    c         C   s   |  d S(   Niÿÿÿÿ(    (   R!   (    (    s   /usr/lib/python2.5/urlparse.pyt   fragmentJ   s    c         C   s_   |  i  } d | j oE | i d d ƒ d } d | j o | i d d ƒ d } n | Sn d  S(   Nt   @i   i    t   :(   R#   t   splitt   None(   R!   R#   t   userinfo(    (    s   /usr/lib/python2.5/urlparse.pyt   usernameQ   s    	c         C   sY   |  i  } d | j o? | i d d ƒ d } d | j o | i d d ƒ d SqU n d  S(   NR'   i   i    R(   (   R#   R)   R*   (   R!   R#   R+   (    (    s   /usr/lib/python2.5/urlparse.pyt   password[   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)   t   lowerR*   (   R!   R#   (    (    s   /usr/lib/python2.5/urlparse.pyt   hostnamed   s    	c         C   sh   |  i  } d | j o | i d d ƒ d } n d | j o' | i d d ƒ d } t | d ƒ Sn d  S(   NR'   i   R(   i
   (   R#   R)   t   intR*   (   R!   R#   t   port(    (    s   /usr/lib/python2.5/urlparse.pyR1   m   s    	(    (   t   __name__t
   __module__t   __doc__t	   __slots__t   propertyR"   R#   R$   R%   R&   R,   R-   R/   R1   (    (    (    s   /usr/lib/python2.5/urlparse.pyR    ,   s   
		t   SplitResultc           B   s    e  Z d Z d  „  Z d „  Z RS(   c         C   s   t  i |  | | | | | f ƒ S(   N(   R    t   __new__(   t   clsR"   R#   R$   R%   R&   (    (    s   /usr/lib/python2.5/urlparse.pyR8   |   s    c         C   s
   t  |  ƒ S(   N(   R   (   R!   (    (    s   /usr/lib/python2.5/urlparse.pyt   geturl€   s    (    (   R2   R3   R5   R8   R:   (    (    (    s   /usr/lib/python2.5/urlparse.pyR7   x   s   	t   ParseResultc           B   s/   e  Z d Z d  „  Z e d „  ƒ Z d „  Z RS(   c         C   s"   t  i |  | | | | | | f ƒ S(   N(   R    R8   (   R9   R"   R#   R$   t   paramsR%   R&   (    (    s   /usr/lib/python2.5/urlparse.pyR8   ˆ   s    c         C   s   |  d S(   Ni   (    (   R!   (    (    s   /usr/lib/python2.5/urlparse.pyR<   Œ   s    c         C   s
   t  |  ƒ S(   N(   R   (   R!   (    (    s   /usr/lib/python2.5/urlparse.pyR:      s    (    (   R2   R3   R5   R8   R6   R<   R:   (    (    (    s   /usr/lib/python2.5/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   urlR"   t   allow_fragmentst   tupleR#   R%   R&   R<   (    (    s   /usr/lib/python2.5/urlparse.pyR    ”   s    c         C   sl   d |  j o: |  i  d |  i d ƒ ƒ } | d j  o |  d f SqV n |  i  d ƒ } |  |  |  | d f S(   Nt   /R=   i    R   i   (   t   findt   rfind(   R@   t   i(    (    s   /usr/lib/python2.5/urlparse.pyR?   ¢   s    i    c         C   sd   t  |  ƒ } x@ d D]8 } |  i | | ƒ } | d j o t | | ƒ } q q W|  | | !|  | f S(   Ns   /?#i    (   t   lenRD   t   min(   R@   t   startt   delimt   ct   wdelim(    (    s   /usr/lib/python2.5/urlparse.pyt   _splitnetloc«   s     c         C   sŒ  t  | ƒ } |  | | t |  ƒ t | ƒ f } t i | d
 ƒ } | o | Sn 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 | <|	 Sn xG |  |  D] }
 |
 t j o Pq}q}W|  |  i	 ƒ  |  | d } }  n | t j o* |  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*   RG   t   MAX_CACHE_SIZER   RD   R.   RM   R)   R7   t   scheme_charst   uses_netloct   uses_fragmentt
   uses_query(   R@   R"   RA   t   keyt   cachedR#   R%   R&   RF   t   vRK   (    (    s   /usr/lib/python2.5/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   .0R"   R#   R@   R<   R%   R&   (    (    s   /usr/lib/python2.5/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   RC   R   R(   RO   RN   (   RU   (   R[   R"   R#   R@   R%   R&   (    (    s   /usr/lib/python2.5/urlparse.pyR   ç   s    , c      	   C   s  |  p | Sn | p |  Sn t  |  d | ƒ \ } } } } } } t  | | | ƒ \ }	 }
 } } } } |	 | j p |	 t j o | Sn |	 t j o1 |
 o  t |	 |
 | | | | f ƒ Sn | }
 n | d  d j o  t |	 |
 | | | | f ƒ Sn | p | p | p  t |	 |
 | | | | f ƒ Sn | i d ƒ d  | i d ƒ } | d d j o d | d <n x d | j o | i d ƒ qn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   RC   iÿÿÿÿt   .s   ..i   iþÿÿÿ(   R   s   ..(   R    t   uses_relativeRU   R   R)   t   removeRG   t   join(   t   baseR@   RA   t   bschemet   bnetloct   bpatht   bparamst   bqueryt	   bfragmentR"   R#   R$   R<   R%   R&   t   segmentsRF   t   n(    (    s   /usr/lib/python2.5/urlparse.pyR   ó   sT    $$
   $c         C   se   d |  j oJ t  |  ƒ \ } } } } } } t | | | | | d f ƒ } | | f Sn |  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.
    RN   R   N(   R    R   (   R@   t   sRh   t   pt   at   qt   fragt   defrag(    (    s   /usr/lib/python2.5/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   s…  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á | i ƒ  } | p Pn | 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 GHq~q  q  d  S(   NiÿÿÿÿR   i   t   -(   t   StringIOi    s
   %-10s : %ss   <URL:%s>s
   %-10s = %si   t   =i   t   EXPECTEDs
   !!!!!!!!!!(   t   syst   argvt   stdint   opent	   cStringIORp   t   ImportErrort
   test_inputt   readlineR)   R    R   RG   (   Rs   R`   t   fnt   fpRp   t   linet   wordsR@   t   partst   abst   wrapped(    (    s   /usr/lib/python2.5/urlparse.pyt   testT  s<     


$t   __main__N(   R4   t   __all__R]   RU   t   non_hierarchicalR>   RW   RV   RT   RS   R   R   RB   R    R7   R;   t   TrueR    R?   RM   R   R   R   R   R   Ry   R‚   R2   (    (    (    s   /usr/lib/python2.5/urlparse.pys   <module>   sL   	L		+			0	/	!