
    .Ph)                         d dl Z d dlZd dlZd dlZd dlZd dlZd dlmZ d dlm	Z	m
Z
mZmZmZmZmZmZ e	r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 d dlmZ d d	lmZ  ej        e           Z! G d
 de          Z" edg d          Z# G d de          Z$ G d de          Z% G d de%          Z& G d dej'                  Z( G d de          Z) G d de          Z* G d de          Z+ G d de          Z, G d de          Z-dS )     N)
namedtuple)TYPE_CHECKINGAbstractSetAnyClassVarDictListOptionalUnion)_Hash)FieldValidationInfofield_validator)Literal)ordered_unionrelative_path)StrictModel)Channelc                   0    e Zd ZU ed         ed<   eed<   dS )DependencySourceurltypeN)__name__
__module____qualname__r   __annotations__str     ]/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/conda_lock/lockfile/v1/models.pyr   r   #   s)         
%.	HHHHHr   r   LockKey)managernameplatformc                   D    e Zd ZU dZee         ed<   dZee         ed<   dS )	HashModelNmd5sha256)r   r   r   r'   r
   r   r   r(   r   r   r    r&   r&   +   s:         C# FHSM     r   r&   c                       e Zd ZU eed<   eed<   ed         ed<   eed<   i Zeeef         ed<   eed<   eed<   d	Z	e
e         ed
<   d	Ze
e         ed<   defdZ ed          edededefd                        Zd	S )BaseLockedDependencyr#   version)condapipr"   r$   dependenciesr   hashNsourcebuildreturnc                 B    t          | j        | j        | j                  S N)r!   r"   r#   r$   selfs    r    keyzBaseLockedDependency.key;   s    t|TY>>>r   vinfoc                 T    |j         d         dk    r|j        t          d          |S )Nr"   r,   z!conda package hashes must use MD5)datar'   
ValueError)clsr8   r9   s      r    validate_hashz"BaseLockedDependency.validate_hash>   s0     Ii G++!%-@AAAr   )r   r   r   r   r   r   r.   r   r&   r0   r
   r   r1   r!   r7   r   classmethodr   r>   r   r   r    r*   r*   0   s         
