
9Vc           @@  s  d  d l  m Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l m	 Z	 m
 Z
 m Z d  d l m Z m Z d  d l m Z d  d l 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 d  d
 l m Z d  d l Z e j  Z  d Z! e j" e#  Z$ e j% d d e d   Z& d   Z' d   Z( d   Z) d d  Z+ d e, f d     YZ- e# d k re j. e+    n  d S(   i    (   t   absolute_importN(   t   InstallationErrort   CommandErrort   PipError(   t   get_installed_distributionst   get_prog(   t   deprecation(   t   gitt	   mercurialt
   subversiont   bazaar(   t   ConfigOptionParsert   UpdatingDefaultsHelpFormatter(   t   get_summariest   get_similar_commands(   t   commands_dict(   t   InsecureRequestWarnings   7.1.2t   ignoret   categoryc          C@  s  d t  j k r d St  j d j   d }  t t  j d  } y |  | d } Wn t k
 rh d } n Xg  t   D] \ } } | ^ qs } g  } y- g  |  D] } | | k r | ^ q d } Wn t k
 r d } n Xt   }	 | r| d k rt j	 d  n  | d	 k r| j
 d
  rg  }
 | j   } xO t d t  D]> } | j j
 |  rA| j |  d k rA|
 j | j  qAqAW|
 rx |
 D] } | GHqWt j	 d  qn  t |   } | g  | j j D]- } | j t j k r| j   | j f ^ q7} g  |  d | d !D] } | j d  d ^ q} g  | D]$ \ } } | | k r;| | f ^ q;} g  | D]' \ } } | j
 |  rl| | f ^ ql} x | D], } | d } | d r| d 7} n  | GHqWn | j
 d
  s| j
 d  rhg  |	 j D] } | j ^ q} | j |	 j  d   | D } | g  | D]$ } | j t j k r:| j   ^ q:7} n  d j g  | D] } | j
 |  ru| ^ qu GHt j	 d  d S(   s   Command and option completion for the main option parser (and options)
    and its subcommands (and options).

    Enable by sourcing one of the completion shell scripts (bash or zsh).
    t   PIP_AUTO_COMPLETENt
   COMP_WORDSi   t
   COMP_CWORDt    i    t   helpt	   uninstallt   -t
   local_onlyt   =s   --c         s@  s"   |  ] } | D] } | Vq q d  S(   N(    (   t   .0t   itt   o(    (    s)   /tmp/pip-build-5Z5nTX/pip/pip/__init__.pys	   <genexpr>j   s    t    (   t   ost   environt   splitt   intt
   IndexErrorR   t   Nonet   create_main_parsert   syst   exitt
   startswitht   lowerR   t   Truet   keyt   appendR   t   parsert   option_list_allR   t   optparset   SUPPRESS_HELPt   get_opt_stringt   nargst   option_groupst   option_listt   join(   t   cwordst   cwordt   currentt   cmdt   summaryt   subcommandst   optionst   wt   subcommand_nameR.   t	   installedt   lct   distt
   subcommandt   optt   xt	   prev_optst   vt   kt   optiont	   opt_labelt   it   opts(    (    s)   /tmp/pip-build-5Z5nTX/pip/pip/__init__.pyt   autocomplete*   s`    
"-
	%	.114

(0c          C@  s  i d d 6t  d 6t   d 6d d 6t   d 6}  t |    } | j   t j j t j j t j j t	    } d t
 | t j d	  f | _ t j t j |  } | j |  t | _ t   } d
 g g  | D] \ } } d | | f ^ q } d j |  | _ | S(   Ns   
%prog <command> [options]t   usaget   add_help_optiont	   formattert   globalt   namet   progs   pip %s from %s (python %s)i   R   s   %-27s %ss   
(   t   FalseR   R   R   t   disable_interspersed_argsR    t   patht   dirnamet   abspatht   __file__t   __version__R'   t   versiont
   cmdoptionst   make_option_groupt   general_groupt   add_option_groupR+   t   mainR   R6   t   description(   t	   parser_kwR.   t   pip_pkg_dirt   gen_optst   command_summariesRK   t   jRa   (    (    s)   /tmp/pip-build-5Z5nTX/pip/pip/__init__.pyR&   s   s$    

*		0c         C@  s  t    } | j |   \ } } | j rZ t j j | j  t j j t j  t j   n  | s | d d k r t	 |  d k r | j
   t j   n  | d } | t k r t |  } d | g } | r | j d |  n  t d j |    n  |  } | j |  | | f S(   Ni    R   i   s   unknown command "%s"s   maybe you meant "%s"s    - (   R&   t
   parse_argsR[   R'   t   stdoutt   writeR    t   linesepR(   t   lent
   print_helpR   R   R-   R   R6   t   remove(   t   argsR.   t   general_optionst	   args_elset   cmd_namet   guesst   msgt   cmd_args(    (    s)   /tmp/pip-build-5Z5nTX/pip/pip/__init__.pyt	   parseopts   s&    			)

c         C@  s   t  } d |  k r t } n  | S(   Ns
   --isolated(   RT   R+   (   Rn   t   isolated(    (    s)   /tmp/pip-build-5Z5nTX/pip/pip/__init__.pyt   check_isolated   s    	c         C@  s   |  d  k r t j d }  n  x! t j D] } t j d |  q& Wt j   t   y t	 |   \ } } WnG t
 k
 r } t j j d |  t j j t j  t j d  n Xt | d t |   } | j |  S(   Ni   t   defaults	   ERROR: %sRv   (   R%   R'   t   argvR   t   DEPRECATIONSt   warningst   simplefiltert   install_warning_loggerRM   Ru   R   t   stderrRi   R    Rj   R(   R   Rw   R`   (   Rn   t   deprecation_warningRq   Rt   t   exct   command(    (    s)   /tmp/pip-build-5Z5nTX/pip/pip/__init__.pyR`      s    
t   FrozenRequirementc           B@  s\   e  Z d d   Z e j d  Z e j d  Z e e d   Z	 e
 d    Z d   Z RS(   c         C@  s(   | |  _  | |  _ | |  _ | |  _ d  S(   N(   RR   t   reqt   editablet   comments(   t   selfRR   R   R   R   (    (    s)   /tmp/pip-build-5Z5nTX/pip/pip/__init__.pyt   __init__   s    			s   -r(\d+)$s   -(20\d\d\d\d\d\d)$c         C@  s4  t  j j t  j j | j   } g  } d d l m } m } | j |  r t	 } y | | | |  }	 Wn) t
 k
 r }
 t j d |
  d  }	 n X|	 d  k rt j d |  | j d  | j   }	 t } qnIt } | j   }	 |	 j } t |  d k r| d d d k s,t d	 | | f   | d d } |  j j |  } |  j j |  } | sj| r| j d
  } | r|   j | |  } n  | st j d |	  | j d  q| j d |	  | r| j d  } n d | j d  } t	 } d | | |  j |  f }	 n  |  | j |	 | |  S(   Ni    (   t   vcst   get_src_requirementsY   Error when trying to get requirement for VCS system %s, falling back to uneditable formats-   Could not determine repository location of %ss-   ## !! Could not determine repository locationi   s   ==s   ===s5   Expected 1 spec with == or ===; specs = %r; dist = %rt   svns(   Warning: cannot find svn location for %ssF   ## FIXME: could not find svn URL in dependency_links for this package:s3   # Installing as editable to satisfy requirement %s:s   {%s}s   %s@%s#egg=%s(   s   ==s   ===(   R    RV   t   normcaseRX   t   locationt   pip.vcsR   R   t   get_backend_nameR+   R   t   loggert   warningR%   R-   t   as_requirementRT   t   specsRk   t   AssertionErrort   _rev_ret   searcht   _date_ret   get_backendt   get_locationt   groupt   egg_namet   project_name(   t   clsRB   t   dependency_linkst	   find_tagsR   R   R   R   R   R   R   R   R[   t	   ver_matcht
   date_matcht   svn_backendt   svn_locationt   rev(    (    s)   /tmp/pip-build-5Z5nTX/pip/pip/__init__.pyt	   from_dist   sf    !

	)	

c         C@  s;   |  j    } t j d |  } | r7 | | j    } n  | S(   Ns
   -py\d\.\d$(   R   t   reR   t   start(   RB   RR   t   match(    (    s)   /tmp/pip-build-5Z5nTX/pip/pip/__init__.pyR   +  s
    c         C@  sF   |  j  } |  j r d | } n  d j t |  j  t |  g  d S(   Ns   -e %ss   
(   R   R   R6   t   listR   t   str(   R   R   (    (    s)   /tmp/pip-build-5Z5nTX/pip/pip/__init__.pyt   __str__3  s    		(    (   t   __name__t
   __module__R   R   t   compileR   R   t   classmethodRT   R   t   staticmethodR   R   (    (    (    s)   /tmp/pip-build-5Z5nTX/pip/pip/__init__.pyR      s   @t   __main__(/   t
   __future__R    t   loggingR    R0   R{   R'   R   t   pip.exceptionsR   R   R   t	   pip.utilsR   R   R   R   R   R   R	   R
   t   pip.baseparserR   R   t   pip.commandsR   R   R   t0   pip._vendor.requests.packages.urllib3.exceptionsR   t   pip.cmdoptionst   pipR\   RZ   t	   getLoggerR   R   t   filterwarningsRM   R&   Ru   Rw   R%   R`   t   objectR   R(   (    (    (    s)   /tmp/pip-build-5Z5nTX/pip/pip/__init__.pyt   <module>   s6   "
		I		*		[