
    DIeԒ              
          d Z ddlZddlZddlmZmZmZ ddlmZ ddl	m
Z
 ddlmZ ddlmZ ddlmZ dd	lmZ dd
lmZ ddlm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" ddl#m$Z$m%Z%m&Z&m'Z' ddl(m)Z)m*Z*m+Z+ ddl,m-Z-m.Z. ddl/m0Z0 ddl1m2Z2m3Z3  ee4          Z5 G d de6          Z7 G d de7          Z8d Z9d Z:d Z;i Z<d  Z= G d! d"e          Z> G d# d$          Z? G d% d&e?e>          Z@ G d' d(e@          ZA G d) d*e?e>          ZB G d+ d,eB          ZC G d- d.e>          ZD G d/ d0e>          ZE G d1 d2eB          ZF G d3 d4eC          ZGeFeCe3eBe2eEeEeGeGd5	ZHdS )6zImplements the query language for conda packages (a.k.a, MatchSpec).

The MatchSpec is the conda package specification (e.g. `conda==23.3`, `python<3.7`,
`cryptography * *_0`) and is used to communicate the desired packages to install.
    N)ABCMetaabstractmethodabstractproperty)Mapping)reduce)chain)	getLogger)
attrgetter)basename)groupby_to_dict   )
frozendict)memoizedproperty)CONDA_PACKAGE_EXTENSION_V1CONDA_PACKAGE_EXTENSION_V2)context)
isiterable)dashlist)expandis_package_filestrip_pkg_extensionurl_to_path)is_urlpath_to_urlunquote)CondaValueErrorInvalidMatchSpec   )Channel)BuildNumberMatchVersionSpecc                         e Zd Zd fd	Z xZS )MatchSpecTypeNc                    |rt          |t                    r|s|S t          |t                    rzt          |j                  }|                    d|j                   |                    d|j                   |j        |d<    |j        di |  t                      j
        di |S t          |t                    rat          |          }|r7t          |fi |}t          |          ddhz
  r|                    dd             t                      j
        di |S t          |t                    r&t          |fi |} t                      j
        di |S t!          |d          r%|                                }|rt          |fi |S |S t%          d|d|           t                      j
        di |S )Noptionaltarget_original_spec_strto_match_speczInvalid MatchSpec:
  spec_arg=z

  kwargs= )
isinstance	MatchSpecdict_match_components
setdefaultr%   r&   original_spec_strupdatesuper__call__str_parse_spec_strsetpopr   hasattrr(   r   )clsspec_argkwargs
new_kwargsparsedspec	__class__s         7lib/python3.11/site-packages/conda/models/match_spec.pyr2   zMatchSpecType.__call__$   s    "	.(I.. v Hi00 !("<==
%%j(2CDDD%%h@@@3;3M
/0!
!++F+++'uww'55*555Hc** (22 ?!&33F33F6{{j(%;; ? 

#7>>>'uww'11&111Hg.. h11&11'uww'11&111?33 
--//  $T44V444K%oxx)  
 $577#--f---    N)__name__
__module____qualname__r2   __classcell__r>   s   @r?   r#   r#   #   s=        #. #. #. #. #. #. #. #. #. #.r@   r#   c                      e Zd ZdZdZ ee          Zi Zd&dZe	d             Z
d Zd Zd'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	d(d#            Z*e	d$             Z+d(d%Z,dS ))r+   a  The 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]'
    or '*[sha256=f453db4ffe2271ec492a2913af4e61d4a6c118201f07de757df0eff769b65d2e]'.
    )channelsubdirnameversionbuildbuild_numbertrack_featuresfeaturesurlmd5sha256licenselicense_familyfnFNc                 |    || _         || _        |                    dd           | _         | j        di || _        d S )Nr'   r)   )	_optional_targetr6   r'   _build_componentsr-   )selfr%   r&   r:   s       r?   __init__zMatchSpec.__init__   sH    !"(**-A4"H"H!7!7!A!A&!A!Ar@   c                 F   i }|t          t                     d          t          k    r|d t          t                              }nC|t          t                     d          t          k    r|d t          t                              }d|v rZ|                    dd          \  }}d|v r8|                    dd          \  }}|t
          j        vr|}d }||d<   |r||d<   n||d<   |                    dd          \  }}}|                    |||d            | d	i |S )
Nz::r   /rH   rI   -r   rJ   rK   rL   r)   )lenr   r   splitrsplitr   known_subdirsr0   )	r8   dist_strpartschannel_subdir_strchannel_strrI   rJ   rK   rL   s	            r?   from_dist_strzMatchSpec.from_dist_str   sf   S3444667;UUU B3'A#B#B"B BCHHs5666889=WWW B3'A#B#B"B BCH8+3>>$+B+B((((&8&?&?Q&G&G#V!666"4K!F#.i  -&,E(O#5i 'sA66gu" 	
 	
 	
 s||U||r@   c                 H    | j                             |          }|o|j        S rA   )r-   getexact_valuerZ   