IIILLL^$$$$MMM#%L$sCx.%%%	HHH
OOO)-FH%&---E8C=?W ? ? ? ? _Vi ~ )    [   r   r*   c                   (    e Zd ZU dZeed<   eed<   dS )LockedDependencymaincategoryoptionalN)r   r   r   rC   r   r   boolr   r   r    rA   rA   F   s)         HcNNNNNr   rA   c                   &    e Zd ZdZdZdZdZdZdZdS )MetadataOption	timestampgit_shagit_user_namegit_user_email	input_md5	input_shaN)	r   r   r   	TimeStampGitShaGitUserNameGitUserEmailInputMd5InputShar   r   r    rG   rG   K   s,        IF!K#LHHHHr   rG   c                   P    e Zd ZU dZ edd          Zeed<   ed	d            Z	dS )
TimeMetaz9Stores information about when the lockfile was generated..z%Time stamp of lock-file creation timedescription
created_atr2   c                      | t           j                             t           j        j                                      d                    S )Nz%Y-%m-%dT%H:%M:%SZ)rX   )datetimenowtimezoneutcstrftime)r=   s    r    createzTimeMeta.createY   sH    s(,,X->-BCCLL$ 
 
 
 	
r   N)r2   rU   )
r   r   r   __doc__r   rX   r   r   r?   r_   r   r   r    rU   rU   T   sZ         CCeC-TUUUJUUU
 
 
 [
 
 
r   rU   c                       e Zd ZU dZ edd          Zee         ed<    edd          Z	ee         ed<    edd          Z
ee         ed	<   ed
ee         deej                 ddfd            ZdS )GitMetaz
    Stores information about the git repo the lockfile is being generated in (if applicable) and
    the git user generating the file.
    Nz$Git user.name field of global configdefaultrW   rJ   z%Git user.email field of global configrK   z`sha256 hash of the most recent git commit that modified one of the input files for this lockfilerI   metadata_choices	src_filesr2   zGitMeta | Nonec                 L   	 dd l }dd l}n# t          $ r Y d S w xY wd }d }d }	 |                    d          }t          j        |v rd }|D ]}	t          t          j        |j	                  |	          }
t          |                    |
d                    d         }|                    |
          r0t                              d           |j        j        j         d} n|||j        k     r|j        }|j        }t          j        |v r)|                                                    d	d
d           }t          j        |v r)|                                                    d	dd           }n# |j        j        $ r Y nw xY wt3          |||g          r | |||          S d S )Nr   T)search_parent_directories   )paths	max_count)pathzMOne of the inputs to conda-lock is dirty, using commit hash of head + "dirty"z-dirtyuserr#   email)rI   rJ   rK   )gitgit.excImportErrorReporG   rO   r   pathlibPathworking_tree_dirlistiter_commitsis_dirtyloggerwarningheadobjecthexshacommitted_datetimerP   config_reader	get_valuerQ   excInvalidGitRepositoryErrorany)r=   re   rf   ro   rI   rJ   rK   repomost_recent_datetimesrc_filerelative_src_file_pathcommits               r    r_   zGitMeta.createv   s#   	JJJNNNN 	 	 	44	 "&'+(,	88d8;;D$(888DH$ ) 4 4H-:T%:;; . .* "))0FRS)TT F }}*@}AA 4'   &*Y%5%<"D"D"D 183f6OOO393L0&,mG)-=== $ 2 2 4 4 > >vvt T T*.>>>!%!3!3!5!5!?!?QU!V!Vw0 	 	 	D	 788 	3+-    4s    
EE/ /F F)r   r   r   r`   r   rJ   r
   r   r   rK   rI   r?   r   rG   r	   rs   rt   r_   r   r   r    rb   rb   b   s         
 $)5"H$ $ $M8C=    %*E"I% % %NHSM    #U  GXc]    7%n57 %7 
	7 7 7 [7 7 7r   rb   c                   0   e Zd ZU dZ edd          Zee         ed<    edd          Z	ee         ed<   e
dee         dej        d	d fd
            Ze
dej        d	efd            Ze
dej        d	efd            Zedej        ddd	efd            ZdS )	InputMetazDStores information about an input provided to generate the lockfile..zmd5 checksum for an input filerV   r'   r(   re   r   r2   c                     t           j        |v r|                     |          }nd }t           j        |v r|                     |          }nd } | ||          S )N)r   )r'   r(   )rG   rS   get_input_sha256rR   get_input_md5)r=   re   r   r(   r'   s        r    r_   zInputMeta.create   s{     "&666))8)<<FFF"&666##X#66CCCs
 
 
 	
r   c                 V    t          j                    }|                     ||          S N)r   hasher)hashlibr'   	hash_filer=   r   r   s      r    r   zInputMeta.get_input_md5   s#    }}hv}>>>r   c                 V    t          j                    }|                     ||          S r   )r   r(   r   r   s      r    r   zInputMeta.get_input_sha256   s%    !!}}hv}>>>r   r   r   c                     |                      d          5 }|                    |                                                    d                     d d d            n# 1 swxY w Y   |                                S )Nrzutf-8)openupdatereadencode	hexdigest)r   r   infiles      r    r   zInputMeta.hash_file   s    ]]3 	96MM&++--..w77888	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9!!!s   ;AA!$A!N)r   r   r   r`   r   r'   r
   r   r   r(   r?   r   rG   rs   rt   r_   r   r   staticmethodr   r   r   r    r   r      s8        NNs0PQQQC#QQQ!E#3STTTFHSMTTT
*>:
FMl
	
 
 
 [
  ?W\ ?c ? ? ? [? ? ? ? ? ? [? "GL "' "c " " " \" " "r   r   c                   ,   e Zd ZU  edd          Zeeef         ed<    eddd          Ze	e
         ed<    edd	          Ze	e         ed
<    edd          Ze	e         ed<    edd          Zee         ed<    edd          Zee         ed<    edd          Zeeeef                  ed<    edd          Zeeeef                  ed<   ddZ edd          ede	eee
f                  de	e
         fd                        ZdS )LockMeta.z-Hash of dependencies for each target platformrV   content_hashz%Channels used to resolve dependenciesT)rW   validate_defaultchannelszTarget platforms	platformszGpaths to source files, relative to the parent directory of the lockfilesourcesNz3Metadata dealing with the time lockfile was createdrc   time_metadataz[Metadata dealing with the git repo the lockfile was created in and the user that created itgit_metadatazAMetadata dealing with the input files used to create the lockfileinputs_metadataz@Custom metadata provided by the user to be added to the lockfilecustom_metadataotherr2   c           
         || S t          |t                    st          | j        |j        }n0|j        | j        }n!| j        }|                    |j                   | j        |j        }n{|j        | j        }nl| j        }|j        D ]C}||v r=t                              d| dd||          dz   d|j        |          dz              D|                    |j                   t          i | j        |j        | j	        t          t          | j                                      |j                            t          | j        |j        g          |j        |j        ||          S )zmerge other into selfNzCustom metadata key z+ provided twice, overwriting original value(z) with new value ))r   r   r   r   r   r   r   r   )
