
kMc           @   s  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 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 m Z m Z d  d l m Z m Z d  d l m Z m Z m Z d  d	 l m Z m Z 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$ m% Z% m& Z& m' Z' m( Z( m) Z) d  d l* m+ Z+ d  d l m, Z, d  d l- m. Z. m/ Z/ m0 Z0 m1 Z1 m2 Z2 m3 Z3 m4 Z4 m5 Z5 m6 Z6 m7 Z7 d Z8 d e9 f d     YZ: d Z; d e9 f d     YZ< d e9 f d     YZ= d   Z> d   Z? e j@ d e jA  ZB eC eC eC d  ZD eC d  ZE d e9 f d     YZF d e9 f d      YZG d! e9 f d"     YZH d S(#   iN(   t   bin_pyt   running_under_virtualenv(   t   InstallationErrort   UninstallationError(   t   vcs(   t   logger(   t   display_patht   rmtree(   t   askt
   backup_dir(   t   is_installable_dirt   is_localt   dist_is_local(   t   renamest   normalize_patht   egg_link_path(   t   make_path_relative(   t   call_subprocess(
   t   anyt   copytreet   urlparset   urllibt   ConfigParsert   string_typest	   HTTPErrort
   FeedParsert   get_python_versiont   b(   t   Link(   t   build_prefix(
   t   get_file_contentt   is_urlt   url_to_patht   path_to_urlt   is_archive_filet   unpack_vcs_linkt
   is_vcs_urlt   is_file_urlt   unpack_file_urlt   unpack_http_urls   pip-delete-this-directory.txtt   InstallRequirementc           B   s  e  Z d% e d% e d   Z e d% d% d   Z e d% d   Z d   Z	 d   Z
 e d  Z d   Z e d    Z e d    Z e d	    Z e d
  Z d Z d   Z d   Z d   Z d   Z e d    Z e j d  Z d& d  Z e d    Z e d    Z d   Z e d  Z e d  Z  d   Z! d   Z" d   Z# d   Z$ d' d  Z% d   Z& d( d  Z' d   Z( d    Z) e d!    Z* d"   Z+ d#   Z, e d$    Z- RS()   c         C   s   t  | t  r$ t j j |  } n  | |  _ | |  _ | |  _ | |  _ | |  _	 d  |  _ d  |  _ d  |  _ d  |  _ d  |  _ | |  _ d  |  _ d  |  _ d  S(   N(   t
   isinstanceR   t   pkg_resourcest   Requirementt   parset   reqt
   comes_fromt
   source_dirt   editablet   urlt   Nonet   _egg_info_patht   satisfied_byt   conflicts_witht   _temp_build_dirt
   _is_bundlet   updatet   install_succeededt   uninstalled(   t   selfR-   R.   R/   R0   R1   R8   (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyt   __init__#   s    												c      	   C   sX   t  | |  \ } } | j d  r3 t |  } n d  } |  | | d | d t d | S(   Ns   file:R/   R0   R1   (   t   parse_editablet
   startswithR    R2   t   True(   t   clst   editable_reqR.   t   default_vcst   nameR1   R/   (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyt   from_editable<   s
    c         C   s  d } | j   } | } t j j t j j |   } t |  rQ | } d } n t j j |  r t j j | k s | j	 d  r t
 |  s t d |   n  t |  } d } nG t |  r t j j |  s t j d |  n  t |  } d } n  |  | | d | S(   s   Creates an InstallRequirement from a name, which might be a
        requirement, directory containing 'setup.py', filename, or URL.
        t   .s;   Directory %r is not installable. File 'setup.py' not found.sA   Requirement %r looks like a filename, but the file does not existR1   N(   R2   t   stript   ost   patht   normpatht   abspathR   t   isdirt   sepR>   R
   R   R!   R"   t   isfileR   t   warn(   R@   RC   R.   R1   R-   RH   (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyt	   from_lineE   s(    	3			c         C   s   |  j  r8 t |  j   } |  j rA | d |  j 7} qA n	 |  j } |  j d  k	 rm | d t |  j j  7} n  |  j r t |  j t	  r |  j } n |  j j
   } | r | d | 7} q n  | S(   Ns    from %ss    in %ss
    (from %s)(   R-   t   strR1   R4   R2   R   t   locationR.   R)   R   t	   from_path(   R;   t   sR.   (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyt   __str__d   s    				c         C   sv   |  j  d  k r d  St |  j   } |  j rr t |  j t  rI |  j } n |  j j   } | rr | d | 7} qr n  | S(   Ns   ->(   R-   R2   RP   R.   R)   R   RR   (   R;   RS   R.   (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyRR   v   s    	c         C   s   |  j  d  k	 r |  j  S|  j d  k rJ t j d d  |  _  | |  _ |  j  S|  j re |  j j   } n	 |  j } t	 j
 j |  s t |  n  t	 j
 j | |  S(   Ns   -builds   pip-(   R6   R2   R-   t   tempfilet   mkdtempt   _ideal_build_dirR0   RC   t   lowerRG   RH   t   existst   _make_build_dirt   join(   R;   t	   build_dirt   unpackRC   (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyt   build_location   s    			c         C   s8  |  j  d k	 r d S|  j d k	 s( t  |  j s7 t  |  j } |  j } |  ` |  j rj |  j j   } n	 |  j } t	 j
 j | |  } t	 j
 j |  s t j d |  t |  n  t	 j
 j |  r t d t |    n  t j d |  t |  t |  f  t j | |  | |  _ | |  _  d |  _ d S(   sk   If the build location was a temporary directory, this will move it
        to a new more permanent locationNs   Creating directory %ss<   A package already exists in %s; please remove it to continues,   Moving package %s from %s to new location %s(   R/   R2   R-   t   AssertionErrorR6   RW   R0   RC   RX   RG   RH   R[   RY   R   t   debugRZ   R   R   t   shutilt   moveR3   (   R;   t   old_locationt   new_build_dirRC   t   new_location(    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyt   correct_build_location   s0    							c         C   s   |  j  d  k r d  S|  j  j S(   N(   R-   R2   t   project_name(   R;   (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyRC      s    c         C   s&   |  j  d  k r d  St j |  j  j  S(   N(   R-   R2   R   t   quotet   unsafe_name(   R;   (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyt   url_name   s    c         C   s   t  j j |  j d  S(   Ns   setup.py(   RG   RH   R[   R/   (   R;   (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyt   setup_py   s    c         C   s  |  j  s t  |  j r/ t j d |  j  n t j d |  j  t j d 7_ z |  j } | j d t	 |  j
   } | j d t	 |  j   } |  j s | r g  } nF t j j |  j  d  } t j j |  s t j |  n  d d g } t t j d | d	 g | d
 |  j  d |  j d t d t j d d Wd  t j d 8_ X|  j st j j d |  j    |  _ |  j   n  d  S(   Ns(   Running setup.py egg_info for package %ss-   Running setup.py egg_info for package from %si   t   __SETUP_PY__t   __PKG_NAME__s   pip-egg-infos
   --egg-bases   -ct   egg_infot   cwdt   filter_stdoutt   show_stdoutt   command_levelt   command_descs   python setup.py egg_infos   %(Name)s==%(Version)s(   R/   R_   RC   R   t   notifyR1   t   indentt   _run_setup_pyt   replacet   reprRk   R0   RG   RH   R[   RY   t   makedirsR   t   syst
   executablet   _filter_installt   Falset   VERBOSE_DEBUGR-   R*   R+   R,   t   pkg_infoRf   (   R;   t   force_root_egg_infot   scriptt   egg_base_optiont   egg_info_dir(    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyt   run_egg_info   s2    						s7  
__file__ = __SETUP_PY__
from setuptools.command import egg_info
def replacement_run(self):
    self.mkpath(self.egg_info)
    installer = self.distribution.fetch_build_egg
    for ep in egg_info.iter_entry_points('egg_info.writers'):
        # require=False is the change we're making:
        writer = ep.load(require=False)
        if writer:
            writer(self, ep.name, egg_info.os.path.join(self.egg_info,ep.name))
    self.find_sources()
egg_info.egg_info.run = replacement_run
exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))
c         C   s   |  j  d  k	 r5 |  j  j |  s% d  S|  j  j |  S|  j sD t  |  j |  } t j j	 |  si d  St
 | d  } | j   } | j   | S(   Nt   r(   R4   R2   t   has_metadatat   get_metadataR/   R_   t   egg_info_pathRG   RH   RY   t   opent   readt   close(   R;   t   filenamet   fpt   data(    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyt   egg_info_data   s    
c   	   	   C   s3  |  j  d  k r|  j r$ |  j } n t j j |  j d  } t j |  } |  j rg  } xt j |  D]\ } } } x- t	 j
 D]" } | | k r | j |  q q Wx | D] } t j j t j j | | d d   st j j t j j | | d d   r| j |  n  | d k s,| d k r | j |  q q W| j g  | D] } t j j | |  ^ qM qj Wg  | D] } | j d  rz| ^ qz} n  | st d	 | | f   n  | st d
 | | f  t |  d k r| j d d    n  t j j | | d  |  _  n  t j j |  j  |  S(   Ns   pip-egg-infot   bint   pythont   Scriptss
   Python.exet   testt   testss	   .egg-infos#   No files/directores in %s (from %s)s$   No files/directories in %s (from %s)i   t   keyc         S   s8   |  j  t j j  t j j r3 |  j  t j j  p6 d S(   Ni    (   t   countRG   RH   RL   t   altsep(   t   x(    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyt   <lambda>!  s   i    (   R3   R2   R0   R/   RG   RH   R[   t   listdirt   walkR   t   dirnamest   removeRY   t   extendt   endswithR   R_   t   lent   sort(	   R;   R   t   baset	   filenamest   roott   dirst   filest   dirt   f(    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyR      s6    		''	*+c         C   so   |  j  |  } | s g  Sg  } xI | j   D]; } | j   } | s, | j d  rZ q, n  | j |  q, W| S(   Nt   #(   R   t
   splitlinesRF   R>   t   append(   R;   R   R   t   resultt   line(    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyt   egg_info_lines'  s    c         C   s^   t    } |  j d  } | sA t j d t |  j d    n  | j | pP d  | j   S(   Ns   PKG-INFOs   No PKG-INFO file found in %st    (   R   R   R   RN   R   R   t   feedR   (   R;   t   pR   (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyR   3  s    	#c         C   s   |  j  d  S(   Ns   dependency_links.txt(   R   (   R;   (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyt   dependency_links;  s    s	   \[(.*?)\]c         c   sn   d  } xa |  j d  D]P } |  j j |  } | rI | j d  } q n  | ra | | k ra q n  | Vq Wd  S(   Ns   requires.txti   (   R2   R   t   _requirements_section_ret   matcht   group(   R;   t   extrast   in_extraR   R   (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyt   requirementsA  s    c         c   s5   x. |  j  j D]  \ } } | d k r | Vq q Wd  S(   Ns   ==(   R-   t   specs(   R;   t	   qualifiert   version(    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyt   absolute_versionsM  s    c         C   s   |  j    d S(   NR   (   R   (   R;   (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyt   installed_versionS  s    c         C   s   |  j  s t  |  j d  k r" d  S|  j } | |  j k r t j d t |  j   | |  f  t	 d t |  j   | |  f   n# t j
 d t |  j   | |  f  d  S(   NsH   Source in %s has the version %s, which does not match the requirement %ss2   Source in %s has version %s that conflicts with %ss;   Source in %s has version %s, which satisfies requirement %s(   R/   R_   R.   R2   R   R-   R   t   fatalR   R   R`   (   R;   R   (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyt   assert_source_matches_versionW  s    		c         C   s  |  j  s! t j d |  j  d  S|  j s0 t  |  j s? t  |  j  j d  rU d  Sd |  j  k st t d |  j   |  j s d  S|  j  j d d  \ } } t	 j
 |  } | r | |  j   } | r | j |  j  q| j |  j  n d st d |  j  | f  d  S(   Ns>   Cannot update repository at %s; repository location is unknowns   file:t   +s   bad url: %ri   i    s+   Unexpected version control type (in %s): %s(   R1   R   t   infoR/   R0   R_   R>   R8   t   splitR   t   get_backendt   obtaint   export(   R;   R   t   vc_typeR1   t   backendt   vcs_backend(    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyt   update_editablei  s(    			c         C   s  |  j    s% t d |  j f   n  |  j p4 |  j } t |  } t j j | j	 | j
   j d  d  d } | j d t j d  } | j
   d } t |  } t j j |  } t j j |  }	 | s |	 r!| r | }
 n | }
 | j |
  | j d  rYxN | j d  j   D]4 } t j j t j j |
 |   } | j |  qWn  | j d	  r6| j d
  r| j d
  } n g  } x g  | j d	  j   D] } | r| | k r| ^ qD]M } t j j | j	 |  } | j |  | j | d  | j | d  qWq6n| j	 j |  r~| j | j	  t j j t j j | j	  d  } | j | d |  n t j j |  r6t | d  } t j j | j   j    } | j   | | j	 k st d | |  j | j	 f  | j |  t j j t j j |  d  } | j | | j	  n  | j d  r| j  d  rxh | j! d  D]T } | j t j j t" |   t# j$ d k rd| j t j j t" |  d  qdqdWn  | j d  rt% j&   } | j' t( | j) d    | j* d  rx | j+ d  D] \ } } | j t j j t" |   t# j$ d k r| j t j j t" |  d  | j t j j t" |  d  | j t j j t" |  d  qqWqn  | j, |  | |  _- d S(   s  
        Uninstall the distribution currently satisfying this requirement.

        Prompts before removing or modifying files unless
        ``auto_confirm`` is True.

        Refuses to delete or modify files outside of ``sys.prefix`` -
        thus uninstallation within a virtual environment can only
        modify that virtual environment, even if the virtualenv is
        linked to global site-packages.

        s.   Cannot uninstall requirement %s, not installeds   -pyi    s	   .egg-infos   -py%sR   s   .eggs   installed-files.txts   top_level.txts   namespace_packages.txts   .pys   .pycs   easy-install.pths   ./R   s;   Egg-link %s does not match installed location of %s (at %s)t   scriptst   win32s   .bats   entry_points.txtt   console_scriptss   .exes   .exe.manifests
   -script.pyN(.   t   check_if_existsR   RC   R4   R5   t   UninstallPathSetRG   RH   R[   RQ   t   egg_nameR   Rw   R*   t   PY_MAJORR   RY   t   addR   R   R   RI   R   t   dirnamet   add_pthRM   R   t   normcaset   readlineRF   R   R_   t   metadata_isdirt   metadata_listdirR    Rz   t   platformR   t   SafeConfigParsert   readfpt   FakeFilet   get_metadata_linest   has_sectiont   itemsR   R:   (   R;   t   auto_confirmt   distt   paths_to_removet   pip_egg_info_patht   debian_egg_info_patht   easy_install_eggt   develop_egg_linkt   pip_egg_info_existst   debian_egg_info_existsR   t   installed_fileRH   t
   namespacesR   t   top_level_pkgt   easy_install_ptht   fht   link_pointerR   t   configRC   t   value(    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyt	   uninstall  s~     	!"	
+	*  -c         C   s4   |  j  r |  j  j   n t j d |  j f  d  S(   Ns'   Can't rollback %s, nothing uninstalled.(   R:   t   rollbackR   t   errorRg   (   R;   (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyt   rollback_uninstall  s    		c         C   s4   |  j  r |  j  j   n t j d |  j f  d  S(   Ns%   Can't commit %s, nothing uninstalled.(   R:   t   commitR   R   Rg   (   R;   (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyt   commit_uninstall  s    		c         C   s  |  j  s t  t } d |  j |  j f } t j j | |  } t j j |  rt	 d t
 |  d  } | d k r t } q| d k r t j d t
 |   t j |  q| d k rt |  } t j d t
 |  t
 |  f  t j | |  qn  | rt j | d t j  } t j j t j j |  j    } xt j |  D] \ }	 }
 } d |
 k r~|
 j d  n  xl |
 D]d } t j j |	 |  } |  j | |  } t j |  j d	 | d	  } d | _ | j | d  qWxb | D]Z } | t k rqn  t j j |	 |  } |  j | |  } | j | |  j d	 |  qWqSW| j   t j d 8_ t j  d t
 |   n  d  S(   Ns	   %s-%s.zips/   The file %s exists. (i)gnore, (w)ipe, (b)ackup t   it   wR   s   Deleting %ss   Backing up %s to %ss   pip-egg-infot   /i  i   R   i   s   Saved %s(   R   R   R   i  (!   R/   R_   R?   RC   R   RG   RH   R[   RY   R   R   R}   R   RN   R   R	   Ra   Rb   t   zipfilet   ZipFilet   ZIP_DEFLATEDR   RJ   R   t   _clean_zip_namet   ZipInfot   external_attrt   writestrt   PIP_DELETE_MARKER_FILENAMEt   writeR   Ru   Rt   (   R;   R\   t   create_archivet   archive_namet   archive_patht   responset	   dest_filet   zipR   t   dirpathR   R   R   RC   t   zipdirR   (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyt   archive  sL    		!	#
c         C   s\   | j  | t j j  s, t d | | f  | t |  d } | j t j j d  } | S(   Ns$   name %r doesn't start with prefix %ri   R   (   R>   RG   RH   RL   R_   R   Rw   (   R;   RC   t   prefix(    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyR     s
    c         C   s  |  j  r |  j | |  d  St j d d  } t j j | d  } zt j d d |  j	 g t
 |  d d d | g } t   r | d	 t j j t j d
 d d t    g 7} n  t j d |  j  t j d 7_ z* t | | d |  j d |  j d t Wd  t j d 8_ Xt j j |  s<t j d |  d  St |  _ t |  } xH | D]+ } | j   } | j d  rX| } PqXqXWt j d |   d  S| j   g  }	 t |  } xU | D]M } | j   }
 t j j |
  r|
 t j j 7}
 n  |	 j  t! |
 |   qW| j   t t j j | d  d  } | j" d j |	  d  | j   Wd  t j j |  rt j# |  n  t j$ |  Xd  S(   Ns   -records   pip-s   install-record.txts   -csj   import setuptools;__file__=%r;exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))t   installs#   --single-version-externally-manageds   --records   --install-headerst   includet   siteR   s   Running setup.py install for %si   Ro   Rp   Rq   s   Record file %s not founds	   .egg-infos;   Could not find .egg-info directory in install record for %ss   installed-files.txtR   s   
