
    Ng~                        d dl Z d dlZd dl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mZmZmZmZmZ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mZm Z m!Z!m"Z"m#Z#m$Z$m%Z% dd
l&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/ ddl0m1Z1 ddl2m3Z3 ddl4m5Z5 ee6e7e8ee9e:f         Z;e G d d                      Z<e G d de<                      Z= G d de          Z> G d de>          Z? G d de?          Z@ G d de          ZA G d de?          ZBdS )    N)ABCabstractmethod)defaultdict)	dataclassfield)Enum)	AnyDictIteratorListOptionalSetTupleTypeUnion)ParserRuleContext   )_DEFAULT_MARKER_NoneType	ValueKind
_get_value_is_interpolation_is_missing_value_is_specialformat_and_raiseget_value_kindis_union_annotationis_valid_value_annotation	split_keytype_str)	ConfigKeyErrorConfigTypeErrorInterpolationKeyErrorInterpolationResolutionError InterpolationToMissingValueErrorInterpolationValidationErrorMissingMandatoryValueUnsupportedInterpolationTypeValidationError)OmegaConfGrammarParser)parse)GrammarVisitorc                      e Zd ZU eee         ef         ed<   eee         ef         ed<   eed<   eed<   dZe	e
eef                  ed<   dZeed<    ed	 
          Ze
eef         ed<   ddZedeee         ef         fd            ZdS )Metadataref_typeobject_typeoptionalkeyNflagsF
flags_rootc                  *    t          t                    S N)r   dict     J/var/www/html/ai-engine/env/lib/python3.11/site-packages/omegaconf/base.py<lambda>zMetadata.<lambda>A   s    ;tCTCT r9   )default_factoryresolver_cachereturnc                 &    | j         	i | _         d S d S r6   )r3   selfs    r:   __post_init__zMetadata.__post_init__C   s    :DJJJ r9   c                 B    | j         rt          | j                 S | j        S )z<Compute `type_hint` from `self.optional` and `self.ref_type`)r1   r   r/   r@   s    r:   	type_hintzMetadata.type_hintG   s#     = 	!DM**= r9   r>   N)__name__
__module____qualname__r   r   r	   __annotations__boolr3   r   r
   strr4   r   r=   rB   propertyrD   r8   r9   r:   r.   r.   ,   s          DIsN####tCy#~&&&&NNN	HHH (,E8DdO$+++ J%*U;T;T%U%U%UNDcNUUU    !5cC0 ! ! ! X! ! !r9   r.   c                   4    e Zd ZU dZeed<   dZeed<   ddZdS )ContainerMetadataNkey_typeelement_typer>   c                 $   | j         t          | _         | j        t          u st          | j        t                    sJ | j        ;t          | j                  s't          dt          | j        d           d          | j	        	i | _	        d S d S )NzUnsupported value type: 'T)include_module_name')
