ó
 \c           @   sn   d  d l  m Z d  d l Z d  d l Z d  d l Z d   Z d   Z d d  Z d d  Z	 d d  Z
 d S(   i˙˙˙˙(   t   LooseVersionNc         C   sİ   y | d k r% t  |   t  |  k S| d k rG t  |   t  |  k S| d k ri t  |   t  |  k S| d k r t  |   t  |  k  St SWn t k
 r¤ t SXd S(   s  
    Check version string of an active module against a required version.

    If dev/prerelease tags result in TypeError for string-number comparison,
    it is assumed that the dependency is satisfied.
    Users on dev branches are responsible for keeping their own packages up to
    date.

    Copyright (C) 2013  The IPython Development Team

    Distributed under the terms of the BSD License.
    t   >s   >=t   =t   <N(   R    t   Falset	   TypeErrort   True(   t   actvert   versiont   cmp_op(    (    sC   lib/python2.7/site-packages/skimage/_shared/version_requirements.pyt   _check_version   s    c         C   s>   t  |  d |  j d  d g } t | d t | d d   S(   s<   Return module version or None if version can't be retrieved.t   fromlistt   .i˙˙˙˙t   __version__t   VERSIONN(   t
   __import__t
   rpartitiont   getattrt   None(   t   module_namet   mod(    (    sC   lib/python2.7/site-packages/skimage/_shared/version_requirements.pyt   get_module_version#   s    	c         C   sà   |  j    d k r" t j d  } n% y t |   } Wn t k
 rF t SX| d
 k rW t St j	 d |  } | d
 k	 s t
 d   | | j    } | s  d } n  | d k sĵ t
 d	 |   | | j   } t | | |  Sd
 S(   s\  Test if *name* is installed.

    Parameters
    ----------
    name : str
        Name of module or "python"
    version : str, optional
        Version string to test against.
        If version is not None, checking version
        (must have an attribute named '__version__' or 'VERSION')
        Version may start with =, >=, > or < to specify the exact requirement

    Returns
    -------
    out : bool
        True if `name` is installed matching the optional version.

    Notes
    -----
    Original Copyright (C) 2009-2011 Pierre Raybaut
    Licensed under the terms of the MIT License.
    t   pythoni   s   [0-9]s   Invalid version numberR   s   >=R   R   s   Invalid version condition '%s'N(   s   >=R   R   R   (   t   lowert   sysR   R   t   ImportErrorR   R   R   t   ret   searcht   AssertionErrort   startR
   (   t   nameR   R   t   matcht   symb(    (    sC   lib/python2.7/site-packages/skimage/_shared/version_requirements.pyt   is_installed*   s"    	c            s      f d   } | S(   s@  Return decorator that forces a requirement for a function or class.

    Parameters
    ----------
    name : str
        Name of module or "python".
    version : str, optional
        Version string to test against.
        If version is not None, checking version
        (must have an attribute named '__version__' or 'VERSION')
        Version may start with =, >=, > or < to specify the exact requirement

    Returns
    -------
    func : function
        A decorator that raises an ImportError if a function is run
        in the absence of the input dependency.
    c            s(   t  j        f d    } | S(   Nc             si   t      r  |  |   Sd } |   j   f }  d  k	 rU | d  7} n  t | d   d  S(   Ns   "%s" in "%s" requires "%ss    %st   "(   R!   t
   __module__R   R   (   t   argst   kwargst   msg(   R   t   objR   (    sC   lib/python2.7/site-packages/skimage/_shared/version_requirements.pyt   func_wrappedj   s    (   t	   functoolst   wraps(   R'   R(   (   R   R   (   R'   sC   lib/python2.7/site-packages/skimage/_shared/version_requirements.pyt	   decoratori   s    $
(    (   R   R   R+   (    (   R   R   sC   lib/python2.7/site-packages/skimage/_shared/version_requirements.pyt   requireV   s    c         C   s3   t  |  |  s d St |  d |  j d  d g S(   s)  Return a module object of name *module_name* if installed.

    Parameters
    ----------
    module_name : str
        Name of module.
    version : str, optional
        Version string to test against.
        If version is not None, checking version
        (must have an attribute named '__version__' or 'VERSION')
        Version may start with =, >=, > or < to specify the exact requirement

    Returns
    -------
    mod : module or None
        Module if *module_name* is installed matching the optional version
        or None otherwise.
    R   R   i˙˙˙˙N(   R!   R   R   R   (   R   R   (    (    sC   lib/python2.7/site-packages/skimage/_shared/version_requirements.pyt
   get_modulex   s    	(   t   distutils.versionR    R)   R   R   R
   R   R   R!   R,   R-   (    (    (    sC   lib/python2.7/site-packages/skimage/_shared/version_requirements.pyt   <module>   s   		,"