field_namevs      r?   get_exact_valuezMatchSpec.get_exact_value   s%    "&&z22"Q]"r@   c                 H    | j                             |          }|o|j        S rA   )r-   rj   	raw_valuerl   s      r?   get_raw_valuezMatchSpec.get_raw_value   s%    "&&z22 Q[ r@   c                 8    |                      |          }||n|S rA   )rr   )rZ   rm   defaultrn   s       r?   rj   zMatchSpec.get   s#    z**)ww*r@   c                 Z    t          | j                  dk    od| j        v o
| j        dk    S )Nr   rJ   *)r`   r-   rJ   rZ   s    r?   is_name_only_speczMatchSpec.is_name_only_spec   s;     &''1, !$00!	S 	
r@   c                 *    |                                  S rA   __str__rw   s    r?   rd   zMatchSpec.dist_str       ||~~r@   c                     | j         S rA   )rW   rw   s    r?   r%   zMatchSpec.optional   s
    ~r@   c                     | j         S rA   )rX   rw   s    r?   r&   zMatchSpec.target   s
    |r@   c                     | j         S rA   )r'   rw   s    r?   r/   zMatchSpec.original_spec_str   s    &&r@   c                     t          |t                    rddlm} |                    |          }| j                                        D ]\  }}|                     |||          s dS  dS )z
        Accepts a `PackageRecord` or a dict, and matches can pull from any field
        in that record.  Returns True for a match, and False for no match.
        r   )PackageRecordFT)r*   r,   recordsr   from_objectsr-   items_match_individual)rZ   recr   rm   rn   s        r?   matchzMatchSpec.match   s    
 c4   	2......,,S11C!399;; 	 	MJ))#z1== uutr@   c                 z    t          ||          }	 |                    |          S # t          $ r	 ||k    cY S w xY wrA   )getattrr   AttributeError)rZ   recordrm   match_componentvals        r?   r   zMatchSpec._match_individual  sV    fj))	*"((--- 	* 	* 	*"c))))	*s   ' ::c                 `    t          | j                  dk    o|                     d          d uS )Nr   rJ   )r`   r-   ro   rw   s    r?   
_is_simplezMatchSpec._is_simple  s5    &''1, 9$$V,,D8	
r@   c                 2    t          | j                  dk    S )Nr   )r`   r-   rw   s    r?   
_is_singlezMatchSpec._is_single  s    4)**a//r@   c                                            d          }|r|S t           fddD                       }t          d |D                       sd|z  t          z   S d S )NrU   c              3   B   K   | ]}                     |          V  d S rA   ro   ).0xrZ   s     r?   	<genexpr>z4MatchSpec._to_filename_do_not_use.<locals>.<genexpr>  s1      SST))!,,SSSSSSr@   r_   c              3      K   | ]}|d u V  	d S rA   r)   )r   r   s     r?   r   z4MatchSpec._to_filename_do_not_use.<locals>.<genexpr>  s&      ++19++++++r@   z%s-%s-%s)ro   tupleanyr   )rZ   fn_fieldvalss   `  r?   _to_filename_do_not_usez!MatchSpec._to_filename_do_not_use  s}     ''-- 	OSSSS6RSSSSS++d+++++ 	%)CCC4r@   c                     | j         j         d|  dg}| j        r|                    d| j        z             | j        r|                    d           |                    d           d                    |          S )Nz(""z, target="%s"z, optional=True) )r>   rB   r&   appendr%   join)rZ   builders     r?   __repr__zMatchSpec.__repr__!  s    n-888889; 	:NN?T[8999= 	.NN,---swwwr@   c                   	
 g }g }| j                             d          }|r*|j        r#|                    t	          |                     n.|r,|j        s%|                    dt	          |          z             | j                             d          }|r:|r |j        r|                    d|z             n|                    d|z             | j                             dd          }|                    |rdnd	|z             | j                             d
          | j                             d          	d}r#t	                    t          fddD                       r|                    dz             nd d         dv r1	r|                    dz             n|                               ndd          dk    r!|                    dd d         z              ntd         dk    r!|                    dd d         z              nG                    d          r|                               d}n|                    dz              d}	rt	          	          	t          	fddD                       r|                    d	z             nPd	v r|                    d	z             n3|r|                    d	z              n|                    d	z             h d}d| j         v rd| j         v r|                    d           | j	        D ]}||vr}|| j         v rt|dk    r|rt	          | j         |                   
t          
fddD                       r|                    | d 
 d!           i|                    | d
            |r+|                    d"d#
                    |          z             d$
                    |          S )%NrH   z