r/   r	   rO   
isinstancetyperP   r   r)   r    r3   r@   s    r:   rB   zContainerMetadata.__post_init__X   s    = DM}##z$-'F'F###(,T->?? %h9J`d0e0e0ehhh   :DJJJ r9   rE   )rF   rG   rH   rO   r	   rI   rP   rB   r8   r9   r:   rN   rN   S   sJ         HcL#     r9   rN   c                      e Zd ZU eed<   ed         ed<   eeeee         f                  ed<   ded         defdZ	deee
f         fd	Zd
eee
f         ddfdZded         ddfdZd7dZded         fdZded         fdZdeee         ef         deeee                  ee         f         dd fdZdedee         fdZdedee         fdZdedee         fdZ	 	 d8de
de
dedee         de
ddfdZedeeeef                  defd            Zd9d Z	 	 d:d"ed#eee                  ded          fd$Z	 d;d"ed#eee                  ded          fd%Z d<d&Z!defd'Z"defd(Z#ed)e
defd*            Z$ed)e
defd+            Z%edefd,            Z&ede
fd-            Z'ed;de
deeeef                  ddfd.            Z(edefd/            Z)edefd0            Z*de
fd1Z+de
ddfd2Z,defd3Z-d4eddfd5Z.defd6Z/dS )=Node	_metadataBox_parent_flags_cacheparentmetadatac                 B    || j         d<   || j         d<   d | j         d<   d S )NrX   rZ   r[   __dict__)rA   r\   r]   s      r:   __init__zNode.__init__l   s,    %-k"#)i (,n%%%r9   r>   c                 >    t          j         | j                  }|d= |S Nr[   )copyr`   rA   
state_dicts     r:   __getstate__zNode.__getstate__q   s!    Yt}--
~&r9   rf   Nc                 N    | j                             |           d | j         d<   d S rc   )r`   updatere   s     r:   __setstate__zNode.__setstate__w   s*    Z((((,n%%%r9   c                 t    |t          |t                    sJ || j        d<   |                                  d S NrZ   )rT   rY   r`   _invalidate_flags_cacherA   r\   s     r:   _set_parentzNode._set_parent{   s=    ~FC!8!8~~~#)i $$&&&&&r9   c                     d | j         d<   d S rc   r_   r@   s    r:   rm   zNode._invalidate_flags_cache   s    (,n%%%r9   c                 R    | j         d         }|t          |t                    sJ |S rl   )r`   rT   rY   rn   s     r:   _get_parentzNode._get_parent   s*    y)~FC!8!8~~~r9   	Containerc                     | j         d         }|t          |t                    sJ t          |t                    r(|j         d         }|t          |t                    sJ |S |t          |t                    sJ |S )z{
        Like _get_parent, but returns the grandparent
        in the case where `self` is wrapped by a UnionNode.
        rZ   )r`   rT   rY   	UnionNoders   )rA   r\   grandparents      r:   _get_parent_containerzNode._get_parent_container   s    
 y)~FC!8!8~~~fi(( 	 /)4K&*[)*L*L&&&>Z	%B%B>>>Mr9   r3   valuesc                    t          |t                    r|g}|t          |t                    r|g}t          |          dk    rt          |          |z  }t          |          t          |          k    rt	          d          t          |          D ]V\  }}||         }|*| j        j        J || j        j        v r| j        j        |= 9| j        j        J || j        j        |<   W|                                  | S )Nr   z3Inconsistent lengths of input flag names and values)	rT   rK   rJ   len
ValueError	enumeraterX   r3   rm   )rA   r3   rx   idxflagvalues         r:   	_set_flagzNode._set_flag   s   
 eS!! 	GE>Z55>XFv;;!ZZ&(Fu::V$$RSSS"5)) 	3 	3IC3KE}~+7774>///,T2~+777-2$T**$$&&&r9   r~   c                 \    | j         j        J | j         j                            |          S )zc
        :param flag: flag to inspect
        :return: the state of the flag on this node.
        )rX   r3   get)rA   r~   s     r:   _get_node_flagzNode._get_node_flag   s.    
 ~#///~#''---r9   c                     | j         d         }|i x}| j         d<   |                    |t                    }|t          u r|                     |          }|||<   |t	          |t
                    sJ |S rc   )r`   r   r   _get_flag_no_cacherT   rJ   )rA   r~   cacherets       r:   	_get_flagzNode._get_flag   s|    n-=466EDM.1ii.//"""))$//CE$K{jd33{{{
r9   c                     | j         j        }|J ||v r||         ||         S |                                 rdS |                                 }|dS |                    |          S )z
        Returns True if this config node flag is set
        A flag is set if node.set_flag(True) was called
        or one if it's parents is flag is set
        :return:
        N)rX   r3   _is_flags_rootrr   r   )rA   r~   r3   r\   s       r:   r   zNode._get_flag_no_cache   s     $   5==U4[4;   	4!!##>4 ##D)))r9   r2   r   causemsgtype_overridec                 R    t          | |||t          |          n|||           J )N)noder2   r   r   r   r   )r   rK   )rA   r2   r   r   r   r   s         r:   _format_and_raisezNode._format_and_raise   sB     	!kE


s'	
 	
 	
 	
 	r9   c                     d S r6   r8   rA   r2   s     r:   _get_full_keyzNode._get_full_key       r9   c                 :    |                      d          }|J |S )NT)throw_on_resolution_failure_dereference_node_impl)rA   r   s     r:   _dereference_nodezNode._dereference_node   s)    **t*LLr9   Fr   memoc                 0    |                      ||          S )Nr   r   r   )rA   r   r   s      r:   _maybe_dereference_nodezNode._maybe_dereference_node   s'    
 **(C + 
 
 	
r9   c           
         |                                  s| S |                                 }||rt          d          d S |J |                                 }|                    ||| t          t          |                     ||          S )Nz8Cannot resolve interpolation for a node without a parent)r\   r2   r   
