Ñò
$8Zc           @   sÈ   d  Z  d d k Z d d k Z d d k Z e i d ƒ Z e i d ƒ Z e i d ƒ Z d „  Z	 h e i
 d 6e i d 6e i d	 6e i d
 6e i d 6e i d 6Z d d d „  ƒ  YZ d a d „  Z d S(   sB   Module for parsing and testing package version predicate strings.
iÿÿÿÿNs'   (?i)^\s*([a-z_]\w*(?:\.[a-z_]\w*)*)(.*)s   ^\s*\((.*)\)\s*$s%   ^\s*(<=|>=|<|>|!=|==)\s*([^\s,]+)\s*$c         C   sR   t  i |  ƒ } | p t d |  ƒ ‚ n | i ƒ  \ } } | t i i | ƒ f S(   sV   Parse a single version comparison.

    Return (comparison string, StrictVersion)
    s"   bad package restriction syntax: %r(   t   re_splitComparisont   matcht
   ValueErrort   groupst	   distutilst   versiont   StrictVersion(   t   predt   rest   compt   verStr(    (    s0   /usr/lib/python2.6/distutils/versionpredicate.pyt   splitUp   s
    t   <s   <=s   ==t   >s   >=s   !=t   VersionPredicatec           B   s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   s»  Parse and test package version predicates.

    >>> v = VersionPredicate('pyepat.abc (>1.0, <3333.3a1, !=1555.1b3)')

    The `name` attribute provides the full dotted name that is given::

    >>> v.name
    'pyepat.abc'

    The str() of a `VersionPredicate` provides a normalized
    human-readable version of the expression::

    >>> print v
    pyepat.abc (> 1.0, < 3333.3a1, != 1555.1b3)

    The `satisfied_by()` method can be used to determine with a given
    version number is included in the set described by the version
    restrictions::

    >>> v.satisfied_by('1.1')
    True
    >>> v.satisfied_by('1.4')
    True
    >>> v.satisfied_by('1.0')
    False
    >>> v.satisfied_by('4444.4')
    False
    >>> v.satisfied_by('1555.1b3')
    False

    `VersionPredicate` is flexible in accepting extra whitespace::

    >>> v = VersionPredicate(' pat( ==  0.1  )  ')
    >>> v.name
    'pat'
    >>> v.satisfied_by('0.1')
    True
    >>> v.satisfied_by('0.2')
    False

    If any version numbers passed in do not conform to the
    restrictions of `StrictVersion`, a `ValueError` is raised::

    >>> v = VersionPredicate('p1.p2.p3.p4(>=1.0, <=1.3a1, !=1.2zb3)')
    Traceback (most recent call last):
      ...
    ValueError: invalid version number '1.2zb3'

    It the module or package name given does not conform to what's
    allowed as a legal module or package name, `ValueError` is
    raised::

    >>> v = VersionPredicate('foo-bar')
    Traceback (most recent call last):
      ...
    ValueError: expected parenthesized list: '-bar'

    >>> v = VersionPredicate('foo bar (12.21)')
    Traceback (most recent call last):
      ...
    ValueError: expected parenthesized list: 'bar (12.21)'

    c         C   s  | i  ƒ  } | p t d ƒ ‚ n t i | ƒ } | p t d | ƒ ‚ n | i ƒ  \ |  _ } | i  ƒ  } | o t i | ƒ } | p t d | ƒ ‚ n | i ƒ  d } g  } | i d ƒ D] } | t | ƒ qÃ ~ |  _	 |  i	 p t d | ƒ ‚ qn
 g  |  _	 d S(   s*   Parse a version predicate string.
        s   empty package restrictions   bad package name in %rs   expected parenthesized list: %ri    t   ,s   empty parenthesized list in %rN(
   t   stripR   t   re_validPackageR   R   t   namet   re_parent   splitR   R   (   t   selft   versionPredicateStrR   t   parent   strt   _[1]t   aPred(    (    s0   /usr/lib/python2.6/distutils/versionpredicate.pyt   __init___   s$    3
c         C   sj   |  i  oU g  } |  i  D]! \ } } | | d t | ƒ q ~ } |  i d d i | ƒ d S|  i Sd  S(   Nt    s    (s   , t   )(   R   R   R   t   join(   R   R   t   condt   vert   seq(    (    s0   /usr/lib/python2.6/distutils/versionpredicate.pyt   __str__z   s    
8c         C   s7   x0 |  i  D]% \ } } t | | | ƒ p t Sq
 Wt S(   sÏ   True if version is compatible with all the predicates in self.
        The parameter version must be acceptable to the StrictVersion
        constructor.  It may be either a string or StrictVersion.
        (   R   t   compmapt   Falset   True(   R   R   R   R    (    (    s0   /usr/lib/python2.6/distutils/versionpredicate.pyt   satisfied_by   s
    
 	(   t   __name__t
   __module__t   __doc__R   R"   R&   (    (    (    s0   /usr/lib/python2.6/distutils/versionpredicate.pyR      s   ?		c         C   sœ   t  d j o t i d ƒ a  n |  i ƒ  }  t  i |  ƒ } | p t d |  ƒ ‚ n | i d ƒ p d } | o t i	 i
 | ƒ } n | i d ƒ | f S(   s9  Return the name and optional version number of a provision.

    The version number, if given, will be returned as a `StrictVersion`
    instance, otherwise it will be `None`.

    >>> split_provision('mypkg')
    ('mypkg', None)
    >>> split_provision(' mypkg( 1.2 ) ')
    ('mypkg', StrictVersion ('1.2'))
    s=   ([a-zA-Z_]\w*(?:\.[a-zA-Z_]\w*)*)(?:\s*\(\s*([^)\s]+)\s*\))?$s"   illegal provides specification: %ri   i   N(   t   _provision_rxt   Nonet   ret   compileR   R   R   t   groupR   R   R   (   t   valuet   mR    (    (    s0   /usr/lib/python2.6/distutils/versionpredicate.pyt   split_provisionŽ   s    (    (   R)   R,   t   distutils.versionR   t   operatorR-   R   R   R    R   t   ltt   let   eqt   gtt   get   neR#   R   R+   R*   R1   (    (    (    s0   /usr/lib/python2.6/distutils/versionpredicate.pyt   <module>   s   	!!n