isinstancer   	TypeErrorr   r   r   ry   rz   r   r   sortedsetr   unionr   r   r   r   )r6   r   new_inputs_metadatanew_custom_metadatar7   s        r    __or__zLockMeta.__or__   s   =KE8,, 	O'"'"7"*"&"6"&"6&&u'<==='"'"7"*"&"6"&"6,  ---NN_s___I1#6IIIJ;e3C8;;;<  
  &&u'<===DD-D1CD]S0066uGGHH!4<"?@@-+//	
 	
 	
 		
r   before)moder8   c                     g }|D ]T}t          |t                    r(|                    t          j        |                     ?|                    |           U|S r4   )r   r   appendr   from_string)r=   r8   reses       r    ensure_channelszLockMeta.ensure_channels  s`       	 	A!S!! 

7.q112222

1
r   )r   r   r2   r   )r   r   r   r   r   r   r   r   r   r	   r   r   r   r   r
   rU   r   rb   r   r   r   r   r   r?   r   r   r   r   r    r   r      s(        #(5H$ $ $L$sCx.    $e@SW  Hd7m    !52DEEEItCyEEE]  GT#Y    )."W) ) )M8H%    ',ei' ' 'L(7#    7<eW7 7 7OXd3	>23    16V1 1 1OXd38n-   
&
 &
 &
 &
P _Zh///U3<%8 9 d7m    [ 0/  r   r   c                   f    e Zd ZU dZee         ed<   ee         ed<   e	ed<   de
eef         fdZdS )Lockfileri   r+   packagemetadatar2   c                     t           j        t          j        | j                            ddd                    d | j        D             dS )zCConvert the lockfile to a dictionary that can be written to a file.Tby_aliasexclude_unsetexclude_nonec                 >    g | ]}|                     d d d           S )Tr   )
model_dump).0r   s     r    
<listcomp>z,Lockfile.dict_for_output.<locals>.<listcomp>:  s>        ""DSW"XX  r   )r+   r   r   )r   r+   jsonloadsr   model_dump_jsonr   r5   s    r    dict_for_outputzLockfile.dict_for_output1  sg      '
--!D .   
 #|  
 
 	
r   N)r   r   r   r+   r   intr   r	   rA   r   r   r   r   r   r   r   r    r   r   +  sk         GXc]"####
c3h 
 
 
 
 
 
r   r   ).rZ   enumr   r   loggingrs   collectionsr   typingr   r   r   r   r   r	   r
   r   r   pydanticr   r   r   typing_extensionsr   conda_lock.commonr   r   conda_lock.modelsr   conda_lock.models.channelr   	getLoggerr   ry   r   r!   r&   r*   rA   EnumrG   rU   rb   r   r   r   r   r   r    <module>r      s+         " " " " " "	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	   ; ; ; ; ; ; ; ; ; ; % % % % % % : : : : : : : : ) ) ) ) ) ) - - - - - - 
	8	$	$    {   
 *Y ? ? ?
@
@! ! ! ! ! ! ! !
    ;   ,    +   
    TY   
 
 
 
 
{ 
 
 
L L L L Lk L L L^%" %" %" %" %" %" %" %"PO O O O O{ O O Od
 
 
 
 
{ 
 
 
 
 
r   