parse_treer   r   )r   rw   r$   _key&_resolve_interpolation_from_parse_treer+   r   )rA   r   r   r\   r2   s        r:   r   zNode._dereference_node_impl  s    
 %%'' 	K++-->* 2N   4!!!iikk<<Z--..(C = 
 
 	
r9   c                 r   |                                  }|t          | t                    sJ | S |t          |t                    sJ |                                 A|                                 }|t          |t                    sJ |                                 A|t          |t                    sJ |S r6   )rr   rT   rs   rY   )rA   roots     r:   	_get_rootzNode._get_root  s    "..00<dI.....KJtS$9$9  ,##%%D#
4(=(=###   , JtY$?$?r9   c                      t          |           S )zY
        Check if the node's value is `???` (does *not* resolve interpolations).
        )r   r@   s    r:   _is_missingzNode._is_missing*  s     !&&&r9   c                 .    |                                  du S )zZ
        Check if the node's value is `None` (does *not* resolve interpolations).
        N)_valuer@   s    r:   _is_nonezNode._is_none0  s     {{}}$$r9   otherc                     d S r6   r8   rA   r   s     r:   __eq__zNode.__eq__6  r   r9   c                     d S r6   r8   r   s     r:   __ne__zNode.__ne__:  r   r9   c                     d S r6   r8   r@   s    r:   __hash__zNode.__hash__>  r   r9   c                     d S r6   r8   r@   s    r:   r   zNode._valueB  r   r9   c                     d S r6   r8   )rA   r   r3   s      r:   
