ó
¨9Vc           @@  sœ  d  Z  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 m	 Z	 d d l
 m Z d d l m Z d d l m Z m Z m Z m Z m Z d d l m Z d d	 l m Z m Z d d
 l m Z m Z d d l m Z m Z m Z m  Z  m! Z! d d l" m# Z# m$ Z$ d d l% m& Z& d d l' m( Z( d d l) m* Z* d g Z+ e j, e- ƒ Z. d e/ f d „  ƒ  YZ0 d e0 f d „  ƒ  YZ1 d S(   s(   Base Command class, and related routinesi    (   t   absolute_importN(   t
   cmdoptions(   t   running_under_virtualenv(   t
   PipSession(   t
   BadCommandt   InstallationErrort   UninstallationErrort   CommandErrort   PreviousBuildDirError(   t   logging_dictConfig(   t   ConfigOptionParsert   UpdatingDefaultsHelpFormatter(   t   InstallRequirementt   parse_requirements(   t   SUCCESSt   ERRORt   UNKNOWN_ERRORt   VIRTUALENV_NOT_FOUNDt   PREVIOUS_BUILD_DIR_ERROR(   t   get_progt   normalize_path(   t   RemovedInPip8Warning(   t   IndentingFormatter(   t   pip_version_checkt   Commandc           B@  sM   e  Z d Z d Z e Z d Z e d „ Z d d d „ Z	 d „  Z
 d „  Z RS(   s   ext://sys.stdouts   ext://sys.stderrc         C@  s¹   i |  j  d 6d t ƒ  |  j f d 6t ƒ  d 6t d 6|  j d 6|  j d 6| d 6} t |   |  _ d	 |  j j ƒ  } t	 j
 |  j | ƒ |  _ t j t j |  j ƒ } |  j j | ƒ d  S(
   Nt   usages   %s %st   progt	   formattert   add_help_optiont   namet   descriptiont   isolateds
   %s Options(   R   R   R   R   t   Falset   __doc__R
   t   parsert
   capitalizet   optparset   OptionGroupt   cmd_optsR   t   make_option_groupt   general_groupt   add_option_group(   t   selfR   t	   parser_kwt   optgroup_namet   gen_opts(    (    s,   /tmp/pip-build-5Z5nTX/pip/pip/basecommand.pyt   __init__(   s    




c         C@  s÷   t  d | j r- t t j j | j d ƒ ƒ n d  d | d  k	 rE | n | j d | j ƒ } | j	 rr | j	 | _
 n  | j rŠ | j | _	 n  | j s™ | rº | d  k	 r« | n | j | _ n  | j rã i | j d 6| j d 6| _ n  | j | j _ | S(   Nt   cachet   httpt   retriest   insecure_hostst   https(   R   t	   cache_dirR   t   ost   patht   joint   NoneR1   t   trusted_hostst   certt   verifyt   client_certt   timeoutt   proxyt   proxiest   no_inputt   autht	   prompting(   R*   t   optionsR1   R=   t   session(    (    s,   /tmp/pip-build-5Z5nTX/pip/pip/basecommand.pyt   _build_session@   s     -		!	
c         C@  s   |  j  j | ƒ S(   N(   R"   t
   parse_args(   R*   t   args(    (    s,   /tmp/pip-build-5Z5nTX/pip/pip/basecommand.pyRF   d   s    c         @  sé  |  j  | ƒ \ } } | j rW | j d k r6 d ‰  n  | j d k rN d ‰  qo d ‰  n | j ri d ‰  n d ‰  t i d d 6t d	 6i i d
 d 6t j d 6d 6d 6i i t d 6| j s¾ d n d d 6d 6d 6i i ˆ  d 6d d 6|  j	 d d 6d g d 6d d 6d 6i d d 6d d 6|  j	 d d 6d d 6d 6i d d 6d d 6| j
 pKd d 6t d 6d d 6d 6d  6i ˆ  d 6t t d  d d | j
 rd n d  g ƒ ƒ d  6d! 6t ‡  f d" †  d# d$ d% d& g Dƒ ƒ d' 6ƒ | j rêt j d( t ƒ n  | j rd) t j d* <n  | j r(d+ j | j ƒ t j d, <n  | j rZt ƒ  sZt j d- ƒ t j t ƒ qZn  z-y) |  j | | ƒ } t  | t! ƒ r…| SWný t" k
 rÂ} t j t# | ƒ ƒ t j$ d. d/ t ƒt% St& t' t( f k
 r} t j t# | ƒ ƒ t j$ d. d/ t ƒt) St* k
 r:} t j d0 | ƒ t j$ d. d/ t ƒt) St+ k
 rkt j d1 ƒ t j$ d. d/ t ƒt) St j d2 d/ t ƒt, SXWd  | j- rät. | d3 t ƒ rä|  j/ | d4 d d5 t0 d6 | j1 ƒ ƒ } t2 | ƒ Wd  QXn  Xt3 S(7   Ni   t   WARNINGi   R   t   CRITICALt   DEBUGt   INFOt   versiont   disable_existing_loggerss    pip.utils.logging.MaxLevelFilters   ()t   levelt   exclude_warningst   filterss   %(message)ss   [%(levelname)s] %(message)st   formatt   indentt
   formatterss(   pip.utils.logging.ColorizedStreamHandlert   classi    t   streamR   t   consolet   console_errorss+   pip.utils.logging.BetterRotatingFileHandlers	   /dev/nullt   filenamet   delayt   user_logt   handlerst   rootc         3@  s4   |  ]* } | i ˆ  d k r! d n d d 6f Vq d S(   RK   R   RH   RJ   RN   N(   s   INFOs   ERROR(    (   t   .0R   (   RN   (    s,   /tmp/pip-build-5Z5nTX/pip/pip/basecommand.pys	   <genexpr>¬   s   
s   pip._vendort   distlibt   requestst   urllib3t   loggerssR   --log-explicit-levels has been deprecated and will be removed in a future version.t   1t   PIP_NO_INPUTt    t   PIP_EXISTS_ACTIONs2   Could not find an activated virtualenv (required).s   Exception information:t   exc_infos	   ERROR: %ss   Operation cancelled by users
   Exception:t   no_indexR1   R=   i   (4   RF   t   quiett   verboseR	   R    t   loggingRH   R   t   log_explicit_levelst   log_streamst   logt   Truet   listt   filterR8   t   dictt   warningst   warnR   R@   R5   t   environt   exists_actionR7   t   require_venvR   t   loggert   criticalt   syst   exitR   t   runt
   isinstancet   intR   t   strt   debugR   R   R   R   R   R   t   KeyboardInterruptR   t   disable_pip_version_checkt   getattrRE   t   minR=   R   R   (   R*   RG   RC   t   statust   excRD   (    (   RN   s,   /tmp/pip-build-5Z5nTX/pip/pip/basecommand.pyt   mainh   s¼    						
	#
	
				 	
N(   s   ext://sys.stdouts   ext://sys.stderr(   t   __name__t
   __module__R8   R   R   R    t   hiddenRl   R.   RE   RF   R†   (    (    (    s,   /tmp/pip-build-5Z5nTX/pip/pip/basecommand.pyR   "   s   $	t   RequirementCommandc           B@  s   e  Z e d  „  ƒ Z RS(   c         C@  s›  xS | j  D]H } x? t | d t d | d | d | d | ƒD] } |  j | ƒ q; Wq
 Wx6 | D]. } |  j t j | d d | j d | ƒƒ q] Wx? | j D]4 } |  j t j	 | d | j
 d | j d | ƒƒ q™ Wt }	 xS | j D]H } x? t | d | d | d | d | ƒD] } t }	 |  j | ƒ qWqá W| p?| j p?|	 s—i | d 6}
 | j r}d	 t |
 d
 d j | j ƒ ƒ} n
 d |
 } t j | ƒ n  d S(   s?   
        Marshal cmd line args into a requirement set.
        t
   constraintt   finderRC   RD   t   wheel_cacheR   t   default_vcsR   s^   You must give at least one requirement to %(name)s (maybe you meant "pip %(name)s %(links)s"?)t   linksRd   sL   You must give at least one requirement to %(name)s (see "pip help %(name)s")N(   t   constraintsR   Rn   t   add_requirementR   t	   from_lineR8   t   isolated_modet	   editablest   from_editableRŽ   R    t   requirementst
   find_linksRq   R7   Rw   t   warning(   t   requirement_setRG   RC   RŒ   RD   R   R   RX   t   reqt   found_req_in_filet   optst   msg(    (    s,   /tmp/pip-build-5Z5nTX/pip/pip/basecommand.pyt   populate_requirement_setÿ   sD    			"(   R‡   Rˆ   t   staticmethodRž   (    (    (    s,   /tmp/pip-build-5Z5nTX/pip/pip/basecommand.pyRŠ   ý   s   (2   R!   t
   __future__R    Rj   R5   Ry   R$   Rr   t   pipR   t   pip.locationsR   t   pip.downloadR   t   pip.exceptionsR   R   R   R   R   t
   pip.compatR	   t   pip.baseparserR
   R   t   pip.reqR   R   t   pip.status_codesR   R   R   R   R   t	   pip.utilsR   R   t   pip.utils.deprecationR   t   pip.utils.loggingR   t   pip.utils.outdatedR   t   __all__t	   getLoggerR‡   Rw   t   objectR   RŠ   (    (    (    s,   /tmp/pip-build-5Z5nTX/pip/pip/basecommand.pyt   <module>   s,   ((	Û