channel=%srI   z/%sz	subdir=%srJ   rv   z::%s%srK   rL   Fc              3       K   | ]}|v V  	d S rA   r)   )r   srK   s     r?   r   z$MatchSpec.__str__.<locals>.<genexpr>C  s'      22A1<222222r@   z><$^|,zversion='%s'r   )z!=z~=.*===Tc              3       K   | ]}|v V  	d S rA   r)   )r   r   rL   s     r?   r   z$MatchSpec.__str__.<locals>.<genexpr>W  s'      00!1:000000r@   z
build='%s'zbuild=%s>   rJ   rL   rI   rH   rK   rP   rU   c              3       K   | ]}|v V  	d S rA   r)   )r   r   values     r?   r   z$MatchSpec.__str__.<locals>.<genexpr>i  s'      11aqEz111111r@   z, =z=''[%s],r   )r-   rj   rk   r   r3   matches_allr   
startswithaddFIELD_NAMESr   )rZ   r   bracketschannel_matchersubdir_matchername_matcherversion_exact_skipkeyrL   r   rK   s            @@@r?   r{   zMatchSpec.__str__*  sy   044Y?? 	A: 	ANN3//0000 	A_%@ 	AOOL3+?+??@@@/33H== 	> >?#> >u~56666n <===-11&#>>'3t|CDDD(,,Y77&**733 	%'llG222222222 % 89999!,, ,OONW$<====NN7++++%%sWSbS\12222##sWSbS\12222##D)) %w''' $tg~... $ 		4JJE0000x00000 4u 45555
U 23333 4sU{++++
U 2333AAAD***tt7M/M/MIIdOOO# 		6 		6C%C4+A$A$A%<<O<D237881111511111 6OOs$6$6e$6$6$67777OOs$4$4U$4$4555 	8NN6CHHX$6$66777wwwr@   c                 *    |                                  S rA   rz   rw   s    r?   __json__zMatchSpec.__json__s  r|   r@   c                 *   g }|                      d          }|sJ |                    |           |                     d          }|                     d          }|r|sJ |||gz  }n|r|                    |           d                    |          S )NrJ   rL   rK    )ro   r   rr   r   )rZ   r   rJ   rL   rK   s        r?   conda_build_formzMatchSpec.conda_build_formv  s    ##F++t""7++$$Y// 	$NNN''GG 	$NN7###xx   r@   c                 P    t          |t                    r| j        |j        k    S dS )NF)r*   r+   	_hash_keyrZ   others     r?   __eq__zMatchSpec.__eq__  s(    eY'' 	>U_445r@   c                 *    t          | j                  S rA   )hashr   rw   s    r?   __hash__zMatchSpec.__hash__  s    DN###r@   c                 *    | j         | j        | j        fS rA   )r-   r%   r&   rw   s    r?   r   zMatchSpec._hash_key  s    %t}dkAAr@   c                     || j         v S rA   r-   )rZ   fields     r?   __contains__zMatchSpec.__contains__  s    ...r@   c                     t          |          t          j        z
  }|rt          | j        d|z            t          j        t          fd|                                D                       S )NzCannot match on field(s): %sc              3   6   K   | ]\  }} ||          V  d S rA   r)   )r   r   r   _make_components      r?   r   z.MatchSpec._build_components.<locals>.<genexpr>  s3      WW*#u//#u55WWWWWWr@   )r5   r+   FIELD_NAMES_SETr   r'   r   r   r   )rZ   r:   
not_fieldsr   s      @r?   rY   zMatchSpec._build_components  ss    [[9#<<
 	"')G*)T   $3WWWWWWWWWWr@   c                    t          |d          r|}| |fS t          j        }| |f}|                    |          }|r| |fS | t          v rt	          |          |          }nt          t          |                    }||| |f<   | |fS )Nr   )r7   r+   _MATCHER_CACHErj   _implementorsExactStrMatchr3   )rm   r   matcherr   	cache_keycached_matchers         r?   r   zMatchSpec._make_component  s    5'"" 	'Gw&&"1'	'++I66 	.~--&&#J/66GG#CJJ//G.5
E*+7""r@   c                 0    |                      d          pdS )NrJ   rv   r   rw   s    r?   rJ   zMatchSpec.name  s    ##F++2s2r@   c                      t           fddD                       }|t           j                  k     rdS                      d          r	d j        v rdS d j        v rdS dS )	Nc              3   *   K   | ]}|j         v V  d S rA   r   )r   frZ   s     r?   r   z'MatchSpec.strictness.<locals>.<genexpr>  s+      RRT++RRRRRRr@   r_      rJ   rL   rK   r   r   )sumr`   r-   ro   )rZ   r   s   ` r?   
strictnesszMatchSpec.strictness  s     RRRR5QRRRRRs4)****1%%f-- 	D<R1R1R1$00011r@   c                 *    |                                  S rA   )r   rw   s    r?   r=   zMatchSpec.spec  s    $$&&&r@   c                 6    | j                             d          S )NrK   )r-   rj   rw   s    r?   rK   zMatchSpec.version  s     %)))444r@   c                     |                      d          p|                      d          }|rt          |          }|sJ |S )NrU   rP   )rr   r   )rZ   r   s     r?   rU   zMatchSpec.fn  sI      &&C$*<*<U*C*C 	 3--C



