ó
Ż²k^c           @` sk  d  d l  m Z m Z m Z m Z d  d l m Z m Z m Z y d  d l	 m
 Z
 Wn! e k
 ru d  d l m
 Z
 n Xd  d l m Z d  d l m 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 m Z d d l m Z d d l m Z d d l m  Z  m! Z! m" Z" d d l# m$ Z$ d d l% m& Z& m' Z' m( Z( m) Z) m* Z* m+ Z+ d d l, m- Z- d d l. m/ Z/ m0 Z0 m1 Z1 m2 Z2 d d l3 m4 Z4 m5 Z5 m6 Z6 d d l7 m8 Z8 m9 Z9 e e:  Z; d e< f d     YZ= e+ e=  d e> f d     Y Z? d   Z@ d   ZA d   ZB i  ZC d   ZD e+ e  d e> f d     Y ZE d  e> f d!     YZF d" eF eE f d#     YZG d$ eG f d%     YZH d& eF eE f d'     YZI d( eI f d)     YZJ d* eE f d+     YZK d, eE f d-     YZL d. eI f d/     YZM d0 eJ f d1     YZN i	 eM d2 6eJ d3 6e d4 6eI d5 6e d6 6eL d7 6eL d8 6eN d9 6eN d: 6ZO d S(;   i    (   t   absolute_importt   divisiont   print_functiont   unicode_literals(   t   ABCMetat   abstractmethodt   abstractproperty(   t   Mapping(   t   reduce(   t	   getLogger(   t
   attrgetter(   t   basenameNi   (   t   Channel(   t   BuildNumberMatcht   VersionSpeci   (   t
   frozendict(   t   memoizedproperty(   t   concatt   concatvt   groupby(   t   CONDA_PACKAGE_EXTENSION_V1(   t
   isiterablet	   iteritemst
   itervaluest   string_typest	   text_typet   with_metaclass(   t   dashlist(   t   expandt   url_to_patht   strip_pkg_extensiont   is_package_file(   t   is_urlt   path_to_urlt   unquote(   t   CondaValueErrort   InvalidMatchSpect   MatchSpecTypec           B` s   e  Z d d   Z RS(   c         K` s¢  | rt  | t  r  | r  | St  | t  r t | j  } | j d | j  | j d | j  | j | d <| j |   t	 t
 |   j |   St  | t  rt |  } | rš t | |  } t |  d d h rš | j d d   qš n  t	 t
 |   j |   St  | t  r:t | |  } t	 t
 |   j |   St | d  ro| j   } | rht | |  S| Sqt d | | f   n t	 t
 |   j |   Sd  S(   Nu   optionalu   targetu   _original_spec_stru   to_match_specu,   Invalid MatchSpec:
  spec_arg=%s
  kwargs=%s(   t
   isinstancet	   MatchSpect   dictt   _match_componentst
   setdefaultt   optionalt   targett   original_spec_strt   updatet   superR%   t   __call__R   t   _parse_spec_strt   sett   popt   NoneR   t   hasattrt   to_match_specR#   (   t   clst   spec_argt   kwargst
   new_kwargst   parsedt   spec(    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyR0   #   s8    N(   t   __name__t
   __module__R4   R0   (    (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyR%   !   s   R'   c           B` s²  e  Z d  Z d/ Z e e  Z i  Z e d0 d  Z	 e
 d    Z d   Z d   Z d0 d  Z e d    Z d   Z e d    Z e d    Z e d    Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d    Z d!   Z d"   Z e  d#    Z! d$   Z" d%   Z# e$ d&    Z% e d'    Z& e d(    Z' e d)    Z( e d*    Z) e d+    Z* e
 e d,   Z+ e
 d-    Z, e d.  Z- RS(1   uĒ  
    :class:`MatchSpec` is, fundamentally, a query language for conda packages.  Any of the fields
    that comprise a :class:`PackageRecord` can be used to compose a :class:`MatchSpec`.

    :class:`MatchSpec` can be composed with keyword arguments, where keys are any of the
    attributes of :class:`PackageRecord`.  Values for keyword arguments are the exact values the
    attribute should match against.  Many fields can also be matched against non-exact values--by
    including wildcard `*` and `>`/`<` ranges--where supported.  Any non-specified field is
    the equivalent of a full wildcard match.

    :class:`MatchSpec` can also be composed using a single positional argument, with optional
    keyword arguments.  Keyword arguments also override any conflicting information provided in
    the positional argument.  The positional argument can be either an existing :class:`MatchSpec`
    instance or a string.  Conda has historically had several string representations for equivalent
    :class:`MatchSpec`s.  This :class:`MatchSpec` should accept any existing valid spec string, and
    correctly compose a :class:`MatchSpec` instance.

    A series of rules are now followed for creating the canonical string representation of a
    :class:`MatchSpec` instance.  The canonical string representation can generically be
    represented by

        (channel(/subdir):(namespace):)name(version(build))[key1=value1,key2=value2]

    where `()` indicate optional fields.  The rules for constructing a canonical string
    representation are:

    1. `name` (i.e. "package name") is required, but its value can be '*'.  Its position is always
       outside the key-value brackets.
    2. If `version` is an exact version, it goes outside the key-value brackets and is prepended
       by `==`. If `version` is a "fuzzy" value (e.g. `1.11.*`), it goes outside the key-value
       brackets with the `.*` left off and is prepended by `=`.  Otherwise `version` is included
       inside key-value brackets.
    3. If `version` is an exact version, and `build` is an exact value, `build` goes outside
       key-value brackets prepended by a `=`.  Otherwise, `build` goes inside key-value brackets.
       `build_string` is an alias for `build`.
    4. The `namespace` position is being held for a future conda feature.
    5. If `channel` is included and is an exact value, a `::` separator is ued between `channel`
       and `name`.  `channel` can either be a canonical channel name or a channel url.  In the
       canonical string representation, the canonical channel name will always be used.
    6. If `channel` is an exact value and `subdir` is an exact value, `subdir` is appended to
       `channel` with a `/` separator.  Otherwise, `subdir` is included in the key-value brackets.
    7. Key-value brackets can be delimited by comma, space, or comma+space.  Value can optionally
       be wrapped in single or double quotes, but must be wrapped if `value` contains a comma,
       space, or equal sign.  The canonical format uses comma delimiters and single quotes.
    8. When constructing a :class:`MatchSpec` instance from a string, any key-value pair given
       inside the key-value brackets overrides any matching parameter given outside the brackets.

    When :class:`MatchSpec` attribute values are simple strings, the are interpreted using the
    following conventions:

      - If the string begins with `^` and ends with `$`, it is converted to a regex.
      - If the string contains an asterisk (`*`), it is transformed from a glob to a regex.
      - Otherwise, an exact match to the string is sought.


    Examples:

        >>> str(MatchSpec(name='foo', build='py2*', channel='conda-forge'))
        'conda-forge::foo[build=py2*]'
        >>> str(MatchSpec('foo 1.0 py27_0'))
        'foo==1.0=py27_0'
        >>> str(MatchSpec('foo=1.0=py27_0'))
        'foo==1.0=py27_0'
        >>> str(MatchSpec('conda-forge::foo[version=1.0.*]'))
        'conda-forge::foo=1.0'
        >>> str(MatchSpec('conda-forge/linux-64::foo>=1.0'))
        "conda-forge/linux-64::foo[version='>=1.0']"
        >>> str(MatchSpec('*/linux-64::foo>=1.0'))
        "foo[subdir=linux-64,version='>=1.0']"

    To fully-specify a package with a full, exact spec, the fields
      - channel
      - subdir
      - name
      - version
      - build
    must be given as exact values.  In the future, the namespace field will be added to this list.
    Alternatively, an exact spec is given by '*[md5=12345678901234567890123456789012]'.

    u   channelu   subdiru   nameu   versionu   buildu   build_numberu   track_featuresu   featuresu   urlu   md5u   licenseu   license_familyu   fnc         K` s=   | |  _  | |  _ | j d d   |  _ |  j |   |  _ d  S(   Nu   _original_spec_str(   t	   _optionalt   _targetR3   R4   t   _original_spec_strt   _build_componentsR)   (   t   selfR+   R,   R9   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyt   __init__¬   s    		c   	      C` sć   i  } | j  t  r) | t t   } n  d | k r | j d d  \ } } d | k r | j d d  \ } } | j i | d 6| d 6 q | | d <n  | j d d  \ } } } | j i | d 6| d	 6| d
 6 |  |   S(   Nu   ::i   u   /i   u   channelu   subdiru   -u   nameu   versionu   build(   t   endswithR   t   lent   splitR.   t   rsplit(	   R7   t   dist_strt   partst   channel_subdir_strt   channel_strt   subdirt   namet   versiont   build(    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyt   from_dist_str²   s"    		c         C` s   |  j  j |  } | o | j S(   N(   R)   t   gett   exact_value(   RC   t
   field_namet   v(    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyt   get_exact_valueŹ   s    c         C` s   |  j  j |  } | o | j S(   N(   R)   RR   t	   raw_value(   RC   RT   RU   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyt   get_raw_valueĪ   s    c         C` s#   |  j  |  } | d  k r | S| S(   N(   RX   R4   (   RC   RT   t   defaultRU   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyRR   Ņ   s    c         C` s1   t  |  j  d k o0 d |  j k o0 |  j d k S(   Ni   u   nameu   *(   RF   R)   RN   (   RC   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyt   is_name_only_specÖ   s    c         C` s
   |  j    S(   N(   t   __str__(   RC   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyRI   Ü   s    c         C` s   |  j  S(   N(   R?   (   RC   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyR+   ß   s    c         C` s   |  j  S(   N(   R@   (   RC   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyR,   ć   s    c         C` s   |  j  S(   N(   RA   (   RC   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyR-   ē   s    c         C` sn   t  | t  r1 d d l m } | j |  } n  x6 t |  j  D]% \ } } |  j | | |  sA t SqA Wt	 S(   u¤   
        Accepts an `IndexRecord` or a dict, and matches can pull from any field
        in that record.  Returns True for a match, and False for no match.
        i   (   t   PackageRecord(
   R&   R(   t   recordsR\   t   from_objectsR   R)   t   _match_individualt   Falset   True(   RC   t   recR\   RT   RU   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyt   matchė   s    c         C` s?   t  | |  } y | j |  SWn t k
 r: | | k SXd  S(   N(   t   getattrRc   t   AttributeError(   RC   t   recordRT   t   match_componentt   val(    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyR_   ł   s
    c         C` s(   t  |  j  d k o' |  j d  d  k	 S(   Ni   u   name(   RF   R)   RV   R4   (   RC   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyt
   _is_simple   s    c         C` s   t  |  j  d k S(   Ni   (   RF   R)   (   RC   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyt
   _is_single  s    c         ` s_     j  d  } | r | St   f d   d D  } t d   | D  sW d | t Sd  Sd  S(	   Nu   fnc         3` s   |  ] }   j  |  Vq d  S(   N(   RV   (   t   .0t   x(   RC   (    s6   lib/python2.7/site-packages/conda/models/match_spec.pys	   <genexpr>  s    u   nameu   versionu   buildc         s` s   |  ] } | d  k Vq d  S(   N(   R4   (   Rk   Rl   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pys	   <genexpr>  s    u   %s-%s-%s(   u   nameu   versionu   build(   RV   t   tuplet   anyR   R4   (   RC   t   fn_fieldt   vals(    (   RC   s6   lib/python2.7/site-packages/conda/models/match_spec.pyt   _to_filename_do_not_use  s    c         C` sl   d |  j  j |  f g } |  j r9 | j d |  j  n  |  j rR | j d  n  | j d  d j |  S(   Nu   %s("%s"u   , target="%s"u   , optional=Trueu   )u    (   t	   __class__R=   R,   t   appendR+   t   join(   RC   t   builder(    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyt   __repr__  s    		c   	      ` sŠ  g  } g  } |  j  j d  } | rC | j rC | j t |   n* | rm | j rm | j d t |   n  |  j  j d  } | r¼ | rØ | j rØ | j d |  q¼ | j d |  n  |  j  j d d  } | j | rć d n d	 |  |  j  j d
   |  j  j d    t }  r#t    t  f d   d D  rZ| j d   q# d  d# k r  r| j d   q | j   q# d d k r¼| j d  d   q# d d k rä| j d  d   q# j d  r	| j   t	 } q#| j d   t	 } n    r³t      t   f d   d D  re| j d    q³d   k r| j d    q³| r| j d    q³| j d    n  d d d d
 d h } d |  j  k röd |  j  k rö| j
 d  n  x§ |  j D] } | | k r | |  j  k r | d k r9| r9q n  t |  j  |   t  f d   d D  r| j d |  f  q| j d |  f  q q W| rĆ| j d  d! j |   n  d" j |  S($   Nu   channelu
   channel=%su   subdiru   /%su	   subdir=%su   nameu   *u   ::%su   %su   versionu   buildc         3` s   |  ] } |   k Vq d  S(   N(    (   Rk   t   s(   RO   (    s6   lib/python2.7/site-packages/conda/models/match_spec.pys	   <genexpr>4  s    u   ><$^|,u   version='%s'i   u   !=u   ~=iž’’’u   .*u   =i’’’’u   ==c         3` s   |  ] } |   k Vq d  S(   N(    (   Rk   Rw   (   RP   (    s6   lib/python2.7/site-packages/conda/models/match_spec.pys	   <genexpr>H  s    u
   build='%s'u   build=%su   urlu   fnc         3` s   |  ] } |   k Vq d  S(   N(    (   Rk   Rw   (   t   value(    s6   lib/python2.7/site-packages/conda/models/match_spec.pys	   <genexpr>Z  s    u   , =u   %s='%s'u   %s=%su   [%s]u   ,u    (   u   !=u   ~=(   R)   RR   RS   Rs   R   t   matches_allR`   Rn   t
   startswithRa   t   addt   FIELD_NAMESRt   (	   RC   Ru   t   bracketst   channel_matchert   subdir_matchert   name_matchert   version_exactt   _skipt   key(    (   RP   Rx   RO   s6   lib/python2.7/site-packages/conda/models/match_spec.pyR[     sr    		c         C` s
   |  j    S(   N(   R[   (   RC   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyt   __json__d  s    c         C` s   g  } |  j  d  } | s! t  | j |  |  j d  } |  j d  } | rq | s^ t  | | | g 7} n | r | j |  n  d j |  S(   Nu   nameu   buildu   versionu    (   RV   t   AssertionErrorRs   RX   Rt   (   RC   Ru   RN   RP   RO   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyt   conda_build_formg  s    c         C` s'   t  | t  r |  j | j k St Sd  S(   N(   R&   R'   t	   _hash_keyR`   (   RC   t   other(    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyt   __eq__x  s    c         C` s   t  |  j  S(   N(   t   hashR   (   RC   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyt   __hash__~  s    c         C` s   |  j  |  j |  j f S(   N(   R)   R+   R,   (   RC   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyR     s    c         C` s   | |  j  k S(   N(   R)   (   RC   t   field(    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyt   __contains__  s    c         ` s[   t  |  t j } | r2 t |  j d |   n  t j   t   f d   t |  D  S(   Nu   Cannot match on field(s): %sc         3` s$   |  ] \ } }   | |  Vq d  S(   N(    (   Rk   R   Rx   (   t   _make_component(    s6   lib/python2.7/site-packages/conda/models/match_spec.pys	   <genexpr>  s    (   R2   R'   t   FIELD_NAMES_SETR$   RA   R   R   R   (   RC   R9   t
   not_fields(    (   R   s6   lib/python2.7/site-packages/conda/models/match_spec.pyRB     s    		c         C` s   t  | d  r | } |  | f St j } |  | f } | j |  } | rS |  | f S|  t k rr t |  |  } n t t |   } | | |  | f <|  | f S(   Nu   match(   R5   R'   t   _MATCHER_CACHERR   t   _implementorst   ExactStrMatchR   (   RT   Rx   t   matcherR   t	   cache_keyt   cached_matcher(    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyR     s    
	
c         C` s   |  j  d  p d S(   Nu   nameu   *(   RV   (   RC   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyRN   ¢  s    c         ` ss   t    f d   d D  } | t   j  k  r5 d S  j d  sT d   j k rX d Sd   j k rk d Sd Sd  S(	   Nc         3` s   |  ] } |   j  k Vq d  S(   N(   R)   (   Rk   t   f(   RC   (    s6   lib/python2.7/site-packages/conda/models/match_spec.pys	   <genexpr>®  s    u   nameu   versionu   buildi   i   i   (   u   nameu   versionu   build(   t   sumRF   R)   RV   (   RC   Rw   (    (   RC   s6   lib/python2.7/site-packages/conda/models/match_spec.pyt
   strictnessŖ  s    c         C` s
   |  j    S(   N(   R   (   RC   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyR<   ø  s    c         C` s   |  j  j d  S(   Nu   version(   R)   RR   (   RC   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyRO   ¼  s    c         C` sC   |  j  d  p |  j  d  } | r3 t |  } n  | s? t  | S(   Nu   fnu   url(   RX   R   R   (   RC   Rh   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyt   fnĀ  s
    c   	      ` s6  t  t   f d   | D  d t } t t d  |  } | j d g   | j d  g   } g  } t t d   t |  D   } x | D] } t t d  |  } | j d  d   t	 |  d k rä t
 d t |    n  | j t	 |  d k rt  f d	   |  n | d
  q Wt t | |   S(   Nc         3` s!   |  ] } | r   |  Vq d  S(   N(    (   Rk   Rw   (   R7   (    s6   lib/python2.7/site-packages/conda/models/match_spec.pys	   <genexpr>Ģ  s    R   u   nameu   *c         s` s'   |  ] } t  t d    |   Vq d S(   c         S` s   |  j  S(   N(   R+   (   Rw   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyt   <lambda>Ņ  s    N(   R   R   (   Rk   t   group(    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pys	   <genexpr>Ņ  s   u   targeti   u   Incompatible MatchSpec merge:%sc         ` s   |  j  |    S(   N(   t   _merge(   Rl   t   y(   t   union(    s6   lib/python2.7/site-packages/conda/models/match_spec.pyR   Ū  s    i    (   t   sortedRm   t   strR   R
   R3   R4   R   R   RF   t
   ValueErrorR   Rs   R   R   (	   R7   t   match_specsR   t   name_groupst   unmergeablet   merged_specst   mergeable_groupsR   t   target_groups(    (   R7   R   s6   lib/python2.7/site-packages/conda/models/match_spec.pyt   mergeŹ  s    ("9c         C` s   |  j  | d t S(   NR   (   R©   Ra   (   R7   R£   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyR   ß  s    c   	      C` se  |  j  | j  k s$ |  j | j k r= t d |  | f   n  i  } t |  j  t | j  B} xä | D]Ü } |  j j |  } | j j |  } | d  k r® | d  k r® qf qf | d  k rĒ | | | <qf | d  k rą | | | <qf | r)y | j |  } Wq8t t t	 f k
 r%d | | f } q8Xn | j
 |  } | | | <qf W|  j d |  j  d |  j |  S(   Nu*   Incompatible MatchSpec merge:  - %s
  - %su   %s|%sR+   R,   (   R+   R,   R¢   R2   R)   RR   R4   R   Re   t	   TypeErrorR©   Rr   (	   RC   R   R   t   final_componentst   component_namest   component_namet   this_componentt   that_componentt   final(    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyR   ć  s*    $(   u   channelu   subdiru   nameu   versionu   buildu   build_numberu   track_featuresu   featuresu   urlu   md5u   licenseu   license_familyu   fnN(.   R=   R>   t   __doc__R|   t	   frozensetR   R   R`   R4   RD   t   classmethodRQ   RV   RX   RR   t   propertyRZ   RI   R+   R,   R-   Rc   R_   Ri   Rj   Rq   Rv   R[   R   R   R   R   R   R   R   RB   t   staticmethodR   RN   R   R<   RO   R   R©   R   R   (    (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyR'   G   sd   Q            											I						c         C` sh   t  j d |   } | r? | j   \ } } | o9 | j   } n |  d } } | oa | j d d  | f S(   uč  This should reliably pull the build string out of a version + build string combo.
    Examples:
        >>> _parse_version_plus_build("=1.2.3 0")
        ('=1.2.3', '0')
        >>> _parse_version_plus_build("1.2.3=0")
        ('1.2.3', '0')
        >>> _parse_version_plus_build(">=1.0 , < 2.0 py34_0")
        ('>=1.0,<2.0', 'py34_0')
        >>> _parse_version_plus_build(">=1.0 , < 2.0 =py34_0")
        ('>=1.0,<2.0', 'py34_0')
        >>> _parse_version_plus_build("=1.2.3 ")
        ('=1.2.3', None)
        >>> _parse_version_plus_build(">1.8,<2|==1.7")
        ('>1.8,<2|==1.7', None)
        >>> _parse_version_plus_build("* openblas_0")
        ('*', 'openblas_0')
        >>> _parse_version_plus_build("* *")
        ('*', '*')
    u<   ((?:.+?)[^><!,|]?)(?:(?<![=!|,<>~])(?:[ =])([^-=,|<>~]+?))?$u    u    N(   t   ret   searcht   groupst   stripR4   t   replace(   t   v_plus_bRJ   RO   RP   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyt   _parse_version_plus_build’  s    c         C` s:   t  |   \ }  } |  j d d  \ } } } | | | f S(   uÓ   
    Examples:
        >>> _parse_legacy_dist("_license-1.1-py27_1.tar.bz2")
        ('_license', '1.1', 'py27_1')
        >>> _parse_legacy_dist("_license-1.1-py27_1")
        ('_license', '1.1', 'py27_1')
    u   -i   (   R   RH   (   RI   t   _RN   RO   RP   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyt   _parse_legacy_dist  s    c         C` s5   |  s
 d St |   } | j p% | j } | | j f S(   N(   NN(   R4   R   RN   t   base_urlRM   (   t   channel_valt   chnt   channel_name(    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyt   _parse_channel)  s
    c          ` s  t  j |   } | r | S|  } |  j d  rM |  d  } i d d 6| f d 6Sd |  k r |  j d  } |  |  |  | }  } |  j   n  |  j d d  } t |  d k rĮ t j d	 |   n  | d
 }  t	 |   rµt
 |   sž t t t |     }  n  t |   } | j rnt | j  \ } }	 }
 i | j d 6| j d 6| d 6|	 d 6|
 d 6| j d 6|  d 6} nC |  j d  rt |   } n |  } i d d 6t |  d 6|  d 6S| Si  } t j d |   } | rj| j   d
 } |  j | d  }  | d d !} t j d |  } xS | D]H } | j   \ } } } } | sG| rYt | d   n  | | | <qWn  t j d |   } i  } | r| j   d
 } |  j | d  }  | d d !} t j d |  } x0 | D]( } | j   \ } } } } | | | <qŠWd | k rt | d <qn  |  j d d  } t |  } | d k rT| \ } } }  nI | d k ru| \ } }  d  } n( | r| d
 }  d% \ } } n	 t    t  |  \ } } d | k r÷t  | j! d   \ } } | rå| } n  | r÷| } q÷n  d | k r| j! d  } n  t j d |   } | rd| j   \ } }  | d  k rst | d |    qsn t | d   |  o|  j   }  |  rRd |  k r©t | d   n  t" |   \ }	 }
 |	 d
 d  k r^|	 d   |	 d  d! k rž|
 d  k rž|	 d }	 qOt#   f d"   d# D  sO|
 d  k rC  d d k rC  d }	 qL  }	 qOq^n d& \ }	 }
 i  } | rp| n d | d <| d  k	 r| | d <n  | d  k	 r¬| | d <n  | d  k	 r»n  |	 d  k	 rŌ|	 | d <n  |
 d  k	 rķ|
 | d <n  | j$ |  | | d$ <| t  | <| S('   Nu   @i’’’’u   *u   nameu   track_featuresu   #u    if i   u   Ignoring conditional in spec %si    u   channelu   subdiru   versionu   buildu   fnu   urlu   file://u   .*(?:(\[.*\]))u    u2   ([a-zA-Z0-9_-]+?)=(["\']?)([^\'"]*?)(\2)(?:[, ]|$)u   key-value mismatch in bracketsu   .*(?:(\(.*\)))u   optionalu   :i   i   u   ([^ =<>!~]+)?([><!=~ ].+)?u   no package name found in '%s'u   no package name foundu   [u&   multiple brackets sections not allowedu   =u   ==c         3` s   |  ] } |   k Vq d  S(   N(    (   Rk   t   c(   t   test_str(    s6   lib/python2.7/site-packages/conda/models/match_spec.pys	   <genexpr>¾  s    u   =,|u   _original_spec_str(   NN(   NN(%   t   _PARSE_CACHERR   RE   t   indexR¹   RG   RF   t   logt   debugR   R    R"   R!   R   R   RM   R¾   t   package_filenamet   canonical_nameRz   R   R   R¶   Rc   Rø   Rŗ   t   finditerR$   Ra   RH   R4   t   NotImplementedErrorRĆ   R3   R¼   Rn   R.   (    t   spec_strt   cached_resultR-   t   feature_namet   ndxR½   t
   spec_splitt   channelRN   RO   RP   t   resultt   path_or_urlR}   t   m3t   brackets_strt   m3bRc   R   Rx   t   m4t   parenst
   parens_strt   m4bt   m5t   m5_lenRL   t	   namespaceRM   t	   b_channelt   b_subdirt
   components(    (   RÅ   s6   lib/python2.7/site-packages/conda/models/match_spec.pyR1   4  sī    

	


	
		


t   MatchInterfacec           B` sY   e  Z d    Z e d    Z d   Z e d    Z e d    Z	 d   Z
 d   Z RS(   c         C` s   | |  _  d  S(   N(   t
   _raw_value(   RC   Rx   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyRD   ß  s    c         C` s   t     d  S(   N(   RĶ   (   RC   R   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyRc   ā  s    c         C` s   |  j  |  S(   N(   Rc   (   RC   Rx   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyt   matchesę  s    c         C` s   |  j  S(   N(   Rä   (   RC   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyRW   é  s    c         C` s   t     d S(   ui   If the match value is an exact specification, returns the value.
        Otherwise returns None.
        N(   RĶ   (   RC   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyRS   ķ  s    c         C` s8   |  j  | j  k r1 t d |  j  | j  f   n  |  j  S(   Nu+   Incompatible component merge:
  - %r
  - %r(   RW   R¢   (   RC   R   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyR©   ō  s    c         C` s%   t  |  j | j f  } d j |  S(   Nu   |(   R2   RW   Rt   (   RC   R   t   options(    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyR   ś  s    (   R=   R>   RD   R   Rc   Rå   R“   RW   R   RS   R©   R   (    (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyRć   Ż  s   			t   _StrMatchMixinc           B` s;   e  Z d    Z d   Z d   Z d   Z e d    Z RS(   c         C` s   |  j  S(   N(   Rä   (   RC   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyR[     s    c         C` s   d |  j  j |  j f S(   Nu   %s('%s')(   Rr   R=   Rä   (   RC   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyRv     s    c         C` s"   t  | |  j  o! |  j | j k S(   N(   R&   Rr   Rä   (   RC   R   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyR     s    c         C` s   t  |  j  S(   N(   R   Rä   (   RC   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyR   
  s    c         C` s   |  j  S(   N(   Rä   (   RC   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyRS     s    (   R=   R>   R[   Rv   R   R   R“   RS   (    (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyRē   ’  s
   				R   c           B` s    e  Z d Z d   Z d   Z RS(   u
   _raw_valuec         C` s   t  t |   j |  d  S(   N(   R/   R   RD   (   RC   Rx   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyRD     s    c         C` s:   y | j  } Wn t k
 r, t |  } n X|  j  | k S(   N(   Rä   Re   R   (   RC   R   t
   _other_val(    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyRc     s
    (   u
   _raw_value(   R=   R>   t	   __slots__RD   Rc   (    (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyR     s   	t   ExactLowerStrMatchc           B` s   e  Z d    Z d   Z RS(   c         C` s    t  t |   j | j    d  S(   N(   R/   Rź   RD   t   lower(   RC   Rx   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyRD   "  s    c         C` s@   y | j  } Wn t k
 r, t |  } n X|  j  | j   k S(   N(   Rä   Re   R   Rė   (   RC   R   Rč   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyRc   %  s
    (   R=   R>   RD   Rc   (    (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyRź      s   	t   GlobStrMatchc           B` s>   e  Z d Z d   Z d   Z e d    Z e d    Z RS(   u
   _raw_valueu	   _re_matchc         C` s   t  t |   j |  d  |  _ | j d  rU | j d  rU t j |  j	 |  _ nC d | k r t j
 |  j d d  } t j d |  j	 |  _ n  d  S(   Nu   ^u   $u   *u   \*u   .*u   ^(?:%s)$(   R/   Rģ   RD   R4   t	   _re_matchRz   RE   R¶   t   compileRc   t   escapeRŗ   (   RC   Rx   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyRD   0  s    	c         C` sT   y | j  } Wn t k
 r, t |  } n X|  j rC |  j |  S|  j  | k Sd  S(   N(   Rä   Re   R   Rķ   (   RC   R   Rč   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyRc   :  s    	c         C` s   |  j  d  k r |  j Sd  S(   N(   Rķ   R4   Rä   (   RC   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyRS   E  s    c         C` s   |  j  d k S(   Nu   *(   Rä   (   RC   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyRy   I  s    (   u
   _raw_valueu	   _re_match(   R=   R>   Ré   RD   Rc   R“   RS   Ry   (    (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyRģ   -  s
   	
	t   GlobLowerStrMatchc           B` s   e  Z d    Z RS(   c         C` s    t  t |   j | j    d  S(   N(   R/   Rš   RD   Rė   (   RC   Rx   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyRD   P  s    (   R=   R>   RD   (    (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyRš   N  s   t   SplitStrMatchc           B` s\   e  Z d	 Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 e
 d    Z RS(
   u
   _raw_valuec         C` s#   t  t |   j |  j |   d  S(   N(   R/   Rń   RD   t   _convert(   RC   Rx   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyRD   W  s    c         C` sT   y# t  | j d d  j d   SWn* t k
 rO t |  rI t  |  S  n Xd  S(   Nu    u   ,(   R²   Rŗ   RG   Re   R   (   RC   Rx   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyRņ   Z  s    #
c         C` sA   y | o |  j  | j  @SWn" t k
 r< |  j  |  j |  @SXd  S(   N(   Rä   Re   Rņ   (   RC   R   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyRc   b  s    c         C` s5   |  j  r- d d j d   t |  j   D  Sd Sd  S(   Nu   {%s}u   , c         s` s   |  ] } d  | Vq d S(   u   '%s'N(    (   Rk   Rw   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pys	   <genexpr>j  s    u   set()(   Rä   Rt   R    (   RC   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyRv   h  s    	$c         C` s   d j  t |  j   S(   Nu    (   Rt   R    Rä   (   RC   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyR[   n  s    c         C` s"   t  | |  j  o! |  j | j k S(   N(   R&   Rr   Rä   (   RC   R   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyR   r  s    c         C` s   t  |  j  S(   N(   R   Rä   (   RC   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyR   u  s    c         C` s   |  j  S(   N(   Rä   (   RC   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyRS   x  s    (   u
   _raw_value(   R=   R>   Ré   RD   Rņ   Rc   Rv   R[   R   R   R“   RS   (    (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyRń   T  s   							t   FeatureMatchc           B` s\   e  Z d	 Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 e
 d    Z RS(
   u
   _raw_valuec         C` s#   t  t |   j |  j |   d  S(   N(   R/   Ró   RD   Rņ   (   RC   Rx   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyRD     s    c         C` sq   | s t    St | t  rO t  d   d   | j d d  j d  D D  St  d   d   | D D  Sd  S(   Nc         s` s   |  ] } | r | Vq d  S(   N(    (   Rk   R   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pys	   <genexpr>  s    c         s` s   |  ] } | j    Vq d  S(   N(   R¹   (   Rk   t   ff(    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pys	   <genexpr>  s    u    u   ,c         s` s   |  ] } | r | Vq d  S(   N(    (   Rk   R   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pys	   <genexpr>  s    c         s` s   |  ] } | j    Vq d  S(   N(   R¹   (   Rk   Rō   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pys	   <genexpr>  s    (   R²   R&   R   Rŗ   RG   (   RC   Rx   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyRņ     s    	*c         C` s   |  j  |  } |  j | k S(   N(   Rņ   Rä   (   RC   R   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyRc     s    c         C` s$   d d j  d   t |  j  D  S(   Nu   [%s]u   , c         s` s   |  ] } d  | Vq d S(   u   '%s'N(    (   Rk   t   k(    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pys	   <genexpr>  s    (   Rt   R    Rä   (   RC   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyRv     s    c         C` s   d j  t |  j   S(   Nu    (   Rt   R    Rä   (   RC   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyR[     s    c         C` s"   t  | |  j  o! |  j | j k S(   N(   R&   Rr   Rä   (   RC   R   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyR     s    c         C` s   t  |  j  S(   N(   R   Rä   (   RC   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyR     s    c         C` s   |  j  S(   N(   Rä   (   RC   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyRS     s    (   u
   _raw_value(   R=   R>   Ré   RD   Rņ   Rc   Rv   R[   R   R   R“   RS   (    (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyRó   }  s   		
					t   ChannelMatchc           B` s,   e  Z d    Z d   Z d   Z d   Z RS(   c         C` s«   d  |  _ t | t  r | j d  rN | j d  rN t j |  j |  _ q d | k r t j d | j	 d d   j |  _ q t
 |  } n  t t |   j |  d  S(   Nu   ^u   $u   *u   ^(?:%s)$u   .*(   R4   Rķ   R&   R   Rz   RE   R¶   Rī   Rc   Rŗ   R   R/   Rģ   RD   (   RC   Rx   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyRD   ¤  s    	(c         C` sx   y t  | j  } Wn t k
 r2 t  |  } n X|  j rL |  j | j  S|  j j | j k ps |  j j | j k Sd  S(   N(   R   Rä   Re   Rķ   RĖ   RN   (   RC   R   Rč   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyRc   ±  s    	c         C` s2   y d |  j  j SWn t k
 r- d |  j  SXd  S(   Nu   %s(   Rä   RN   Re   (   RC   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyR[   æ  s    c         C` s   d |  j    S(   Nu   '%s'(   R[   (   RC   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyRv   Å  s    (   R=   R>   RD   Rc   R[   Rv   (    (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyRö   ¢  s   			t   CaseInsensitiveStrMatchc           B` s   e  Z d    Z RS(   c         C` s`   y | j  } Wn t k
 r, t |  } n X| j   } |  j rO |  j |  S|  j  | k Sd  S(   N(   Rä   Re   R   Rė   Rķ   (   RC   R   Rč   (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyRc   Ė  s    	(   R=   R>   Rc   (    (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyR÷   É  s   u   channelu   nameu   versionu   buildu   build_numberu   track_featuresu   featuresu   licenseu   license_family(P   t
   __future__R    R   R   R   t   abcR   R   R   t   collections.abcR   t   ImportErrort   collectionst	   functoolsR   t   loggingR	   t   operatorR
   t   os.pathR   R¶   RÓ   R   RO   R   R   t   _vendor.auxlib.collectionR   t   _vendor.auxlib.decoratorsR   t   _vendor.toolzR   R   R   t   base.constantsR   t   common.compatR   R   R   R   R   R   t	   common.ioR   t   common.pathR   R   R   R   t
   common.urlR    R!   R"   t
   exceptionsR#   R$   R=   RČ   t   typeR%   t   objectR'   R¼   R¾   RĆ   RĘ   R1   Rć   Rē   R   Rź   Rģ   Rš   Rń   Ró   Rö   R÷   R   (    (    (    s6   lib/python2.7/site-packages/conda/models/match_spec.pyt   <module>   sh   "."&’ ø				©!!)%'