ó
OyTLc           @   s	  d  d l  m Z d  d l Z d  d l Z d  d l Z d  d l m Z m Z m Z m Z d  d l	 m
 Z
 m Z d d d d g Z d d d	 „  ƒ  YZ d
 „  Z d d „ Z d  d d „ Z d  d „ Z e j j d ƒ sâ e j d k r[ [ e j d ƒ e j d ƒ n  d S(   iÿÿÿÿ(   t
   generatorsN(   t   PKG_DIRECTORYt   PY_COMPILEDt	   PY_SOURCEt	   PY_FROZEN(   t   StrictVersiont   LooseVersiont   Requiret   find_modulet   get_module_constantt   extract_constantc           B   sY   e  Z d  Z d d	 d	 d „ Z d „  Z d „  Z d	 d d „ Z d	 d „ Z d	 d „ Z	 RS(
   s7   A prerequisite to building or installing a distributiont    c         C   sn   | d  k r! | d  k	 r! t } n  | d  k	 rQ | | ƒ } | d  k rQ d } qQ n  |  j j t ƒ  ƒ |  ` d  S(   Nt   __version__(   t   NoneR   t   __dict__t   updatet   localst   self(   R   t   namet   requested_versiont   modulet   homepaget	   attributet   format(    (    s6   /usr/lib/python2.7/dist-packages/setuptools/depends.pyt   __init__   s    	c         C   s*   |  j  d k	 r# d |  j |  j  f S|  j S(   s0   Return full package/distribution name, w/versions   %s-%sN(   R   R   R   (   R   (    (    s6   /usr/lib/python2.7/dist-packages/setuptools/depends.pyt	   full_name   s    c         C   s=   |  j  d k p< |  j d k p< t | ƒ d k o< | |  j k S(   s%   Is 'version' sufficiently up-to-date?t   unknownN(   R   R   R   t   strR   (   R   t   version(    (    s6   /usr/lib/python2.7/dist-packages/setuptools/depends.pyt
   version_ok$   s    R   c         C   s°   |  j  d k r] y6 t |  j | ƒ \ } } } | r@ | j ƒ  n  | SWq] t k
 rY d SXn  t |  j |  j  | | ƒ } | d k	 r¬ | | k	 r¬ |  j d k	 r¬ |  j | ƒ S| S(   s×  Get version number of installed module, 'None', or 'default'

        Search 'paths' for module.  If not found, return 'None'.  If found,
        return the extracted version attribute, or 'default' if no version
        attribute was specified, or the value cannot be determined without
        importing the module.  The version is formatted according to the
        requirement's version format (if any), unless it is 'None' or the
        supplied 'default'.
        N(   R   R   R   R   t   closet   ImportErrorR	   R   (   R   t   pathst   defaultt   ft   pt   it   v(    (    s6   /usr/lib/python2.7/dist-packages/setuptools/depends.pyt   get_version*   s     'c         C   s   |  j  | ƒ d k	 S(   s/   Return true if dependency is present on 'paths'N(   R&   R   (   R   R    (    (    s6   /usr/lib/python2.7/dist-packages/setuptools/depends.pyt
   is_presentF   s    c         C   s,   |  j  | ƒ } | d k r t S|  j | ƒ S(   s>   Return true if dependency is present and up-to-date on 'paths'N(   R&   R   t   FalseR   (   R   R    R   (    (    s6   /usr/lib/python2.7/dist-packages/setuptools/depends.pyt
   is_currentK   s    N(
   t   __name__t
   __module__t   __doc__R   R   R   R   R&   R'   R)   (    (    (    s6   /usr/lib/python2.7/dist-packages/setuptools/depends.pyR   
   s   		c   
      c   sæ   d d l  m  } d d l m } m } | d |  j ƒ } t |  j ƒ } d } d } xŒ | | k  rá | | } | | k rÃ | | d | | d d | }	 | d	 7} | | k rÓ |	 d
 } qV qÓ n d }	 | d 7} | |	 f VqV Wd S(   s>   Yield '(op,arg)' pair for each operation in code object 'code'iÿÿÿÿ(   t   array(   t   HAVE_ARGUMENTt   EXTENDED_ARGt   bi    i   i   i   i   l      N(   R-   t   disR.   R/   t   co_codet   lenR   (
   t   codeR-   R.   R/   t   bytest   eoft   ptrt   extended_argt   opt   arg(    (    s6   /usr/lib/python2.7/dist-packages/setuptools/depends.pyt
   _iter_codeS   s"    
"

	
c   
      C   s   |  j  d ƒ } x‡ | r˜ | j d ƒ } t j | | ƒ \ } } \ } } } }	 | t k rv | pg d g } | g } q | r t d | |  f ƒ ‚ q q W|	 S(   s7   Just like 'imp.find_module()', but with package supportt   .i    R   s   Can't find %r in %s(   t   splitt   popt   impR   R   R   (
   R   R    t   partst   partR"   t   patht   suffixt   modet   kindt   info(    (    s6   /usr/lib/python2.7/dist-packages/setuptools/depends.pyR   |   s    	(c   
      C   s  y% t  |  | ƒ \ } } \ } } } Wn t k
 r9 d SXz¼ | t k rh | j d ƒ t j | ƒ }	 n | t k r† t j	 |  ƒ }	 no | t
 k r­ t | j ƒ  | d ƒ }	 nH |  t j k rÞ t j |  | | | | | f ƒ n  t t j |  | d ƒ SWd | r| j ƒ  n  Xt |	 | | ƒ S(   sü   Find 'module' by searching 'paths', and extract 'symbol'

    Return 'None' if 'module' does not exist on 'paths', or it does not define
    'symbol'.  If the module defines 'symbol' as a constant, return the
    constant.  Otherwise, return 'default'.i   t   execN(   R   R   R   R   t   readt   marshalt   loadR   R?   t   get_frozen_objectR   t   compilet   syst   modulest   load_modulet   getattrR   R
   (
   R   t   symbolR!   R    R"   RB   RC   RD   RE   R4   (    (    s6   /usr/lib/python2.7/dist-packages/setuptools/depends.pyR	   ¥   s$    %"c   
      C   s®   | |  j  k r d St |  j  ƒ j | ƒ } d } d } d } | } xd t |  ƒ D]V \ } }	 | | k rx |  j |	 } qP |	 | k r  | | k sœ | | k r  | S| } qP Wd S(   s  Extract the constant value of 'symbol' from 'code'

    If the name 'symbol' is bound to a constant value by the Python code
    object 'code', return that value.  If 'symbol' is bound to an expression,
    return 'default'.  Otherwise, return 'None'.

    Return value is based on the first assignment to 'symbol'.  'symbol' must
    be a global, or at least a non-"fast" local in the code block.  That is,
    only 'STORE_NAME' and 'STORE_GLOBAL' opcodes are checked, and 'symbol'
    must be present in 'code.co_names'.
    iZ   ia   id   N(   t   co_namesR   t   listt   indexR;   t	   co_consts(
   R4   RQ   R!   t   name_idxt
   STORE_NAMEt   STORE_GLOBALt
   LOAD_CONSTt   constR9   R:   (    (    s6   /usr/lib/python2.7/dist-packages/setuptools/depends.pyR
   Î   s    $t   javat   cli(    (   t
   __future__R    RM   R?   RI   R   R   R   R   t   distutils.versionR   R   t   __all__R   R;   R   R   R	   R
   t   platformt
   startswitht   remove(    (    (    s6   /usr/lib/python2.7/dist-packages/setuptools/depends.pyt   <module>   s   $"I	)))"!