ó
Ð²Ebc           @   s¾   d  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 g Z d „  Z d e f d	 „  ƒ  YZ d
 „  Z e ƒ  Z [ e ƒ  Z d d „ Z d S(   sG   
Parser for the environment markers micro-language defined in PEP 508.
iÿÿÿÿNi   (   t   python_implementationt   urlparset   string_types(   t   in_venvt   parse_markert	   interpretc         C   s)   t  |  t ƒ s |  r t S|  d d k S(   Ni    s   '"(   t
   isinstanceR   t   False(   t   o(    (    s8   /tmp/pip-build-UPPWic/pip/pip/_vendor/distlib/markers.pyt   _is_literal   s    t	   Evaluatorc           B   s•   e  Z d  Z i d „  d 6d „  d 6d „  d 6d „  d 6d	 „  d
 6d „  d 6d „  d 6d „  d 6d „  d 6d „  d 6d „  d 6d „  d 6Z d „  Z RS(   s;   
    This class is used to evaluate marker expessions.
    c         C   s
   |  | k S(   N(    (   t   xt   y(    (    s8   /tmp/pip-build-UPPWic/pip/pip/_vendor/distlib/markers.pyt   <lambda>$   t    s   ==c         C   s
   |  | k S(   N(    (   R   R   (    (    s8   /tmp/pip-build-UPPWic/pip/pip/_vendor/distlib/markers.pyR   %   R   s   ===c         C   s   |  | k p |  | k S(   N(    (   R   R   (    (    s8   /tmp/pip-build-UPPWic/pip/pip/_vendor/distlib/markers.pyR   &   R   s   ~=c         C   s
   |  | k S(   N(    (   R   R   (    (    s8   /tmp/pip-build-UPPWic/pip/pip/_vendor/distlib/markers.pyR   '   R   s   !=c         C   s
   |  | k  S(   N(    (   R   R   (    (    s8   /tmp/pip-build-UPPWic/pip/pip/_vendor/distlib/markers.pyR   (   R   t   <c         C   s   |  | k p |  | k  S(   N(    (   R   R   (    (    s8   /tmp/pip-build-UPPWic/pip/pip/_vendor/distlib/markers.pyR   )   R   s   <=c         C   s
   |  | k S(   N(    (   R   R   (    (    s8   /tmp/pip-build-UPPWic/pip/pip/_vendor/distlib/markers.pyR   *   R   t   >c         C   s   |  | k p |  | k S(   N(    (   R   R   (    (    s8   /tmp/pip-build-UPPWic/pip/pip/_vendor/distlib/markers.pyR   +   R   s   >=c         C   s
   |  o	 | S(   N(    (   R   R   (    (    s8   /tmp/pip-build-UPPWic/pip/pip/_vendor/distlib/markers.pyR   ,   R   t   andc         C   s
   |  p	 | S(   N(    (   R   R   (    (    s8   /tmp/pip-build-UPPWic/pip/pip/_vendor/distlib/markers.pyR   -   R   t   orc         C   s
   |  | k S(   N(    (   R   R   (    (    s8   /tmp/pip-build-UPPWic/pip/pip/_vendor/distlib/markers.pyR   .   R   t   inc         C   s
   |  | k S(   N(    (   R   R   (    (    s8   /tmp/pip-build-UPPWic/pip/pip/_vendor/distlib/markers.pyR   /   R   s   not inc   	      C   s*  t  | t ƒ r[ | d d k r/ | d d !} q&| | k rN t d | ƒ ‚ n  | | } nË t  | t ƒ sp t ‚ | d } | |  j k rœ t d | ƒ ‚ n  | d } | d	 } t | d ƒ rì t | d	 ƒ rì t d
 | | | f ƒ ‚ n  |  j | | ƒ } |  j | | ƒ } |  j | | | ƒ } | S(   sƒ   
        Evaluate a marker expression returned by the :func:`parse_requirement`
        function in the specified context.
        i    s   '"i   iÿÿÿÿs   unknown variable: %st   ops   op not implemented: %st   lhst   rhss   invalid comparison: %s %s %s(	   R   R   t   SyntaxErrort   dictt   AssertionErrort
   operationst   NotImplementedErrorR	   t   evaluate(	   t   selft   exprt   contextt   resultR   t   elhst   erhsR   R   (    (    s8   /tmp/pip-build-UPPWic/pip/pip/_vendor/distlib/markers.pyR   2   s$    


 (   t   __name__t
   __module__t   __doc__R   R   (    (    (    s8   /tmp/pip-build-UPPWic/pip/pip/_vendor/distlib/markers.pyR
      s   










c          C   sà   d „  }  t  t d ƒ r9 |  t j j ƒ } t j j } n d } d } i | d 6| d 6t j d 6t j ƒ  d 6t j ƒ  d	 6t j	 ƒ  d
 6t j
 ƒ  d 6t j ƒ  d 6t t ƒ  ƒ d 6t j ƒ  d 6t j ƒ  d  d 6t j d 6} | S(   Nc         S   sS   d |  j  |  j |  j f } |  j } | d k rO | | d t |  j ƒ 7} n  | S(   Ns   %s.%s.%st   finali    (   t   majort   minort   microt   releaselevelt   strt   serial(   t   infot   versiont   kind(    (    s8   /tmp/pip-build-UPPWic/pip/pip/_vendor/distlib/markers.pyt   format_full_versionN   s
    	t   implementationt   0R   t   implementation_namet   implementation_versiont   os_namet   platform_machinet   platform_python_implementationt   platform_releaset   platform_systemt   platform_versiont   platform_in_venvt   python_full_versioni   t   python_versiont   sys_platform(   t   hasattrt   sysR1   R.   t   namet   ost   platformt   machineR    t   releaset   systemR+   R   R=   (   R0   R4   R3   R    (    (    s8   /tmp/pip-build-UPPWic/pip/pip/_vendor/distlib/markers.pyt   default_contextM   s(    	
c         C   s£   y t  |  ƒ \ } } Wn) t k
 rA } t d |  | f ƒ ‚ n X| rq | d d k rq t d |  | f ƒ ‚ n  t t ƒ } | r“ | j | ƒ n  t j | | ƒ S(   sò   
    Interpret a marker and return a result depending on environment.

    :param marker: The marker to interpret.
    :type marker: str
    :param execution_context: The context used for name lookup.
    :type execution_context: mapping
    s)   Unable to interpret marker syntax: %s: %si    t   #s*   unexpected trailing data in marker: %s: %s(   R   t	   ExceptionR   R   t   DEFAULT_CONTEXTt   updatet	   evaluatorR   (   t   markert   execution_contextR   t   restt   eR   (    (    s8   /tmp/pip-build-UPPWic/pip/pip/_vendor/distlib/markers.pyR   q   s    	(   R%   RB   R@   RC   t   ret   compatR    R   R   t   utilR   R   t   __all__R	   t   objectR
   RG   RJ   RL   t   NoneR   (    (    (    s8   /tmp/pip-build-UPPWic/pip/pip/_vendor/distlib/markers.pyt   <module>	   s   		/			