
    .Ph                        d dl Z d dlmZ d dlmZ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mZ d dlmZ  e j        e          Zd	ee         d
ee         defdZ edee          Zdeee                  dee         fdZdS )    N)chain)DictListTupleTypeVar)ordered_union)ChannelAggregationError)Channel)
DependencyLockSpecification)PipRepository
lock_specs	platformsreturnc                   
 | D ]n}t          |j                  t          |          k    rGt          dt          |           dd |j        D              dt          |j                   d          oi }|D ]^
i }t	          j        
fd| D                       D ]}|j        |j        f}|||<   t          |	                                          |
<   _	 t          d | D                       }n # t          $ r}t          |j         d }~ww xY w	 t          d | D                       }	n # t          $ r}t          |j         d }~ww xY wt          |||	t          d	 | D                       t          d
 | D                                 S )NzcLock specifications must have the same platforms in order to be aggregated. Expected platforms are z", but the lock specification from c                 ,    g | ]}t          |          S  )str).0ss     a/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/conda_lock/src_parser/aggregation.py
<listcomp>z(aggregate_lock_specs.<locals>.<listcomp>   s    &I&I&I!s1vv&I&I&I    z has platforms .c              3   N   K   | ]}|j                             g           V   d S N)dependenciesget)r   	lock_specplatforms     r   	<genexpr>z'aggregate_lock_specs.<locals>.<genexpr>!   sG       '
 '
9BI"&&x44'
 '
 '
 '
 '
 '
r   c                     g | ]	}|j         
S r   )channelsr   r   s     r   r   z(aggregate_lock_specs.<locals>.<listcomp>+   s    <<<IY<<<r   c                     g | ]	}|j         
S r   )pip_repositoriesr$   s     r   r   z(aggregate_lock_specs.<locals>.<listcomp>4   s    DDDIY'DDDr   c              3   $   K   | ]}|j         V  d S r   )sourcesr$   s     r   r!   z'aggregate_lock_specs.<locals>.<genexpr>?   s%      LLIi/LLLLLLr   c              3   $   K   | ]}|j         V  d S r   )allow_pypi_requestsr$   s     r   r!   z'aggregate_lock_specs.<locals>.<genexpr>@   s6        
  
.7I) 
  
  
  
  
  
r   )r   r#   r&   r(   r*   )setr   
ValueErrorr(   r   from_iterablemanagernamelistvaluesunify_package_sourcesr	   argsr   r   all)r   r   r   r   unique_depsdepkeyr#   er&   r    s             @r   aggregate_lock_specsr9      sJ       	y"##s9~~55969)nn9 9&I&Iy7H&I&I&I9 9 !!4559 9 9   6 13L 	< 	<9;& '
 '
 '
 '
FP'
 '
 '
 
 
 	# 	#C ;)C"K!%k&8&8&:&:!;!;X/(<<<<<
 
  / / /%qv..// 1DDDDD
 
  / / /%qv../ !)LLLLLLL  
  
;E 
  
  
 
 

 
 
 
s0   C1 1
D;D		DD, ,
E	6EE	PackageSourcecollectionsc                     | sg S t          | t                    }| D ]=}|g k    rg }n|t          |           d         }||k    rt          | d|           >|S )a/  Unify the package sources from multiple lock specs.

    To be able to merge the lock specs, the package sources must be compatible between
    them. This means that between any two lock specs, the package sources must be
    identical or one must be an extension of the other.

    This allows us to use a superset of all of the package source lists in the
    aggregated lock spec.

    The following is allowed:

    > unify_package_sources([[channel_two, channel_one], [channel_one]])
    [channel_two, channel_one]

    Whilst the following will fail:

    > unify_package_sources([[channel_two, channel_one], [channel_three, channel_one]])

    In the failing example, it is not possible to predictably decide which channel
    to search first, `channel_two` or `channel_three`, so we error in this case.
    )r7   Nz( is not an ordered subset at the end of )maxlenr,   )r;   result
collectiontruncated_results       r   r2   r2   I   s    0  	#&&&F!  
!%s:&6&8&89)))OOvOO   * Mr   )logging	itertoolsr   typingr   r   r   r   conda_lock.commonr   conda_lock.errorsr	   conda_lock.models.channelr
   conda_lock.models.lock_specr   r    conda_lock.models.pip_repositoryr   	getLogger__name__loggerr   r9   r:   r2   r   r   r   <module>rM      sC          - - - - - - - - - - - - + + + + + + 5 5 5 5 5 5 - - - - - - E E E E E E E E : : : : : : 
	8	$	$3&'3Cy3 3 3 3 3l -@@$d=)*$	-$ $ $ $ $ $r   