σ
©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 m Z	 d d l
 m 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 d d
 l m Z d g Z e j d e j  Z e j d  Z e j e j e j e j e j e j  e j! e j" e j# e j$ e j% e j& e j' e j( e j) e j* e j+ g Z, e j- e j. g Z/ g  e/ D] Z0 e0   j1 ^ qtZ2 d d d d e4 d d  Z5 d d d d d e4 d  Z6 d   Z7 d   Z8 d   Z9 d   Z: d   Z; d S(   s   
Requirements file parsing
i    (   t   absolute_importN(   t   parse(   t   filterfalse(   t   get_file_content(   t   InstallRequirement(   t   RequirementsFileParseError(   t   normalize_name(   t
   cmdoptionst   parse_requirementss   ^(http|https|file):s   (^|\s)+#.*$c         c@  sΝ   | d k r t d   n  t |  d | d | \ } } | j   }	 t |	  }	 t |	  }	 t |	 |  }	 xZ t |	 d  D]I \ }
 } t | |  |
 | | | | | d | } x | D] } | VqΆ Wq| Wd S(   sϊ  Parse a requirements file and yield InstallRequirement instances.

    :param filename:    Path or url of requirements file.
    :param finder:      Instance of pip.index.PackageFinder.
    :param comes_from:  Origin description of requirements.
    :param options:     Global options.
    :param session:     Instance of pip.download.PipSession.
    :param constraint:  If true, parsing a constraint file rather than
        requirements file.
    :param wheel_cache: Instance of pip.wheel.WheelCache
    sC   parse_requirements() missing 1 required keyword argument: 'session't
   comes_fromt   sessioni   t
   constraintN(	   t   Nonet	   TypeErrorR   t
   splitlinest   ignore_commentst
   join_linest
   skip_regext	   enumeratet   process_line(   t   filenamet   finderR	   t   optionsR
   R   t   wheel_cachet   _t   contentt   linest   line_numbert   linet   req_itert   req(    (    s-   /tmp/pip-build-5Z5nTX/pip/pip/req/req_file.pyR   9   s    	c	         c@  s$  t    }	 |	 j   }
 d |
 _ | r3 | j |
 _ n  t |   \ } } |	 j t j |  |
  \ } } d | ru d n d | | f } | r,| r | j	 n t
 } | rΉ t j | |  n  i  } x> t D]6 } | | j k rΖ | j | rΖ | j | | | <qΖ qΖ Wt j | | d | d | d | d | Vnτ| j r| rD| j	 n t
 } | rY| j n d } t j | j d d	 | d | d
 | d | d | Vn| j s§| j r| j rΖ| j d } t
 } n | j d } t } t j |  rύt j | |  } nE t j |  sBt j j |  } t j j t j j |  |  } n  t | | | | | d | d | }	 x·|	 D] } | VqmWn‘| r | j r | j g | _  n  | j! t
 k rΞt
 | _! t" j# j$ | j  n  | j% t k rιg  | _  n  | j& r| j& | _& n  | j' r | j  j( | j'  n  | j) rc| j) t* g  | j) D] } t+ |  j,   ^ q= O_) n  | j- r¦| j- t* g  | j- D] } t+ |  j,   ^ q O_- n  | j. r | j. d } t j j t j j/ |   } t j j | |  } t j j0 |  r
