ó
^†êWc           @@  s2  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 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- e j. e j/ e j0 e j1 g Z2 e j3 e j4 e j5 g Z6 g  e6 D] Z7 e7 ƒ  j8 ^ qªZ9 d d d d e; d d „ Z< d „  Z= d d d d d e; d „ Z> d „  Z? d „  Z@ d „  ZA d „  ZB d „  ZC d S(   s   
Requirements file parsing
i    (   t   absolute_importN(   t   parse(   t   filterfalse(   t   get_file_content(   t   InstallRequirement(   t   RequirementsFileParseError(   t   RemovedInPip10Warning(   t
   cmdoptionst   parse_requirementss   ^(http|https|file):s   (^|\s)+#.*$c         c@  s    | d k r t d ƒ ‚ n  t |  d | d | ƒ\ } } t | | ƒ }	 xQ |	 D]I \ }
 } t | |  |
 | | | | | d | ƒ} x | D] } | Vq‰ WqO 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:     cli 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   sessiont
   constraintN(   t   Nonet	   TypeErrorR   t
   preprocesst   process_line(   t   filenamet   finderR	   t   optionsR
   R   t   wheel_cachet   _t   contentt
   lines_enumt   line_numbert   linet   req_itert   req(    (    sa   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/req/req_file.pyR   @   s    	c         C@  sC   t  |  j ƒ  d d ƒ} t | ƒ } t | ƒ } t | | ƒ } | S(   s˜   Split, filter, and join lines, and return a line iterator

    :param content: the content of the requirements file
    :param options: cli options
    t   starti   (   t	   enumeratet
   splitlinest
   join_linest   ignore_commentst
   skip_regex(   R   R   R   (    (    sa   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/req/req_file.pyR   a   s
    c	         c@  sT  t  ƒ  }	 |	 j ƒ  }
 d |
 _ | r3 | j |
 _ n  t |  ƒ \ } } t j d k  rf | j d ƒ } n  |	 j	 t
 j | ƒ |
 ƒ \ } } d | r– d n d | | f } | rM| 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¶| re| j n t } | rz| 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 | | ƒ } n3 t j | ƒ sQt j j  t j j! | ƒ | ƒ } n  t" | | | | | d | d | ƒ}	 xØ|	 D] } | Vq|WnÂ| j# r¦| j# | _# nª| rP| j$ rÈt% j& d t' ƒ n  | j( rät% j& d t' ƒ n  | j) r t% j& d t' ƒ n  | j r| j g | _* n  | j+ t k rIt | _+ t, j- j. | j ƒ n  | j/ t k rdg  | _* n  | j0 rƒ| j* j1 | j0 ƒ n  | j2 rú| j2 d } t j j! t j j3 | ƒ ƒ } t j j  | | ƒ } t j j4 | ƒ rç| } n  | j2 j5 | ƒ n  | j6 rt | _7 n  | j8 r$t | _8 n  | j9 rP| j: j1 d „  | j9 Dƒ ƒ qP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.
    :param options: OptionParser options that we may update
    i   i   i   t   utf8s   %s %s (line %s)s   -cs   -rR   t   isolatedR   R   i    R	   t   default_vcss   --allow-external has been deprecated and will be removed in the future. Due to changes in the repository protocol, it no longer has any effect.s“   --allow-all-external has been deprecated and will be removed in the future. Due to changes in the repository protocol, it no longer has any effect.s‘   --allow-unverified has been deprecated and will be removed in the future. Due to changes in the repository protocol, it no longer has any effect.c         s@  s   |  ] } d  | d  f Vq d S(   t   *N(    (   t   .0t   host(    (    sa   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/req/req_file.pys	   <genexpr>ú   s    N(   i   i   i   (;   t   build_parsert   get_default_valuesR   t	   index_urlt   format_controlt   break_args_optionst   syst   version_infot   encodet
   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   joint   dirnameR   t   require_hashest   allow_externalt   warningst   warnR   t   allow_all_externalt   allow_unverifiedt
   index_urlst	   use_wheelt   pipt   indext   fmt_ctl_no_use_wheelt   no_indext   extra_index_urlst   extendt
   find_linkst   abspatht   existst   appendt   pret   allow_all_prereleasest   process_dependency_linkst   trusted_hostst   secure_origins(   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_constraintR   t   valuet   req_dirt   relative_to_reqs_file(    (    sa   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/req/req_file.pyR   n   s¤    		!			$		
	
	
									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    (   R1   t
   startswithRV   t   popRC   (   R   t   tokenst   argsR   t   token(    (    sa   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/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(    (    sa   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/req/req_file.pyt   parser_exit  s    (   t   optparset   OptionParserR3   t   SUPPORTED_OPTIONSt   SUPPORTED_OPTIONS_REQt
   add_optiont   exit(   R\   t   option_factoriest   option_factoryt   optionRs   (    (    sa   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/req/req_file.pyR'     s    
			c         c@  sâ   d } g  } x² |  D]ª \ } } | j d ƒ s> t j | ƒ r˜ t j | ƒ rZ d | } n  | rŠ | j | ƒ | d j | ƒ f Vg  } q½ | | f Vq | s§ | } n  | j | j d ƒ ƒ q W| rÞ | d j | ƒ f Vn  d S(   s’   Joins a line ending in '' with the previous line (except when following
    comments).  The joined line takes on the index of the first line.
    s   \Ri   t    N(   R   t   endswitht
   COMMENT_REt   matchRV   RC   t   strip(   R   t   primary_line_numbert   new_lineR   R   (    (    sa   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/req/req_file.pyR   "  s     		c         c@  sM   xF |  D]> \ } } t  j d | ƒ } | j ƒ  } | r | | f Vq q Wd S(   s1   
    Strips comments and filter empty lines.
    R}   N(   R   t   subR   (   R   R   R   (    (    sa   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/req/req_file.pyR   ?  s
    c         @  sI   | r | j  n d } | rE t j | ƒ ‰  t ‡  f d †  |  ƒ }  n  |  S(   ss   
    Skip lines that match '--skip-requirements-regex' pattern

    Note: the regex pattern is only built once
    c         @  s   ˆ  j  |  d ƒ S(   Ni   (   R>   (   t   e(   t   pattern(    sa   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/req/req_file.pyt   <lambda>T  s    N(   t   skip_requirements_regexR   t   ret   compileR   (   R   R   R    (    (   R†   sa   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/req/req_file.pyR    J  s    (D   t   __doc__t
   __future__R    RA   R‰   R0   R,   Rt   RG   t   pip._vendor.six.moves.urllibR   R?   t   pip._vendor.six.movesR   RM   t   pip.downloadR   t   pip.req.req_installR   t   pip.exceptionsR   t   pip.utils.deprecationR   R   t   __all__RŠ   t   IR=   R   R;   t   editableR:   RP   R)   RS   t   extra_index_urlRF   RI   t   no_allow_externalt   allow_unsafet   no_allow_unsafeRL   t   no_use_wheelt   always_unzipt	   no_binaryt   only_binaryRW   RY   t   trusted_hostRE   Rv   t   install_optionst   global_optionst   hashRw   t   oRc   R5   R   R3   R   R   R   R+   R'   R   R   R    (    (    (    sa   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/req/req_file.pyt   <module>   sl   		 						