_set_valuezNode._set_valueF  r   r9   c                     d S r6   r8   r@   s    r:   _is_optionalzNode._is_optionalJ  r   r9   c                     d S r6   r8   r@   s    r:   r   zNode._is_interpolationN  r   r9   c                     | j         j        S r6   rX   r2   r@   s    r:   r   z	Node._keyR  s    ~!!r9   c                     || j         _        d S r6   r   r   s     r:   _set_keyzNode._set_keyU  s     r9   c                     | j         j        S r6   )rX   r4   r@   s    r:   r   zNode._is_flags_rootX  s    ~((r9   r4   c                 j    | j         j        |k    r"|| j         _        |                                  d S d S r6   )rX   r4   rm   )rA   r4   s     r:   _set_flags_rootzNode._set_flags_root[  s<    >$
22(2DN%((***** 32r9   c                 (    | j         j        t          uS r6   )rX   r/   r	   r@   s    r:   _has_ref_typezNode._has_ref_type`  s    ~&c11r9   rE   NN)r>   rW   )FNr6   )r>   rs   )0rF   rG   rH   r.   rI   r   r
   rK   rJ   ra   r	   rg   rj   ro   rm   rr   rw   r   r   r   r   r   r   	Exceptionr   r   DictKeyTypeintr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r8   r9   r:   rW   rW   f   se        e_4Xd^ 345555-x -( - - - -
d38n    -tCH~ -$ - - - -'(5/ 'd ' ' ' '
- - - -Xe_    
x'<     T#Y^$ d8D>*HTN:; 
	   :.3 .8D> . . . .
c 
htn 
 
 
 
*s *x~ * * * *6 "!   	
 c]  
   $ %S0@*A!B s    ^    -2#'
 
%)
 s3x 
 
&		
 
 
 
 $(
 
%)
 s3x 
 
&		
 
 
 
4
 
 
 
'T ' ' ' '%$ % % % % C D    ^ C D    ^ #    ^     ^   HT#t)_,E QU    ^ d    ^ 4    ^"c " " " "!C !D ! ! ! !) ) ) ) )+$ +4 + + + +
2t 2 2 2 2 2 2r9   rW   c                   X     e Zd ZU dZeed<   ded          def fdZdefdZ	d
d	Z
 xZS )rY   z
    Base class for nodes that can contain other nodes.
    Concrete subclasses include DictConfig, ListConfig, and UnionNode.
    _contentr\   r]   c                 b    t                                          ||           d | j        d<   d S )Nr\   r]   r   )superra   r`   )rA   r\   r]   	__class__s      r:   ra   zBox.__init__l  s2    :::$(j!!!r9   r>   c                 *    t          j        |           S r6   )rd   deepcopyr@   s    r:   __copy__zBox.__copy__p  s    }T"""r9   Nc                 V   ddl m} ddlm} t	          | |          r| j        d         }t	          |t                    re| j        d                                         D ]G\  }}||                    |            t	          |t                    r|
                                 Fd S d S t	          | |          rv| j        d         }t	          |t                    rP| j        d         D ]D}||                    |            t	          |t                    r|
                                 Cd S d S t	          | t                    rb| j        d         }t	          |t                    rB|                    |            t	          |t                    r|
                                 d S d S d S d S )Nr   
DictConfig
ListConfigr   )
dictconfigr   
listconfigr   rT   r`   r7   itemsro   rY   
_re_parentlistru   rW   )rA   r   r   contentr   r   items          r:   r   zBox._re_parentt  s   ************ dJ'' 	)mJ/G'4(( +#'=#<#B#B#D#D + +KD%())$///!%-- +((***+ ++ +
 j)) 	)mJ/G'4(( * M*5 * *D'((...!$,, *)))* ** *
 i(( 	)mJ/G'4(( )##D)))gs++ ) &&(((((	) 	)) )) )r9   rE   )rF   rG   rH   __doc__r	   rI   r   r.   ra   r   r   __classcell__r   s   @r:   rY   rY   d  s          
 MMM)x )( ) ) ) ) ) )## # # # #) ) ) ) ) ) ) )r9   rY   c                      e Zd ZU dZeed<   e	 	 	 	 d,dedededed	ed
e	e
e         ee
e                  f         fd            Ze	 	 	 	 d,dedededed	ed
e	e
e         ee
e                  f         fd            Zeded
dfd            Zededed
dfd            Zed
ee         fd            Zeded
efd            Zded
ed ef         fdZ	 d-dededede
ee                  d
ee
d          e
e         e
e         f         f
dZde
d          dddedej        dede
ee                  d
e
d         fdZde
d          dddededed
e
d         fdZded ed
dfd!Zd"ede
ee                  d
dfd#Zdeded$ed%eed&f         d'eed&f         d
efd(Z 	 d-de
d          dededede
ee                  d
e
e         fd)Z!	 	 d.de"dede
ee                  de
e         d
ef
d*Z#d/d+Z$dS )0rs   z%
    Container tagging interface
    rX   TFr2   validate_accessvalidate_keythrow_on_missing_valuethrow_on_missing_keyr>   c                     d S r6   r8   rA   r2   r   r   r   r   s         r:   
_get_childzContainer._get_child  	     	r9   c                     d S r6   r8   r   s         r:   	_get_nodezContainer._get_node  r   r9   Nc                     d S r6   r8   r   s     r:   __delitem__zContainer.__delitem__  r   r9   r   c                     d S r6   r8   )rA   r2   r   s      r:   __setitem__zContainer.__setitem__  r   r9   c                     d S r6   r8   r@   s    r:   __iter__zContainer.__iter__  r   r9   key_or_indexc                     d S r6   r8   )rA   r   s     r:   __getitem__zContainer.__getitem__  r   r9   c                 4   |}|                     d          s|                                 |fS | }|                     d          sJ 	 |J |dd          }|                     d          sn*|                                }|t          d| d          N||fS )N.Tr   zError resolving key 'rS   )
startswithr   rw   r!   )rA   r2   origr   s       r:   _resolve_key_and_rootzContainer._resolve_key_and_root  s    ~~c"" 	>>##S(((,D>>#&&&&&J'''!""g~~c** 1133<()H)H)H)HIIIJ 9r9   throw_on_missingr   r   c           
      >   ddl m} |dk    r| d| fS t          |          }| }t          t	          |          dz
            D ]}| n||         }	 |||	||          \  }
}t          |
t                    r|
                    ||          }
|
Yt          |
t                    sDd	                    |d|dz                      }||dz            }t          d	| d
| d| d          |
}|dS |d         } |||||          \  }}|||dfS |7t          |          }||v rt          d          |                    |           	 |                    |||||          }||                    |           n# ||                    |           w w xY w|||fS )zA
        Select a value using dot separated key sequence
        r   )_select_one N)cr2   r   throw_on_type_errorr   r   r   zError trying to access z: node `z.` is not a container and thus cannot contain ``)NNNz Recursive interpolation detected)r\   r2   r   r   r   )	omegaconfr   r   rangerz   rT   rW   r   rs   joinr"   idr$   add_maybe_resolve_interpolationremove)rA   r2   r   r   r   r   splitr   ikr   _
parent_key	child_keylast_keyr   vids                    r:   _select_implzContainer._select_impl  s_    	+*****"99T>!#$(s5zzA~&& 	 	A|aA [!1$?	  FC #t$$ 110K 2  
 z#y'A'A XXeAAI&677
!!a%L	%Pc P P: P PCLP P P   DD<##9;- ;	
 
 
q =4''U))Cd{{23UVVVHHSMMM	!55,G 6  E C    C       Xu$$s   E= =Fr\   rW   r   c                     	 |                      ||||          }n# t          $ r |r Y dS w xY w|                     |||||          S )a  
        Resolve an interpolation.

        This happens in two steps:
            1. The parse tree is visited, which outputs either a `Node` (e.g.,
               for node interpolations "${foo}"), a string (e.g., for string
               interpolations "hello ${name}", or any other arbitrary value
               (e.g., or custom interpolations "${foo:bar}").
            2. This output is potentially validated and converted when the node
               being resolved (`value`) is typed.

        If an error occurs in one of the above steps, an `InterpolationResolutionError`
        (or a subclass of it) is raised, *unless* `throw_on_resolution_failure` is set
        to `False` (in which case the return value is `None`).

        :param parent: Parent of the node being resolved.
        :param value: Node being resolved.
        :param key: The associated key in the parent.
        :param parse_tree: The parse tree as obtained from `grammar_parser.parse()`.
        :param throw_on_resolution_failure: If `False`, then exceptions raised during
            the resolution of the interpolation are silenced, and instead `None` is
            returned.

        :return: A `Node` that contains the interpolation result. This may be an existing
            node in the config (in the case of a node interpolation "${foo}"), or a new
            node that is created to wrap the interpolated value. It is `None` if and only if
            `throw_on_resolution_failure` is `False` and an error occurs during resolution.
        )r   r   r2   r   N)r\   r   r2   resolvedr   )resolve_parse_treer$   *_validate_and_convert_interpolation_result)rA   r\   r   r2   r   r   r   r  s           r:   r   z0Container._resolve_interpolation_from_parse_tree!  s    L	..%Es /  HH , 	 	 	* 44	
 >>(C ? 
 
 	
s    --r  c           
         ddl m}m}m} t	          |t
                     }	t	          ||          rt	          ||          st          |          }
	 |                    |
          }n?# t          $ r2}|r%| 	                    ||
|d| d| t                     Y d }~d S d }~ww xY wt          |          t          |
          k    rd}	|}|	r ||||          S t	          |t
                    sJ |S )Nr   )AnyNodeInterpolationResultNode	ValueNodez#While dereferencing interpolation 'z': )r2   r   r   r   r   T)r   r2   r\   )nodesr  r  r  rT   rW   r   validate_and_convertr)   r   r&   rU   )rA   r\   r   r2   r  r   r  r  r  	must_wrap	res_value
conv_valuees                r:   r  z4Container._validate_and_convert_interpolation_resultX  sU    	GFFFFFFFFF #8T222	 eY'' 	&
5'0J0J 	&"8,,I"77	BB

" 	 	 	. **'O%OOAOO&B +    ttttt	 J4	??22 	% 	**s6RRRRh-----Os   A' '
B#1'BB#r   targetc                 d    |}|+||u rt          d          |                                }|)d S d S )Nz%Interpolation to parent node detected)r$   rr   )rA   r   r  r\   s       r:   %_validate_not_dereferencing_to_parentz/Container._validate_not_dereferencing_to_parent  sT    !% 2;   ''))F      r9   	inter_keyc                    	 |                      |          \  }}nN# t          $ rA}t          d|                               t	          j                    d                   d}~ww xY w	 |                    |dd|          \  }}}nN# t          $ rA}t          d|                               t	          j                    d                   d}~ww xY w||t          d| d          | 	                    | |	           |S )
z0A node interpolation is of the form `${foo.bar}`z.ConfigKeyError while resolving interpolation:    NT)r   r   r   z5MissingMandatoryValue while resolving interpolation: zInterpolation key 'z' not found)r   r  )
r   r!   r#   with_tracebacksysexc_infor  r'   r%   r  )rA   r  r   	root_nodeexcr\   r  r   s           r:   _resolve_node_interpolationz%Container._resolve_node_interpolation  sB   	0#'#=#=i#H#H Iyy 	0 	0 	0'FFF nS\^^A.//0	0

	0&/&<&<!%,0	 '= ' '#FHee % 	0 	0 	02MMM nS\^^A.//0	0
 >U]'(Ti(T(T(TUUU66D6OOOLs,    
A&<A!!A&*B 
C<CC
inter_type
inter_args.inter_args_strc                     ddl m} |                    |          }|#|                                 } ||| |||          S t	          d|           )Nr   )	OmegaConfzUnsupported interpolation type )r   r,  _get_resolverr   r(   )	rA   r2   r   r(  r)  r*  r,  resolverr%  s	            r:   _evaluate_custom_resolverz#Container._evaluate_custom_resolver  s     	('''''**:66((I8   />*>>  r9   c           	          t          |          }|t          j        k    r|S t          t	          |                    }|                     |||||||nt                                S )N)r\   r   r2   r   r   r   )r   r   INTERPOLATIONr+   r   r   set)rA   r\   r2   r   r   r   
value_kindr   s           r:   r  z&Container._maybe_resolve_interpolation  su     $E**
000L:e,,--
::!(C)suu ; 
 
 	
r9   c                     dt           dt          t          t                            dt          d         f fd}dt           dt          t
          df         d	t          t           df         dt
          f fd
}t          |||          }	 |                    |          S # t          $ r  t          $ rU}t          t          |          j         d|                               t          j                    d                   d}~ww xY w)z
        Resolve a given parse tree into its value.

        We make no assumption here on the type of the tree's root, so that the
        return value may be of any type.
        r  r   r>   rW   c                 2                         | |          S )N)r  r   )r'  )r  r   rA   s     r:   node_interpolation_callbackzAContainer.resolve_parse_tree.<locals>.node_interpolation_callback  s     33id3SSSr9   nameargs.args_strc                 8                         | ||          S )N)r2   r   r(  r)  r*  )r/  )r7  r8  r9  r2   r   rA   s      r:   resolver_interpolation_callbackzEContainer.resolve_parse_tree.<locals>.resolver_interpolation_callback  s1     11' 2   r9   )r6  r;  r   z' raised while resolving interpolation: r!  N)rK   r   r   r   r   r	   r,   visitr$   r   rU   rF   r"  r#  r$  )	rA   r   r   r   r2   r6  r;  visitorr&  s	   ` ` `    r:   r  zContainer.resolve_parse_tree  sX   	T	T"*3s8"4	Tf	T 	T 	T 	T 	T 	T
				"38_		8=c3h				 		 		 		 		 		 		 		 !(C,K
 
 

	0==,,,+ 	 	 	 	0 	0 	0.99%SScSS nS\^^A.//0	0s   B! !D
5ADD
c                    ddl m} ddlm} | j        d         d | j        d<   t          | |          r\| j        d         }t          |t                    r6| j        d                                         D ]}|                                 d S d S t          | |          rH| j        d         }t          |t                    r(| j        d         D ]}|                                 d S d S d S d S )Nr   r   r   r[   r   )
r   r   r   r   r`   rT   r7   rx   rm   r   )rA   r   r   r   r   r   s         r:   rm   z!Container._invalidate_flags_cache  s=   ************ =(4,0DM.)$
++ 	7-
3gt,, 8!%z!:!A!A!C!C 8 85577778 88 8D*-- 7-
3gt,, 7 $j 9 7 7446666 547 77 77 7r9   )TTFFr6   r   rE   )%rF   rG   rH   r   rN   rI   r   r	   rJ   r   r   rW   r   r   r   r   r   r   r   r   rK   r   r   r   r   r  r*   ConfigValueContextr   r  r  r'  r/  r  r   r  rm   r8   r9   r:   rs   rs     s          !    !%!',%*   	
 !% # 
x~tHTN33	4   ^  !%!',%*   	
 !% # 
x~tHTN33	4   ^ s t    ^ s 3 4    ^ (3-    ^      ^ {C7G1H    . $(L% L%L% L% &*	L%
 s3x L% 
x$hsmXd^C	DL% L% L% L%\5
%5
 5
 	5

 +=5
 &*5
 s3x 5
 
&	5
 5
 5
 5
n)%) ) 	)
 ) &*) 
&	) ) ) )V*$ * *QU * * * *$,SX$6	   :  	
 #s(O c3h 
   > $(
 
%
 
 	

 &*
 s3x 
 
$
 
 
 
4 $(!+0 +0%+0 +0 s3x 	+0
 c]+0 
+0 +0 +0 +0Z7 7 7 7 7 7r9   rs   c                       e Zd ZdZdZdZdS )SCModer   r!     N)rF   rG   rH   DICTDICT_CONFIGINSTANTIATEr8   r9   r:   rA  rA    s        DKKKKr9   rA  c                       e Zd ZU dZee         ed<   eede	f         ed<   	 	 	 dde
de
ded	e
d
ee         ddf fdZd	eeeef                  de	fdZde
defdZde
defdZdefdZdeede	f         fdZdde
deee	ef                  ddfdZ	 dde
deee	ef                  ddfdZdefdZdefdZde	fdZde	fdZdeee
f         dd fdZ xZS )ru   a  
    This class handles Union type hints. The `_content` attribute is either a
    child node that is compatible with the given Union ref_type, or it is a
    special value (None or MISSING or interpolation).

    Much of the logic for e.g. value assignment and type validation is
    delegated to the child node. As such, UnionNode functions as a
    "pass-through" node. User apps and downstream libraries should not need to
    know about UnionNode (assuming they only use OmegaConf's public API).
    rZ   Nr   Tr   r/   is_optionalr2   r\   r>   c                    	 t          |          sd| ddz   }t          |          t          |t          t          f          st          d          t                                          |t          |d ||ddi                     | 	                    |           d S # t          $ r,}t          d ||t          |          |	           Y d }~d S d }~ww xY w)
Nz"UnionNode got unexpected ref_type z. Please file a bugz3 report at https://github.com/omry/omegaconf/issuesz&Parent type is not omegaconf.ContainerconvertF)r/   r0   r1   r2   r3   r   )r   r2   r   r   r   )r   AssertionErrorrT   rs   r   r"   r   ra   r.   r   r   r   rK   )	rA   r   r/   rG  r2   r\   r   exr   s	           r:   ra   zUnionNode.__init__.  s%   	W&x00 *VVVVKL  %S)))fy(&;<< P%&NOOOGG!% $($e,    	 	 	 OOG$$$$$ 	W 	W 	W$CwCGGSUVVVVVVVVVV	Ws   BB# #
C-!CCc                     |                                  }|'| j        j        dS t          | j        j                  S |                    | j        j                  S )Nr   )rr   rX   r2   rK   r   )rA   r2   r\   s      r:   r   zUnionNode._get_full_keyM  sT    !!##>~!)r4>-...''(:;;;r9   r   c                 L   | j         d         }t          |t                    r|                    |          }n@t          |t                    r|                    |          }n|                    |          }t          |t          t          t                    f          sJ |S Nr   )r`   rT   rW   r   rJ   rU   NotImplemented)rA   r   r   r   s       r:   r   zUnionNode.__eq__W  s    -
+gt$$ 	(..''CCt$$ 	(,,w''CC..''C#d>&:&:;<<<<<
r9   c                 R    |                      |          }|t          u rt          S | S r6   )r   rO  )rA   r   xs      r:   r   zUnionNode.__ne__b  s+    KK!!ur9   c                 6    t          | j        d                   S rN  )hashr`   r@   s    r:   r   zUnionNode.__hash__h      DM*-...r9   c                 h    | j         d         }t          |t          t          t          f          sJ |S rN  )r`   rT   rW   r   rK   )rA   r   s     r:   r   zUnionNode._valuek  s0    -
+'D(C#899999r9   r   r3   c                     | j         d         }| j         d         }	 |                     ||           d S # t          $ r}|| j         d<   || j         d<   |d }~ww xY w)Nr   rX   )r`   _set_value_implr   )rA   r   r3   previous_contentprevious_metadatar  s         r:   r   zUnionNode._set_valuep  sy    =4 M+6	  ..... 	 	 	(8DM*%):DM+&G	s   4 
AAAc                 L   ddl m} | j        j        }| j        j        }t          |          }t          |          r`t          |t          t          f          sJ |4| 
                                s t          dt          |           d          || j        d<   d S t          |t                    rt          dt          |                     |j        D ]-}	  |||dd |           | j        d<    d S # t          $ r Y *w xY wt          d	t          |           d          )
Nr   )
_node_wrapz/Value '$VALUE' is incompatible with type hint 'rS   r   z:Cannot assign container '$VALUE' of type '$VALUE_TYPE' to F)r   r/   rG  r2   r\   zEValue '$VALUE' of type '$VALUE_TYPE' is incompatible with type hint ')omegaconf.omegaconfr[  rX   r/   rD   r   r   rT   rK   r   r   r)   r    r`   rs   __args__)rA   r   r3   r[  r/   rD   candidate_ref_types          r:   rW  zUnionNode._set_value_implz  s    	322222>*N,	5!!u 	ec8_55555}((** )`(S\J]J]```   ).DM*%%%y)) 	!bXV_M`M`bb   '/&7  "
0:
#!3$) #1 1 1DM*- EE&   H &r\den\o\orrr  s   C66
DDc                 *    | j         d         j        du S )NrX   T)r`   r1   r@   s    r:   r   zUnionNode._is_optional  s    }[)2d::r9   c                 6    t          | j        d                   S rN  )r   r`   r@   s    r:   r   zUnionNode._is_interpolation  s     z!:;;;r9   c                 6    t          | j        d                   S rN  )rK   r`   r@   s    r:   __str__zUnionNode.__str__  s    4=,---r9   c                 6    t          | j        d                   S rN  )reprr`   r@   s    r:   __repr__zUnionNode.__repr__  rT  r9   r   c                     t                               t          |                     }| j                                        D ]'\  }}|dvrt          j        ||          |j        |<   (| j        d         }t          |t                    rR|j        d         }	 d |j        d<   t          j        ||          }||j        d<   ||j        d<   n# ||j        d<   w xY w|}||j        d<   | j        d         |j        d<   |S )N)r   rZ   )r   r   rZ   )	object__new__rU   r`   r   rd   r   rT   rW   )rA   r   resr2   r   src_content
old_parentcontent_copys           r:   __deepcopy__zUnionNode.__deepcopy__  s   nnT$ZZ((---// 	D 	DJC111$(M%d$C$C$CS!mJ/k4(( 
	'$-i8J=26$Y/#}[tDDD36%i02<$Y//*$Y/<<<< 'L#/Z "&-	":Y
s   *C C)TNNr6   )rF   rG   rH   r   r   rs   rI   r   rW   rK   r	   rJ   rY   ra   r   r   r   r   r   r   r   r
   r   rW  r   r   rb  re  rm  r   r   s   @r:   ru   ru     s        	 	 i    D$O$$$$ ! $W WW W 	W
 W W 
W W W W W W><%S0@*A!B <s < < < <	C 	D 	 	 	 	C D    /# / / / /dD#o.    
  HT#t)_,E QU     >B% %%!)$sDy/!:%	% % % %N;d ; ; ; ;<4 < < < <. . . . ./# / / / /c3h K        r9   ru   )Crd   r#  abcr   r   collectionsr   dataclassesr   r   enumr   typingr	   r
   r   r   r   r   r   r   r   antlr4r   _utilsr   r   r   r   r   r   r   r   r   r   r   r   r    errorsr!   r"   r#   r$   r%   r&   r'   r(   r)   "grammar.gen.OmegaConfGrammarParserr*   grammar_parserr+   grammar_visitorr,   rK   bytesr   floatrJ   r   r.   rN   rW   rY   rs   rA  ru   r8   r9   r:   <module>r{     sw    



 # # # # # # # # # # # # # # ( ( ( ( ( ( ( (       O O O O O O O O O O O O O O O O O O O O O O $ $ $ $ $ $                             
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 G F F F F F ! ! ! ! ! ! + + + + + +CT5$67 #! #! #! #! #! #! #! #!L        ${2 {2 {2 {2 {23 {2 {2 {2|-) -) -) -) -)$ -) -) -)`B7 B7 B7 B7 B7 B7 B7 B7J    T   c c c c c c c c c cr9   