(%   R0   t   install_editableRU   RV   RG   RH   R[   Rz   R{   Rk   t   listR   R  R   R   Rt   RC   Ru   R   R/   R|   R}   RY   R?   R9   R   RF   R   RN   R   RK   RL   R   R   R  R   t   rmdir(   R;   t   install_optionst   global_optionst   temp_locationt   record_filenamet   install_argsR   R   R   t	   new_linesR   (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyR    s^    	 		

c         C   s   |  j  s t j j |  j  rW t j d |  j  |  j rK t |  j  n  d |  _ n  |  j
 r t j j |  j
  r t |  j
  n  d |  _
 d S(   sV   Remove the source files from this requirement, if they are marked
        for deletions   Removing source in %sN(   t	   is_bundleRG   RH   RY   t   delete_marker_filenameR   R   R/   R   R2   R6   (   R;   (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyt   remove_temporary_sourceY  s    	c         C   s   t  j d |  j  t  j d 7_ zW t t j d d |  j g t |  d d g t |  d |  j	 d |  j
 d	 t Wd  t  j d 8_ Xt |  _ d  S(
   Ns   Running setup.py develop for %si   s   -csl   import setuptools; __file__=%r; exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))t   develops	   --no-depsRo   Rp   Rq   (   R   Rt   RC   Ru   R   Rz   R{   Rk   R  R/   R|   R}   R?   R9   (   R;   R  R  (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyR  e  s    7c         C   sa   t  j } xK d d d d d d d d g D]+ } t j | | j    r( t  j } Pq( q( W| | f S(	   Ns   ^running .*s   ^writing .*s   ^creating .*s   ^[Cc]opying .*s   ^reading .*s4   ^removing .*\.egg-info' \(and everything under it\)$s   ^byte-compiling s7   ^warning: manifest_maker: standard file '-c' not found$(   R   t   NOTIFYt   ret   searchRF   t   INFO(   R;   R   t   levelt   regex(    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyR|   u  s    		c         C   ss   |  j  d k r t Sy t j |  j   |  _ Wn@ t j k
 rC t St j k
 rn t j |  j  j  |  _	 n Xt
 S(   s   Find an installed distribution that satisfies or conflicts
        with this requirement, and set self.satisfied_by or
        self.conflicts_with appropriately.N(   R-   R2   R}   R*   t   get_distributionR4   t   DistributionNotFoundt   VersionConflictRg   R5   R?   (   R;   (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyR     s    c         C   su   |  j  d  k	 r |  j  S|  j } | s) t St j j t j j | d   ph t j j t j j | d   |  _  |  j  S(   Ns   pip-manifest.txts   pyinstall-manifest.txt(   R7   R2   R6   R}   RG   RH   RY   R[   (   R;   R   (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyR    s    	!$c   
      c   s;  x |  j  D] } t j j |  } x t j D] } d  } } t j j | | j  } t j j	 |  r, | j
 } t |  } | j   }	 | j   |   j |	  \ } } Pq, q, W| r d | | | f } n d  } t | |  d t d | d t d | Vq
 Wx7 |  j D], } t j j |  } t | |  d | VqWd  S(   Ns   %s+%s@%sR0   R1   R8   R/   (   t   _bundle_editable_dirsRG   RH   t   basenameR   t   backendsR2   R[   t   bundle_fileRY   RC   R   R   R   t   parse_vcs_bundle_fileR(   R?   R}   t   _bundle_build_dirs(
   R;   t   dest_dirt   packageR   R1   t   revt   vcs_bundle_fileR   R   t   content(    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyt   bundle_requirements  s0    
		
	c         C   s  |  j  } | s t  t j j | d  } t j j | d  } g  } g  } x#| | | f | | | f g D]\ } }	 }
 t j j |  rj x t j |  D] } t j j |	 |  } |
 j |  t j j |  r t j	 d | | |  f  q n  t j j |	  s(t j
 d |	  t j |	  n  t j t j j | |  |  q Wt j |  smt j |  qmqj qj Wd  |  _  | |  _ | |  _ d  S(   Nt   srct   buildsZ   The directory %s (containing package %s) already exists; cannot move source from bundle %ss   Creating directory %s(   R6   R_   RG   RH   R[   RY   R   R   R   RN   R   Ry   Ra   Rb   R  R2   R*  R%  (   R;   t   dest_build_dirt   dest_src_dirR   t   src_dirR\   t   bundle_build_dirst   bundle_editable_dirsR/   R+  t   dir_collectionR   t   dest(    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyt   move_bundle_files  s4    		#		c         C   s%   |  j  s t  t j j |  j  t  S(   N(   R/   R_   RG   RH   R[   R   (   R;   (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyR    s    N(    (    (    (.   t   __name__t
   __module__R2   R}   R?   R<   t   classmethodRD   RO   RT   RR   R^   Rf   t   propertyRC   Rj   Rk   R   Rv   R   R   R   R   R   R  t   compileR   R   R   R   R   R   R   R   R   R
  R   R  R  R  R|   R   R  R0  R:  R  (    (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyR(   !   sP   			0		'			]			(	=					s   This file is placed here by pip to indicate the source was put
here by pip.

Once this package is successfully installed this source code will be
deleted (unless you remove this file).
t   Requirementsc           B   sG   e  Z d    Z d   Z d   Z d   Z d   Z d   Z d   Z RS(   c         C   s   g  |  _  i  |  _ d  S(   N(   t   _keyst   _dict(   R;   (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyR<     s    	c         C   s   |  j  S(   N(   RA  (   R;   (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyt   keys  s    c         C   s2   g  } x% |  j  D] } | j |  j |  q W| S(   N(   RA  R   RB  (   R;   t   values_listR   (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyt   values  s    c         C   s   | |  j  k S(   N(   RA  (   R;   t   item(    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyt   __contains__  s    c         C   s3   | |  j  k r" |  j  j |  n  | |  j | <d  S(   N(   RA  R   RB  (   R;   R   R   (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyt   __setitem__  s    c         C   s   |  j  | S(   N(   RB  (   R;   R   (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyt   __getitem__  s    c         C   sJ   g  |  j    D]& } d t |  t |  |  f ^ q } d d j |  S(   Ns   %s: %ss   Requirements({%s})s   , (   RC  Rx   R[   (   R;   t   kRE  (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyt   __repr__  s    9(	   R;  R<  R<   RC  RE  RG  RH  RI  RK  (    (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyR@    s   						t   RequirementSetc           B   s   e  Z d e e e d   Z d   Z d   Z d   Z e d    Z	 e d    Z
 e d    Z d   Z e d  Z d	   Z e e d
  Z e d  Z d   Z d   Z e d  Z d d  Z d   Z d Z d   Z d   Z RS(   c         C   s|   | |  _  | |  _ | |  _ | |  _ | |  _ | |  _ t   |  _ i  |  _ g  |  _	 | |  _
 g  |  _ g  |  _ g  |  _ d  S(   N(   R\   R5  t   download_dirt   download_cachet   upgradet   ignore_installedR@  R   t   requirement_aliasest   unnamed_requirementst   ignore_dependenciest   successfully_downloadedt   successfully_installedt   reqs_to_cleanup(   R;   R\   R5  RM  RN  RO  RP  RS  (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyR<     s    											c         C   sg   g  |  j  j   D] } | j s | ^ q } | j d d    d j g  | D] } t | j  ^ qK  S(   NR   c         S   s   |  j  j   S(   N(   RC   RX   (   R-   (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyR     s    t    (   R   RE  R.   R   R[   RP   R-   (   R;   R-   t   reqs(    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyRT     s    c         C   s   | j  } | s" |  j j |  ni |  j |  rV t d | |  j |  | f   n  | |  j | <| j   | k r | |  j | j   <n  d  S(   Ns4   Double requirement given: %s (aready in %s, name=%r)(	   RC   RR  R   t   has_requirementR   t   get_requirementR   RX   RQ  (   R;   t   install_reqRC   (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyt   add_requirement  s    	c         C   sC   x< | | j    f D]( } | |  j k s7 | |  j k r t Sq Wt S(   N(   RX   R   RQ  R?   R}   (   R;   Rg   RC   (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyRY  )  s    c         C   s   t  |  j j    p |  j S(   N(   R  R   RE  RR  (   R;   (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyt   has_requirements/  s    c         C   sD   t  d   |  j j   D  r# t St  d   |  j D  r@ t St S(   Nc         s   s   |  ] } | j  Vq d  S(   N(   R0   (   t   .0R-   (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pys	   <genexpr>5  s    c         s   s   |  ] } | j  Vq d  S(   N(   R0   (   R^  R-   (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pys	   <genexpr>7  s    (   R   R   RE  R?   RR  R}   (   R;   (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyt   has_editables3  s
    c         C   sg   |  j  rc t j j |  j   |  _  t j j |  j   r: t St j d  t d t	 |  j     n  t
 S(   Ns!   Could not find download directorys0   Could not find or access download directory '%s'(   RM  RG   RH   t
   expanduserRY   R?   R   R   R   R   R}   (   R;   (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyt   is_download;  s    	c         C   sl   xU | | j    f D]A } | |  j k r3 |  j | S| |  j k r |  j |  j | Sq Wt d |   d  S(   Ns   No project with the name %r(   RX   R   RQ  t   KeyError(   R;   Rg   RC   (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyRZ  H  s    c         C   s8   x1 |  j  j   D]  } | j d |  | j   q Wd  S(   NR   (   R   RE  R   R   (   R;   R   R-   (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyR   P  s    c         C   sr  t  |  j  } t  |  j j    } xG| s3 | rm| rK | j d  } n | j d  } t } |  j r | j r | j   | j	 r |  j
 r | j	 | _ d  | _	 q t } n  | j	 r t j d |  q n  | j r| j d  k r)| j |  j  | _ q)n% | r)| j |  j |  j  | _ n  | j d  k	 r' t j j | j  r' t d | | j f   q' q' Wd  S(   Ni    s<   Requirement already satisfied (use --upgrade to upgrade): %ss   Could not install requirement %s because source folder %s does not exist (perhaps --no-download was used without first running an equivalent install with --no-install?)(   R  RR  R   RE  t   popR?   RP  R0   R   R4   RO  R5   R2   R}   R   Rt   R/   R^   R5  R\   Ra  RG   RH   RK   R   (   R;   t   unnamedRX  t   req_to_installt   install_needed(    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyt   locate_filesU  s2    
						%c         C   s  t  |  j  } t  |  j j    } x| s3 | r| rK | j d  } n | j d  } t } |  j r | j r | j   | j	 r |  j
 r | j	 | _ d | _	 q t } n  | j	 r t j d |  q n  | j r t j d |  n^ | rL| j r8| j j   j d  r8t j d t t | j    qLt j d |  n  t j d 7_ zht } | j r| j d k r| j |  j  }	 |	 | _ n	 | j }	 t j j |  j  st |  j  n  | j |  j  |  j r| j    | j! |  j"  qd| j    nX| rd| j |  j |  j  }	 t }
 t j j t j j# |	 d   s| j d k r|| j$ | d	 |  j
 } n t% | j  } | st&  | ry |  j' | |	 |  j  Wqt( k
 r
t) j*   d
 } t j+ d | | f  t, d | | | f   qXqt }
 n  |
 rd| j- } d } | r|| j. |  j |  j  x | j/   D]  } | j0 |  |  j1 |  qUWn |  j r|	 | _ | r!| j2 t3 j4 k r!| j    | j! |  j"  q!n[ |	 | _ | j    | r| j  d t  n  | j5   | r!| j r!|  j6 |  t } n  | j   | j	 ra|  j
 rU| j	 | _ d | _	 q^t } qaqdn  | rh|  j rh| j7 | j8  |  j9 s@x | j   D] } y t: j; j< |  j= } Wn> t> k
 rt) j*   d
 } t j? d | | | f  qn X|  j@ |  rqn  tA | |  } | j0 |  |  j1 |  qWn  | jB |  j k rx| |  j | jB <qxn |  jC j0 |  | r|  jD j0 |  | r| j r| j j d  r|  j6 |  qn  Wd t j d 8_ Xq' Wd S(   sG   Prepare process. Create temp directories, download and/or unpack files.i    s<   Requirement already satisfied (use --upgrade to upgrade): %ss   Obtaining %ss   file:s   Unpacking %ss   Downloading/unpacking %si   s   setup.pyRO  i   s4   Could not install requirement %s because of error %ssD   Could not install requirement %s because of HTTP error %s for URL %sR   s.   Invalid requirement: %r (%s) in requirement %ss   file:///N(E   R  RR  R   RE  Rc  R?   RP  R0   R   R4   RO  R5   R2   R}   R   Rt   R1   RX   R>   R   R    Ru   R/   R^   R5  RG   RH   RY   R\   RZ   R   Ra  R   R
  RM  R[   t   find_requirementR   R_   t
   unpack_urlR   Rz   t   exc_infoR   R   R  R:  R0  R   R\  t   schemeR   t   all_schemesR   t   copy_to_build_dirt   add_dependency_linksR   RS  R*   R+   R,   Rg   t
   ValueErrorR   RY  R(   RC   RV  RT  (   R;   t   finderR   t   bundleRd  RX  Re  R  R  RQ   R]   R1   t   et   subreqR-   RC   (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyt   prepare_filesz  s    
						!#			
!					
	

	
			!c         C   s   t  j d  t  j d 7_ x |  j D] } | j   q& Wg  } |  j   r_ | j |  j  n  | rx | j |  j  n  x> | D]6 } t	 j
 j |  r t  j d |  t |  q q Wt  j d 8_ d S(   s   Clean up files, remove builds.s   Cleaning up...i   s   Removing temporary dir %s...N(   R   Rt   Ru   RV  R  t   _pip_has_created_build_dirR   R\   R5  RG   RH   RY   R   R   (   R;   Rq  R-   t
   remove_dirR   (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyt   cleanup_files  s    c         C   s1   |  j  t k o0 t j j t j j |  j  t   S(   N(   R\   R   RG   RH   RY   R[   R   (   R;   (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyRu    s    c         C   sx   | j  r |  j p |  j } t j d | j | f  t j j | | j  } t	 | j
 |  t d d | d g  d  S(   Ns   Copying %s to %sR   s   %s/setup.pyt   clean(   R0   R5  R\   R   R   RC   RG   RH   R[   R   R/   R   (   R;   Re  t
   target_dirR9  (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyRm    s
    c         C   s   | r |  j  } n  t |  r. t | | |  St |  rG t | |  S|  j rk t j j |  j  |  _ n  t	 | | |  j |  Sd  S(   N(
   RM  R$   R#   R%   R&   RN  RG   RH   R`  R'   (   R;   t   linkRQ   t   only_download(    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyRi  &  s    	c         C   sr  g  |  j  j   D] } |  j s) | j r | ^ q } | rn t j d d j g  | D] } | j ^ qQ   n  t j d 7_ z x | D] } | j	 r t j d | j	  t j d 7_ z | j
 d t  Wd t j d 8_ Xn  y | j | |  Wn* | j	 r| j r| j   n    n  X| j	 rC| j rC| j   n  | j   q WWd t j d 8_ X| |  _ d S(   sR   Install everything in this set (after having downloaded and unpacked the packages)s!   Installing collected packages: %ss   , i   s   Found existing installation: %sR   N(   R   RE  RO  R4   R   Rt   R[   RC   Ru   R5   R   R?   R  R9   R   R   R  RU  (   R;   R  R  R   t
   to_installR-   t   requirement(    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyR  2  s2    3		c         C   s  t  j | d t  j  } g  } xJ|  j d f |  j d f f D]*\ } } t j j t j j |   } xt j	 |  D]\ } } } x t
 j D] }	 |	   }
 d  } } |
 j | k r xR | D] } | j |  r Pq q W|
 j t j j | |   \ } } | j |  |
 j } |
 j i | d 6| d 6} | j |
 j  Pq q Wd | k re| j d  n  xQ | D]I } t j j | |  } |  j | |  } | j | d | d d  qlWx_ | D]W } | t k rqn  t j j | |  } |  j | |  } | j | | d |  qW| rw t j j | |  } |  j | |  } | j | d | |  qw qw Wq= W| j d	 |  j    | j   d  S(
   NR   R2  R1  R1   R-  s   pip-egg-infoR   R   s   pip-manifest.txt(   R   R   R   R\   R5  RG   RH   R   RJ   R   R   R'  R2   R   R>   t   get_infoR[   R   R(  t   guideR   R   R   R   R  R0  R   (   R;   t   bundle_filenameR  t   vcs_dirsR   R&  R  R   R   R   R   t   vcs_urlt   vcs_revt   vcs_dirR.  t	   vcs_guideR   RC   R   (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyt   create_bundleS  sL    +	
	 #s   # This is a pip bundle file, that contains many source packages
# that can be installed as a group.  You can install this like:
#     pip this_file.zip
# The rest of the file contains a list of all the packages included:
c         C   s   |  j  g } xP g  |  j j   D] } | j s | ^ q D]# } | j d | j | j f  q8 W| j d  xP g  |  j j   D] } | j r | ^ q D]# } | j d | j | j f  q Wd j |  S(   Ns   %s==%s
sC   # These packages were installed to satisfy the above requirements:
R   (   t   BUNDLE_HEADERR   RE  R.   R   RC   R   R[   (   R;   t   partsR-   (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyR0    s    !!c         C   s\   | j  | t j j  s, t d | | f  | t |  d } | j t j j d  } | S(   Ns$   name %r doesn't start with prefix %ri   R   (   R>   RG   RH   RL   R_   R   Rw   (   R;   RC   R  (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyR     s
    N(    (   R;  R<  R2   R}   R<   RT   R\  RY  R>  R]  R_  Ra  RZ  R   Rg  Rt  Rw  Ru  Rm  Ri  R  R  R  R0  R   (    (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyRL    s,   					%		!	7	c         C   s*   t  j |   t t  j j |  t   d  S(   N(   RG   Ry   t   _write_delete_marker_messageRH   R[   R   (   R\   (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyRZ     s    c         C   s*   t  |  d  } | j t  | j   d  S(   NR   (   R   R  t   DELETE_MARKER_MESSAGER   (   t   filepatht	   marker_fp(    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyR    s    s   ^(http|https|file):c         c   s  d  } | j } | r' t j |  } n  t |  d | \ }  } xLt | j    D]8\ } } | d 7} | j   } | sR | j d  r qR n  | r | j	 |  r qR n  | j d  s | j d  r| j d  r | d j   }	 n | t
 d  j   j d  }	 t j	 |   r.t j |	 |   }	 n3 t j	 |	  sat j j t j j |   |	  }	 n  x&t |	 | d |  d | D] }
 |
 Vq}WqR | j d	  s| j d
  rqR | j d  s| j d  r+| j d  r| d j   } n | t
 d  j   j d  } | r| j j |  qqR | j d  sI| j d  r| j d  rk| d j   } n | t
 d  j   j d  } | r| g | _ qqR | j d  r| t
 d  j   j d  } | r| j j |  qqR d |  | f } | j d  s| j d  rs| j d  r<| d j   } n | t
 d  j   } t j | d | d | j } n t j | |  } | VqR Wd  S(   NR.   i   R   s   -rs   --requirementi   t   =t   optionss   -Zs   --always-unzips   -fs   --find-linkss   -is   --index-urls   --extra-index-urls   -r %s (line %s)s   -es
   --editableRB   (   R2   t   skip_requirements_regexR  R?  R   t	   enumerateR   RF   R>   R  R   t
   _scheme_reR   t   urljoinRG   RH   R[   R   t   parse_requirementst   lstript
   find_linksR   t
   index_urlsR(   RD   RB   RO   (   R   Rp  R.   R  t
   skip_matcht
   skip_regexR/  t   line_numberR   t   req_urlRF  R-   (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyR    sb    	
$"c   	      C   s  |  } t  j j |  rH t  j j t  j j | d   rH t |  } n  | j   j d  rg d | f Sx: t	 D]2 } | j   j d |  rn d | | f } qn qn Wd | k r | r | d | } q t
 d |    n  | j d d  d j   } t	 j |  st
 d	 |    n  t j d
 |   } | sA| j d  rt	 j |  rg  |  j d d  d j d  D] } | rp| ^ qp} | d d k r| d } q| d d k r| d } qt
 d |    n | j d  } t j d |  } | r| j d  } n  | | f S(   sS   Parses svn+http://blahblah@rev#egg=Foobar into a requirement
    (Foobar) and a URLs   setup.pys   file:s   %s:s   %s+%sR   sJ   --editable=%s should be formatted with svn+URL, git+URL, hg+URL or bzr+URLi   i    ss   For --editable=%s only svn (svn+URL), Git (git+URL), Mercurial (hg+URL) and Bazaar (bzr+URL) is currently supporteds   (?:#|#.*?&)egg=([^&]*)R   R   it   tagst   branchest   tagt   branchiit   trunks@   --editable=%s is not the right format; it must have #egg=Packages   ^(.*?)(?:-dev|-\d.*)$N(   R  R  R  s   branch(   RG   RH   RK   RY   R[   R!   RX   R>   R2   R   R   R   R   R  R  R   (	   RA   RB   R1   t   version_controlR   R   R   R  R-   (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyR=     s@    3
&8R   c           B   sk   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 e
 d  Z d	   Z d
   Z RS(   sM   A set of file paths to be removed in the uninstallation of a
    requirement.c         C   s@   t    |  _ t    |  _ i  |  _ | |  _ d  |  _ g  |  _ d  S(   N(   t   sett   pathst   _refuset   pthR   R2   t   save_dirt   _moved_paths(   R;   R   (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyR<     s    			c         C   s
   t  |  S(   ss   
        Return True if the given path is one we are permitted to
        remove/modify, False otherwise.

        (   R   (   R;   RH   (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyt
   _permitted#  s    c         C   sF   t  |  j  sB t j d |  j j t |  j j  t j f  t	 St
 S(   Ns1   Not uninstalling %s at %s, outside environment %s(   R   R   R   Rt   Rg   R   RQ   Rz   R  R}   R?   (   R;   (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyt   _can_uninstall+  s
    	&c         C   sX   t  |  } t j j |  s" d  S|  j |  rD |  j j |  n |  j j |  d  S(   N(   R   RG   RH   RY   R  R  R   R  (   R;   RH   (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyR   2  s    c         C   sk   t  |  } |  j |  rW | |  j k r@ t |  |  j | <n  |  j | j |  n |  j j |  d  S(   N(   R   R  R  t   UninstallPthEntriesR   R  (   R;   t   pth_filet   entry(    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyR   ;  s    c      	   C   s   t    } x} t | d t D]i } t g  | D]@ } | j |  oi | t | j t j j   t j j k ^ q,  s | j	 |  q q W| S(   s   Compact a path set to contain the minimal number of paths
        necessary to contain all paths in the set. If /a/path/ and
        /a/path/to/a/file.txt are both in the set, leave only the
        shorter path.R   (
   R  t   sortedR   R   R>   t   rstripRG   RH   RL   R   (   R;   R  t   short_pathsRH   t	   shortpath(    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyt   compactD  s    	Mc         C   s5   t  j j |  j t  j j |  d j t  j j   S(   Ni   (   RG   RH   R[   R  t
   splitdriveR  RL   (   R;   RH   (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyt   _stashQ  s    	c         C   s  |  j    s d St j d |  j j  t j d 7_ t |  j |  j   } z6| r` d } n- x | D] } t j |  qg Wt	 d d  } |  j
 r t j d  x* |  j |  j
  D] } t j |  q Wn  | d k rt j d d	 d
 d  |  _ xK | D]C } |  j |  } t j d |  |  j j |  t | |  q Wx! |  j j   D] } | j   qUWt j d |  j j  n  Wd t j d 8_ Xd S(   s[   Remove paths in ``self.paths`` with confirmation (unless
        ``auto_confirm`` is True).Ns   Uninstalling %s:i   t   ys   Proceed (y/n)? t   ns.   Not removing or modifying (outside of prefix):t   suffixs
   -uninstallR  s   pip-s   Removing file or directory %ss   Successfully uninstalled %s(   R  R  (   R  R   Rt   R   Rg   Ru   R  R  R  R   R  RU   RV   R  R  R   R  R   R   R  RE  R   (   R;   R   R  R  RH   t   new_pathR  (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyR   U  s6    		c         C   s   |  j  d k r* t j d |  j j  t St j d |  j j  x> |  j D]3 } |  j	 |  } t j
 d |  t | |  qK Wx |  j D] } | j   q Wd S(   s1   Rollback the changes previously made by remove().s'   Can't roll back %s; was not uninstalleds   Rolling back uninstall of %ss   Replacing %sN(   R  R2   R   R   R   Rg   R}   Rt   R  R  R   R   R  R   (   R;   RH   t   tmp_pathR  (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyR   w  s    c         C   s5   |  j  d k	 r1 t |  j   d |  _  g  |  _ n  d S(   s?   Remove temporary save dir: rollback will no longer be possible.N(   R  R2   R   R  (   R;   (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyR     s    	(   R;  R<  t   __doc__R<   R  R  R   R   R  R  R}   R   R   R   (    (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyR     s   									"	R  c           B   s,   e  Z d    Z d   Z d   Z d   Z RS(   c         C   sG   t  j j |  s% t d |   n  | |  _ t   |  _ d  |  _ d  S(   Ns.   Cannot remove entries from nonexistent file %s(	   RG   RH   RM   R   t   fileR  t   entriesR2   t   _saved_lines(   R;   R  (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyR<     s
    	c         C   sa   t  j j |  } t j d k rM t  j j |  d rM | j d d  } n  |  j j |  d  S(   NR   i    s   \R   (	   RG   RH   R   Rz   R   R  Rw   R  R   (   R;   R  (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyR     s    &c         C   s   t  j d |  j  t |  j d  } | j   } | |  _ | j   t d   | D  rd d } n d } xQ |  j D]F } y, t  j d |  | j	 t
 | |   Wqt t k
 r qt Xqt Wt |  j d  } | j |  | j   d  S(   Ns   Removing pth entries from %s:t   rbc         s   s!   |  ] } t  d   | k Vq d S(   s   
N(   R   (   R^  R   (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pys	   <genexpr>  s    s   
s   
s   Removing entry: %st   wb(   R   R   R  R   t	   readlinesR  R   R   R  R   R   Ro  t
   writelines(   R;   R   t   linest   endlineR  (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyR     s"    	
	c         C   sk   |  j  d  k r' t j d |  j  t St j d |  j  t |  j d  } | j |  j   | j	   t
 S(   Ns.   Cannot roll back changes to %s, none were mades!   Rolling %s back to previous stateR  (   R  R2   R   R   R  R}   R   R   R  R   R?   (   R;   R   (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyR     s    
(   R;  R<  R<   R   R   R   (    (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyR    s   		
	R   c           B   s)   e  Z d  Z d   Z d   Z d   Z RS(   sQ   Wrap a list of lines in an object with readline() to make
    ConfigParser happy.c         C   s   d   | D |  _  d  S(   Nc         s   s   |  ] } | Vq d  S(   N(    (   R^  t   l(    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pys	   <genexpr>  s    (   t   _gen(   R;   R  (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyR<     s    c         C   sL   y3 y t  |  j  SWn t k
 r1 |  j j    SXWn t k
 rG d SXd  S(   NR   (   t   nextR  t	   NameErrort   StopIteration(   R;   (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyR     s    c         C   s   |  j  S(   N(   R  (   R;   (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyt   __iter__  s    (   R;  R<  R  R<   R   R  (    (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyR     s   			(I   Rz   RG   Ra   R  R   R*   RU   t   pip.locationsR    R   t   pip.exceptionsR   R   t   pip.vcsR   t   pip.logR   t   pip.utilR   R   R   R	   R
   R   R   R   R   R   R   t   pipR   t   pip.backwardcompatR   R   R   R   R   R   R   R   R   R   t	   pip.indexR   R   t   pip.downloadR   R   R    R!   R"   R#   R$   R%   R&   R'   R   t   objectR(   R  R@  RL  RZ   R  R?  t   IR  R2   R  R=   R   R  R   (    (    (    s+   /usr/lib/python2.7/dist-packages/pip/req.pyt   <module>   sH   FF   		?+t2