r@   c                     t          t           fd|D                       t                    }t          t	          d          |          }|                    dg           |                    d g           z   }g }t          t          j        d |                                D                                 }|D ]}t          t	          d          |          }|                    d d            t          |          dk    rt          dt          |          z            |                    t          |          dk    rt          fd	|          n|d
                    g ||R S )Nc              3   2   K   | ]}| |          V  d S rA   r)   )r   r   r8   s     r?   r   z"MatchSpec.merge.<locals>.<genexpr>  s0      "D"Da!"D33q66"D"D"D"D"D"Dr@   )r   rJ   rv   c              3   \   K   | ]'}t          d  |                                          V  (dS )c                     | j         S rA   )r%   )r   s    r?   <lambda>z+MatchSpec.merge.<locals>.<genexpr>.<lambda>  s    !* r@   N)groupbyvalues)r   groups     r?   r   z"MatchSpec.merge.<locals>.<genexpr>  sP           ,,e44;;==           r@   r&   r   zIncompatible MatchSpec merge:%sc                 0    |                      |          S rA   )_merge)r   yunions     r?   r   z!MatchSpec.merge.<locals>.<lambda>  s    AHHQ$6$6 r@   r   )sortedr   r3   r   r
   r6   r   from_iterabler   r`   
ValueErrorr   r   r   )	r8   match_specsr   name_groupsunmergeablemerged_specsmergeable_groupsr   target_groupss	   ` `      r?   mergezMatchSpec.merge  s   U"D"D"D"D;"D"D"DDD#NNNj00+>>!ooc2..r1J1JJ     (//11       
 
 & 		 		E#Jx$8$8%@@MdD)))=!!A%% !BXe__!TUUUu::>> 6666>>>1X   
 -,,,,r@   c                 0    |                      |d          S )NT)r   )r   )r8   r   s     r?   r   zMatchSpec.union  s    yyDy111r@   c                 @   | j         |j         k    s| j        |j        k    rt          d|  d|           i }t          | j                  t          |j                  z  }|D ]}| j                            |          }|j                            |          }||;||||<   C||||<   K|r;	 |                    |          }n9# t          t          t          f$ r
 | d| }Y nw xY w|	                    |          }|||<    | j
        d| j         | j        d|S )Nz!Incompatible MatchSpec merge:  - 
  - |)r%   r&   r)   )r%   r&   r   r5   r-   rj   r   r   	TypeErrorr   r>   )	rZ   r   r   final_componentscomponent_namescomponent_namethis_componentthat_componentfinals	            r?   r   zMatchSpec._merge  s   =EN**dkU\.I.ITTTUTTUUUd455E<S8T8TT- 	9 	9N!377GGN"488HHN%.*@'3A 00'3A 00 AE . 4 4^ D D*J	B E E E#1 D DN D DE +00@@E38 00t~ 
]4;
 
:J
 
 	
s   1CC('C()FNrA   )F)-rB   rC   rD   __doc__r   	frozensetr   r   r[   classmethodrh   ro   rr   rj   propertyrx   rd   r%   r&   r/   r   r   r   r   r   r   r{   r   r   r   r   r   r   r   rY   staticmethodr   rJ   r   r=   rK   rU   r   r   r   r)   r@   r?   r+   r+   J   s       O ObK   i,,ONB B B B   [:# # #! ! !+ + + + 
 
 X
     X   X ' ' X'  * * *
 
 
0 0 0
 
 
     G  G  G R  ! ! !"  $ $ $ B B B/ / /X X X # # \#" 3 3 X3   X ' ' X' 5 5 X5
   X - - - [-0 2 2 [2
 
 
 
 
 
r@   r+   )	metaclassc                     t          j        d|           }|r.|                                \  }}|o|                                }n| d}}|o|                    dd          |fS )a  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("* *")
        ('*', '*')
    z<((?:.+?)[^><!,|]?)(?:(?<![=!|,<>~])(?:[ =])([^-=,|<>~]+?))?$Nr   r   )researchgroupsstripreplace)v_plus_bre   rK   rL   s       r?   _parse_version_plus_buildr    sp    ( IG E  ('%++--!4/wsB//66r@   c                 d    t          |           \  } }|                     dd          \  }}}|||fS )z
    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')
    r^   r   )r   rb   )rd   _rJ   rK   rL   s        r?   _parse_legacy_distr  3  s<     &h//KHa#??322D'5%r@   c                 V    | sdS t          |           }|j        p|j        }||j        fS )NNN)r   rJ   base_urlrI   )channel_valchnchannel_names      r?   _parse_channelr   @  s7     z
+

C8+s|L##r@   c                 H
  ! t                               |           }|r|S | }|                     d          r| d d         }d|fdS d| v r=|                     d          }| d |         | |d          }} |                                  |                     dd          }t          |          dk    rt                              d|            |d	         } t          |           rt          |           s)t          t          t          |                               } t          |           }|j        r2t!          |j                  \  }}	}
|j        |j        ||	|
|j        | d
}n:|                     d          rt)          |           }n| }dt+          |          | dS |S i }t-          j        d|           }|r|                                d	         }|                     |d          } |dd         }t-          j        d|          }|D ]4}|                                \  }}}}|r|st7          |d          |||<   5t-          j        d|           }i }|r{|                                d	         }|                     |d          } |dd         }t-          j        d|          }|D ] }|                                \  }}}}|||<   !d|v rd|d<   |                     dd          }t          |          }|dk    r|\  }}} n,|dk    r|\  }} d }n|r|d	         } d\  }}nt;                      t=          |          \  }}d|v r-t=          |                    d                    \  }}|r|}|r|}d|v r|                    d          }t-          j        d|           }|r-|                                \  }} |t7          |d| z            nt7          |d          | o|                                 } | rd| v rt7          |d          tA          |           \  }	}
|	dk    s|	d k    rnh|	d	         d k    rV|	dd          !|	d d         dk    r|
|	dd          }	n7tC          !fd!d"D                       s|
!d         dk    r!dz   }	n!}	nd\  }	}
i }|pd|d#<   |||d<   |||d<   |	 |	|	|d$<   |
|
|d%<   d#|v r?d#|v r;d&|d#          d'|d#          d(|d#          d)} tE          j#        | tH                     |d#= |%                    |           ||d*<   |t           |<   |S )+N@r   rv   )rJ   rN   #z if r   zIgnoring conditional in spec %sr   )rH   rI   rJ   rK   rL   rU   rP   zfile://)rJ   rU   rP   z.*(?:(\[.*\]))r   z2([a-zA-Z0-9_-]+?)=(["\']?)([^\'"]*?)(\2)(?:[, ]|$)zkey-value mismatch in bracketsz.*(?:(\(.*\)))r%   T:r   r   r  rH   rI   z([^ =<>!~]+)?([><!=~ ].+)?zno package name found in '%s'zno package name found[z&multiple brackets sections not allowedr   r   c              3       K   | ]}|v V  	d S rA   r)   )r   ctest_strs     r?   r   z"_parse_spec_str.<locals>.<genexpr>  s'      661h666666r@   z=,|rJ   rK   rL   z'name' specified both inside (z) and outside (z.) of brackets. The value outside of brackets (z) will be used.r'   )&_PARSE_CACHErj   endswithindexr  ra   r`   logdebugr   r   r   r   r   r   rI   r  package_filenamecanonical_namer   r   r   r  r   r  r  finditerr   rb   NotImplementedErrorr   r6   r  r   warningswarnUserWarningr0   )"spec_strcached_resultr/   feature_namendxr  
spec_splitrH   rJ   rK   rL   resultpath_or_urlr   m3brackets_strm3br   r   r   m4parens
parens_strm4bm5m5_lenrg   	namespacerI   	b_channelb_subdir
componentsmsgr(  s"                                    @r?   r4   r4   K  s    $$X..M    
}+o
 
 	
 hnnS!!ttnhsttn! **J