| } n  | j. j1 |  q n  d S(   sη  Process a single requirements line; This can result in creating/yielding
    requirements, or updating the finder.

    For lines that contain requirements, the only options that have an effect
    are from SUPPORTED_OPTIONS_REQ, and they are scoped to the
    requirement. Other options from SUPPORTED_OPTIONS may be present, but are
    ignored.

    For lines that do not contain requirements, the only options that have an
    effect are from SUPPORTED_OPTIONS. Options from SUPPORTED_OPTIONS_REQ may
    be present, but are ignored. These lines may contain multiple options
    (although our docs imply only one is supported), and all our parsed and
    affect the finder.

    :param constraint: If True, parsing a constraints file.
    s   %s %s (line %s)s   -cs   -rR   t   isolatedR   R   i    R	   t   default_vcsN(2   t   build_parsert   get_default_valuesR   t	   index_urlt   format_controlt   break_args_optionst
   parse_argst   shlext   splitt   isolated_modet   FalseR   t   check_install_build_globalt   SUPPORTED_OPTIONS_REQ_DESTt   __dict__R   t	   from_linet	   editablesR    t   from_editablet   requirementst   constraintst   Truet	   SCHEME_REt   searcht   urllib_parset   urljoint   ost   patht   dirnamet   joinR   t
   index_urlst	   use_wheelt   pipt   indext   fmt_ctl_no_use_wheelt   no_indext   allow_all_externalt   extra_index_urlst   extendt   allow_externalt   setR   t   lowert   allow_unverifiedt
   find_linkst   abspatht   existst   append(   R   R   R   R   R	   R   R
   R   R   t   parsert   defaultst   args_strt   options_strt   optsR   t   line_comes_fromR   t   req_optionst   destR    t   req_patht   nested_constraintt   req_dirR   t   vt   valuet   relative_to_reqs_file(    (    s-   /tmp/pip-build-5Z5nTX/pip/pip/req/req_file.pyR   ]   s    		!			$					
0	
0		c         C@  s   |  j  d  } g  } | } xJ | D]B } | j d  sG | j d  rK Pq# | j |  | j d  q# Wd j |  d j |  f S(   s½   Break up the line into an args and options string.  We only want to shlex
    (and then optparse) the options, not the args.  args can contain markers
    which are corrupted by shlex.
    t    t   -s   --i    (   R(   t
   startswithRL   t   popR;   (   R   t   tokenst   argsR   t   token(    (    s-   /tmp/pip-build-5Z5nTX/pip/pip/req/req_file.pyR%   Ο   s    c          C@  sY   t  j d t  }  t t } x$ | D] } |   } |  j |  q# Wd   } | |  _ |  S(   s7   
    Return a parser for parsing requirement lines
    t   add_help_optionc         S@  s   t  |   d  S(   N(   R   (   t   selft   msg(    (    s-   /tmp/pip-build-5Z5nTX/pip/pip/req/req_file.pyt   parser_exitν   s    (   t   optparset   OptionParserR*   t   SUPPORTED_OPTIONSt   SUPPORTED_OPTIONS_REQt
   add_optiont   exit(   RM   t   option_factoriest   option_factoryt   optionRe   (    (    s-   /tmp/pip-build-5Z5nTX/pip/pip/req/req_file.pyR!   ΰ   s    
			c         c@  sr   g  } xe |  D]] } | j  d  sT | rL | j |  d j |  Vg  } qj | Vq | j | j d   q Wd S(   s;   
    Joins a line ending in '' with the previous line.
    s   \t    N(   t   endswithRL   R;   t   strip(   t   iteratorR   R   (    (    s-   /tmp/pip-build-5Z5nTX/pip/pip/req/req_file.pyR   τ   s    	c         c@  sA   x: |  D]2 } t  j d |  } | j   } | r | Vq q Wd S(   s6   
    Strips and filters empty or commented lines.
    Ro   N(   t
   COMMENT_REt   subRq   (   Rr   R   (    (    s-   /tmp/pip-build-5Z5nTX/pip/pip/req/req_file.pyR     s
    c         C@  s=   | r | j  n d } | r9 t t j |  j |   }  n  |  S(   sI   
    Optionally exclude lines that match '--skip-requirements-regex'
    N(   t   skip_requirements_regexR   R   t   ret   compileR5   (   R   R   R   (    (    s-   /tmp/pip-build-5Z5nTX/pip/pip/req/req_file.pyR     s    (<   t   __doc__t
   __future__R    R8   Rv   R'   Rf   t   pip._vendor.six.moves.urllibR   R6   t   pip._vendor.six.movesR   R>   t   pip.downloadR   t   pip.req.req_installR   t   pip.exceptionsR   t	   pip.utilsR   R   t   __all__Rw   t   IR4   Rs   R2   t   editableR1   RA   R#   RI   t   extra_index_urlRE   RB   t   no_allow_externalt   allow_unsafet   no_allow_unsafeR=   t   no_use_wheelt   always_unzipt	   no_binaryt   only_binaryRh   t   install_optionst   global_optionsRi   t   oRT   R,   R   R*   R   R   R%   R!   R   R   R   (    (    (    s-   /tmp/pip-build-5Z5nTX/pip/pip/req/req_file.pyt   <module>   s\   		#	p				