Ζ
B }:c       s  d  Z  d k Z d k l Z l Z l 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 d g Z 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 g	 Z	 d d d d d d d d	 d
 d d d d g Z
 e i e i d Z d Z h  Z d   Z d d d  Z d   Z d d  Z d   Z d Z d   Z e d j o e   n d S(    s   Parse (absolute and relative) URLs.

See RFC 1808: "Relative Uniform Resource Locators", by R. Fielding,
UC Irvine, June 1995.
N(   s   joins   splits   rfinds   ftps   https   gophers   nntps   waiss   files   httpss   shttps   prosperos   rtsps   rtspus    s   telnets   snewss   hdls   mailtos   newss   sips   +-.i   c      s
   h  a  d S(   s   Clear the parse cache.N(   s   _parse_cache(    s$   /usr/local/lib/python2.0/urlparse.pys   clear_cache' s      c    sέ  |  | | f } t i | t  } | o | Sn t t  t	 j o t
   n t i } d } } } }	 }
 | |  d  } | d j oΑ|  |  d j o\t i |  |   } |  | d }  |  d  d j oJ | |  d d  } | d j  o t |   } n |  d | !} |  | }  n | o? t i |  d	  } | d j o |  | d }
 |  |  }  n n | |  d
  } | d j o |  | d }	 |  |  }  n | |  d  } | d j o |  | d } |  |  }  n | | |  | |	 |
 f } | t | <| Sn xM |  |  d r } | t j o Pn qWt i |  |   |  | d f \ } }  n | t j oe |  d  d j oP | |  d d  } | d j  o t |   } n |  d | !|  | f \ } }  n n | o
 | t j oE t i |  d	  } | d j o" |  |  |  | d f \ }  }
 n n | t j oB | |  d
  } | d j o" |  |  |  | d f \ }  }	 n n | t j oB | |  d  } | d j o" |  |  |  | d f \ }  } n n | | |  | |	 |
 f } | t | <| Sd 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.s    s   :i    s   httpi   i   s   //s   /s   #s   ?s   ;N(   s   urls   schemes   allow_fragmentss   keys   _parse_caches   gets   Nones   cacheds   lens   MAX_CACHE_SIZEs   clear_caches   strings   finds   netlocs   paths   paramss   querys   fragments   is   lowers   rfinds   tuples   cs   scheme_charss   uses_netlocs   uses_fragments
   uses_querys   uses_params(   s   urls   schemes   allow_fragmentss   keys   cacheds   finds   netlocs   paths   paramss   querys   fragments   is   tuples   cs$   /usr/local/lib/python2.0/urlparse.pys   urlparse- s|     	
 	+%&&&
i   c    sα   |  \ } } } } } } | p | t j o | d  d j o8 | d  d j o d | } n d | p d | } n | o | d | } n | o | d | } n | o | d | } n | o | d	 | } n | Sd
 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).i   s   //i   s   /s    s   :s   ;s   ?s   #N(   s   netlocs   schemes   uses_netlocs   urls   paramss   querys   fragment(   s   .0s   schemes   netlocs   urls   paramss   querys   fragments$   /usr/local/lib/python2.0/urlparse.pys
   urlunparseq s    % c    s΄  |  o | Sn t |  d |  \ } } } } } } t | | |  \ }	 }
 } } } } |	 | j p
 |	 t j o  t |	 |
 | | | | f  Sn |	 t j o1 |
 o  t |	 |
 | | | | f  Sn | }
 n | d  d j o  t |	 |
 | | | | f  Sn | o' t |	 |
 | | | p | | f  Sn t | d  d  t | d  } | d d j o d | d <n x d | j o | i d  quWxy d oq d } t |  d } xT | | j  oE | | d j o | | d o | | d | d 5Pn | d } q·WPqWt |  d j o | d d j o | d d j o d | d <n8 t |  d j o | d d j o d g | d )n t |	 |
 t | d  | | | f  Sd S(	   s^   Join a base URL and a possibly relative URL to form an absolute
	interpretation of the latter.s    i   s   /s   .s   ..i   i    N(   s   bases   urls   urlparses   allow_fragmentss   bschemes   bnetlocs   bpaths   bparamss   bquerys	   bfragments   schemes   netlocs   paths   paramss   querys   fragments   uses_relatives
   urlunparses   uses_netlocs   splits   segmentss   removes   is   lens   ns   join(   s   bases   urls   allow_fragmentss   bschemes   bnetlocs   bpaths   bparamss   bquerys	   bfragments   schemes   netlocs   paths   paramss   querys   fragments   segmentss   is   ns$   /usr/local/lib/python2.0/urlparse.pys   urljoin sJ     $$  
 '!    5%c    sJ   t  |   \ } } } } } } t | | | | | d f  } | | 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.
	s    N(
   s   urlparses   urls   ss   ns   ps   as   qs   frags
   urlunparses   defrag(   s   urls   ss   ns   ps   as   qs   frags   defrags$   /usr/local/lib/python2.0/urlparse.pys	   urldefrag± 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     sc  d  k  }  d } |  i d o7 |  i d } | d j o |  i } n t |  } n d  k } | i t  } xπ d oθ | i	   } | o Pn t i |  } | o qo n | d } t |  } d | | f GHt | |  }	 | o
 |	 } n d |	 }
 d | |
 f GHt |  d j o | d d	 j o* |
 | d
 j o d G| d
 Gd GHn n qo Wd  S(   Ns    i   s   -i    s
   %-10s : %ss   <URL:%s>s
   %-10s = %si   s   =i   s   EXPECTEDs
   !!!!!!!!!!(   s   syss   bases   argvs   fns   stdins   fps   opens   StringIOs
   test_inputs   readlines   lines   strings   splits   wordss   urls   urlparses   partss   urljoins   abss   wrappeds   len(   s   syss   bases   fns   fps   StringIOs   lines   wordss   urls   partss   abss   wrappeds$   /usr/local/lib/python2.0/urlparse.pys   testΰ s8    		  


$s   __main__(   s   __doc__s   strings   joins   splits   rfinds   uses_relatives   uses_netlocs   non_hierarchicals   uses_paramss
   uses_querys   uses_fragments   letterss   digitss   scheme_charss   MAX_CACHE_SIZEs   _parse_caches   clear_caches   urlparses
   urlunparses   urljoins	   urldefrags
   test_inputs   tests   __name__(    s$   /usr/local/lib/python2.0/urlparse.pys   ? s(   	*0$!-	D	.	#	