:		3X>>>!}H x   h 	>{6(+;+;<<==H(##> 	#5g6N#O#O D'5"1!.". FF ""9-- ')(33& {++  
  H	#X	.	.B	 "yy{{1~##L"55#AbD)kA<
 
  	" 	"E$||~~CE1 e &%'G   "HSMM 
#X	.	.BF	 &YY[[^
##J33"%
kA:
 
  	  	 E$||~~CE1F3KK##!%F: 
a	 	 BWWF{{+-(Y	1 	8	 $a5!+YY!###$[11OGVH,X\\)-D-DEE	8 	 G 	F8h'' 
/	:	:B	 Kh<"!#BX#M   
 02IJJJ ,HNN,,H
  "$(??"!#K   38<< d??gnn QZ3qrr{Hrr{d""u}!!""+666666666 '=Xb\S%8%8&nGG&G# JJv '
9%
8 '
9#
7 ( 2 24Xf-= 4 46"4 46"4 4 4 	
 	c;'''Vh'8J#$&0L"#r@   c                   h    e Zd Zd Zed             Zd Zed             Ze	d             Z
d Zd ZdS )	MatchInterfacec                     || _         d S rA   
_raw_valuerZ   r   s     r?   r[   zMatchInterface.__init__  s    r@   c                     t                      rA   r1  r   s     r?   r   zMatchInterface.match  s    !###r@   c                 ,    |                      |          S rA   )r   rO  s     r?   matcheszMatchInterface.matches!  s    zz%   r@   c                     | j         S rA   rM  rw   s    r?   rq   zMatchInterface.raw_value$  
    r@   c                     t                      )ziIf the match value is an exact specification, returns the value.
        Otherwise returns None.
        rQ  rw   s    r?   rk   zMatchInterface.exact_value(  s    
 "###r@   c                 n    | j         |j         k    rt          d| j         d|j                   | j         S )Nz"Incompatible component merge:
  - r   )rq   r   r   s     r?   r   zMatchInterface.merge/  sC    >U_,,*>>>5??4   ~r@   c                 H    | j         |j         h}d                    |          S )Nr  )rq   r   )rZ   r   optionss      r?   r   zMatchInterface.union7  s"    >5?3xx   r@   N)rB   rC   rD   r[   r   r   rS  r  rq   r   rk   r   r   r)   r@   r?   rK  rK    s              $ $ ^$! ! !   X $ $ $  ! ! ! ! !r@   rK  c                   <    e Zd Zd Zd Zd Zd Zed             ZdS )_StrMatchMixinc                     | j         S rA   rM  rw   s    r?   r{   z_StrMatchMixin.__str__=  s
    r@   c                 0    | j         j         d| j         dS )Nz('z'))r>   rB   rN  rw   s    r?   r   z_StrMatchMixin.__repr__@  s     .)@@T_@@@@r@   c                 L    t          || j                  o| j        |j        k    S rA   r*   r>   rN  r   s     r?   r   z_StrMatchMixin.__eq__C  #    %00XT_HX5XXr@   c                 *    t          | j                  S rA   r   rN  rw   s    r?   r   z_StrMatchMixin.__hash__F      DO$$$r@   c                     | j         S rA   rM  rw   s    r?   rk   z_StrMatchMixin.exact_valueI  rU  r@   N)	rB   rC   rD   r{   r   r   r   r  rk   r)   r@   r?   r[  r[  <  sq          A A AY Y Y% % %   X  r@   r[  c                   (     e Zd ZdZ fdZd Z xZS )r   rM  c                 J    t                                          |           d S rA   )r1   r[   rZ   r   r>   s     r?   r[   zExactStrMatch.__init__Q  s!    r@   c                 h    	 |j         }n# t          $ r t          |          }Y nw xY w| j         |k    S rA   )rN  r   r3   rZ   r   
_other_vals      r?   r   zExactStrMatch.matchT  sH    	$)JJ 	$ 	$ 	$UJJJ	$*,,   
 &&)rB   rC   rD   	__slots__r[   r   rE   rF   s   @r?   r   r   N  sL        I         - - - - - - -r@   r   c                   $     e Zd Z fdZd Z xZS )ExactLowerStrMatchc                 n    t                                          |                                           d S rA   r1   r[   lowerrg  s     r?   r[   zExactLowerStrMatch.__init__]  )    '''''r@   c                     	 |j         }n# t          $ r t          |          }Y nw xY w| j         |                                k    S rA   )rN  r   r3   rq  ri  s      r?   r   zExactLowerStrMatch.match`  sT    	$)JJ 	$ 	$ 	$UJJJ	$*"2"2"4"444rk  )rB   rC   rD   r[   r   rE   rF   s   @r?   rn  rn  \  sG        ( ( ( ( (5 5 5 5 5 5 5r@   rn  c                   T     e Zd ZdZ fdZd Zed             Zed             Z xZ	S )GlobStrMatch)rN  	_re_matchc                    t                                          |           d | _        	 |                    d          r5|                    d          r t          j        |          j        | _        d S d|v rKt          j        |          	                    dd          }t          j        d|z            j        | _        d S d S # t
          j
        $ r}t          |d| d          d }~ww xY w)	N^$rv   z\*r   ^(?:%s)$)Contains an invalid regular expression. 'r   )r1   r[   rv  r   r*  r  compiler   escaper  errorr   rZ   r   er>   s      r?   r[   zGlobStrMatch.__init__k  s    		$$ G)<)< G!#E!2!2!8	%((00>>!#K%,?!@!@!F  x 	 	 	"G1GGG  	s   AC 5AC C.C))C.c                     	 |j         }n# t          $ r t          |          }Y nw xY w| j        r|                     |          S | j         |k    S rA   )rN  r   r3   rv  ri  s      r?   r   zGlobStrMatch.matchz  sf    	$)JJ 	$ 	$ 	$UJJJ	$ > 	1>>*---?j00rk  c                 "    | j         | j        nd S rA   )rv  rN  rw   s    r?   rk   zGlobStrMatch.exact_value  s    "&."8tdBr@   c                     | j         dk    S )Nrv   rM  rw   s    r?   r   zGlobStrMatch.matches_all  s    #%%r@   )
rB   rC   rD   rl  r[   r   r  rk   r   rE   rF   s   @r?   ru  ru  h  s        )I    	1 	1 	1 C C XC & & X& & & & &r@   ru  c                        e Zd Z fdZ xZS )GlobLowerStrMatchc                 n    t                                          |                                           d S rA   rp  rg  s     r?   r[   zGlobLowerStrMatch.__init__  rr  r@   )rB   rC   rD   r[   rE   rF   s   @r?   r  r    s8        ( ( ( ( ( ( ( ( (r@   r  c                   \     e Zd ZdZ fdZd Zd Zd Zd Zd Z	d Z
ed	             Z xZS )
SplitStrMatchrM  c                 p    t                                          |                     |                     d S rA   r1   r[   _convertrg  s     r?   r[   zSplitStrMatch.__init__  -    u--.....r@   c                     	 t          |                    dd                              d                    S # t          $ r" t	          |          rt          |          cY S  w xY w)Nr   r   )r
  r  ra   r   r   rO  s     r?   r  zSplitStrMatch._convert  ss    	U]]344::3??@@@ 	 	 	%   ( '''''	s   58 (A$"A$c                     	 |o| j         |j         z  S # t          $ r  | j         |                     |          z  cY S w xY wrA   )rN  r   r  r   s     r?   r   zSplitStrMatch.match  sV    	:?T_u/??? 	: 	: 	:?T]]5%9%99999	:s    '==c                 |    | j         r4dd                    d t          | j                   D                       z  S dS )Nz{%s}, c              3       K   | ]	}d |z  V  
dS '%s'Nr)   )r   r   s     r?   r   z)SplitStrMatch.__repr__.<locals>.<genexpr>  s&      %R%RQfqj%R%R%R%R%R%Rr@   zset())rN  r   r   rw   s    r?   r   zSplitStrMatch.__repr__  sA    ? 	DII%R%R&:Q:Q%R%R%RRRRR7r@   c                 P    d                     t          | j                            S Nr   r   r   rN  rw   s    r?   r{   zSplitStrMatch.__str__  s    xxt//000r@   c                 L    t          || j                  o| j        |j        k    S rA   r_  r   s     r?   r   zSplitStrMatch.__eq__  r`  r@   c                 *    t          | j                  S rA   rb  rw   s    r?   r   zSplitStrMatch.__hash__  rc  r@   c                     | j         S rA   rM  rw   s    r?   rk   zSplitStrMatch.exact_value  rU  r@   rB   rC   rD   rl  r[   r  r   r   r{   r   r   r  rk   rE   rF   s   @r?   r  r    s        I/ / / / /  : : :  1 1 1Y Y Y% % %   X    r@   r  c                   \     e Zd ZdZ fdZd Zd Zd Zd Zd Z	d Z
ed	             Z xZS )
FeatureMatchrM  c                 p    t                                          |                     |                     d S rA   r  rg  s     r?   r[   zFeatureMatch.__init__  r  r@   c                 &   |st                      S t          |t                    rJt          d d |                    dd                              d          D             D                       S t          d d |D             D                       S )Nc              3      K   | ]}||V  	d S rA   r)   r   r   s     r?   r   z(FeatureMatch._convert.<locals>.<genexpr>  s<             r@   c              3   >   K   | ]}|                                 V  d S rA   r  r   ffs     r?   r   z(FeatureMatch._convert.<locals>.<genexpr>  s*      RR"((**RRRRRRr@   r   r   c              3      K   | ]}||V  	d S rA   r)   r  s     r?   r   z(FeatureMatch._convert.<locals>.<genexpr>  s'      JJ1JQJJJJJJr@   c              3   >   K   | ]}|                                 V  d S rA   r  r  s     r?   r   z(FeatureMatch._convert.<locals>.<genexpr>  s*      (D(D(D(D(D(D(D(Dr@   )r
  r*   r3   r  ra   rO  s     r?   r  zFeatureMatch._convert  s     		K;;s## 	K  RRu}}S#/F/F/L/LS/Q/QRRR      JJ(D(De(D(D(DJJJJJJr@   c                 B    |                      |          }| j        |k    S rA   )r  rN  r   s     r?   r   zFeatureMatch.match  s     e$$%''r@   c                 j    dd                     d t          | j                  D                       z  S )Nr   r  c              3       K   | ]	}d |z  V  
dS r  r)   )r   ks     r?   r   z(FeatureMatch.__repr__.<locals>.<genexpr>  s&      !N!N&1*!N!N!N!N!N!Nr@   r  rw   s    r?   r   zFeatureMatch.__repr__  s2    		!N!NfT_6M6M!N!N!NNNNNr@   c                 P    d                     t          | j                            S r  r  rw   s    r?   r{   zFeatureMatch.__str__  s    xxt//000r@   c                 L    t          || j                  o| j        |j        k    S rA   r_  r   s     r?   r   zFeatureMatch.__eq__  r`  r@   c                 *    t          | j                  S rA   rb  rw   s    r?   r   zFeatureMatch.__hash__  rc  r@   c                     | j         S rA   rM  rw   s    r?   rk   zFeatureMatch.exact_value  rU  r@   r  rF   s   @r?   r  r    s        I/ / / / /
K 
K 
K( ( (O O O1 1 1Y Y Y% % %   X    r@   r  c                   0     e Zd Z fdZd Zd Zd Z xZS )ChannelMatchc                    d | _         	 t          |t                    r|                    d          r4|                    d          rt          j        |          j        | _         nId|v r6t          j        d|                    dd          z            j        | _         nt          |          }n+# t
          j
        $ r}t          |d| d          d }~ww xY wt          t          |                               |           d S )Nrx  ry  rv   rz  r   r{  r   )rv  r*   r3   r   r*  r  r|  r   r  r   r~  r   r1   ru  r[   r  s      r?   r[   zChannelMatch.__init__  s   	%%% +##C(( +U^^C-@-@ +%'Z%6%6%<DNNE\\%'Z#emmC&?&??& & NN $ENNEx 	 	 	"G1GGG  	
 	lD!!**511111s   B'B2 2CCCc                     	 t          |j                  }n# t          $ r t          |          }Y nw xY w| j        r|                     |j                  S | j        j        |j        |j        fv S rA   )r   rN  r   rv  r/  rJ   ri  s      r?   r   zChannelMatch.match  s    	( !122JJ 	( 	( 	( JJJ	( > 	X>>*";<<< ?'JOZ=V+WWWs    33c                 V    	 d| j         j        z  S # t          $ r d| j         z  cY S w xY w)Nr   )rN  rJ   r   rw   s    r?   r{   zChannelMatch.__str__  sE    	*$/... 	* 	* 	*$/))))	*s    ((c                 0    d|                                  z  S )Nr  rz   rw   s    r?   r   zChannelMatch.__repr__  s    &&r@   )rB   rC   rD   r[   r   r{   r   rE   rF   s   @r?   r  r    sh        2 2 2 2 2(X X X* * *' ' ' ' ' ' 'r@   r  c                       e Zd Zd ZdS )CaseInsensitiveStrMatchc                     	 |j         }n# t          $ r t          |          }Y nw xY w|                                }| j        r|                     |          S | j         |k    S rA   )rN  r   r3   rq  rv  ri  s      r?   r   zCaseInsensitiveStrMatch.match  sw    	$)JJ 	$ 	$ 	$UJJJ	$  %%''
> 	1>>*---?j00rk  N)rB   rC   rD   r   r)   r@   r?   r  r    s#        
1 
1 
1 
1 
1r@   r  )	rH   rJ   rK   rL   rM   rN   rO   rS   rT   )Ir	  r  r2  abcr   r   r   collections.abcr   	functoolsr   	itertoolsr   loggingr	   operatorr
   os.pathr   conda.common.iteratorsr   r   auxlib.collectionr   auxlib.decoratorsr   base.constantsr   r   base.contextr   common.compatr   	common.ior   common.pathr   r   r   r   
common.urlr   r   r   
exceptionsr   r   rH   r   rK   r    r!   rB   r,  typer#   r+   r  r  r   r)  r4   rK  r[  r   rn  ru  r  r  r  r  r  r   r)   r@   r?   <module>r     sM   
 
			  9 9 9 9 9 9 9 9 9 9 # # # # # #                               = = = = = = * * * * * * 0 0 0 0 0 0 S S S S S S S S " " " " " " & & & & & &             S S S S S S S S S S S S 5 5 5 5 5 5 5 5 5 5 : : : : : : : :       2 2 2 2 2 2 2 2i$. $. $. $. $.D $. $. $.NG
 G
 G
 G
 G
- G
 G
 G
 G
T7 7 7>
  
  
 $ $ $ K K K\ !  !  !  !  !w  !  !  !  !F       $- - - - -NN - - -	5 	5 	5 	5 	5 	5 	5 	5#& #& #& #& #&>> #& #& #&L( ( ( ( ( ( ( (
& & & & &N & & &R$ $ $ $ $> $ $ $N)' )' )' )' )'< )' )' )'X1 1 1 1 1/ 1 1 1 $"&-
 
r@   