o
    ‹ôjÎ~  ã                   @   sš  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„ dƒƒZ<eG dd„ de<ƒƒZ=G dd„ deƒZ>G dd„ de>ƒZ?G dd„ de?ƒZ@G dd„ deƒZAG d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                   @   s°   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	d
„ d�Ze
eef ed< ddd„Zedeee ef fdd„ƒZdS )ÚMetadataÚref_typeÚobject_typeÚoptionalÚkeyNÚflagsFÚ
flags_rootc                   C   s   t tƒS ©N)r   Údict© r5   r5   úa/var/www/html/academy/tools/voices/clone/cosy-venv/lib/python3.10/site-packages/omegaconf/base.pyÚ<lambda>A   s    zMetadata.<lambda>)Údefault_factoryÚresolver_cacheÚreturnc                 C   s   | j d u r
i | _ d S d S r3   )r1   ©Úselfr5   r5   r6   Ú__post_init__C   s   

ÿzMetadata.__post_init__c                 C   s   | j rt| j S | jS )z<Compute `type_hint` from `self.optional` and `self.ref_type`)r/   r   r-   r;   r5   r5   r6   Ú	type_hintG   s   
zMetadata.type_hint©r:   N)Ú__name__Ú
__module__Ú__qualname__r   r   r   Ú__annotations__Úboolr1   r   r	   Ústrr2   r   r9   r=   Úpropertyr>   r5   r5   r5   r6   r,   ,   s   
 
 r,   c                   @   s0   e Zd ZU dZeed< dZeed< ddd„ZdS )ÚContainerMetadataNÚkey_typeÚelement_typer:   c                 C   sp   | j d u rt| _ | jtu st| jtƒsJ ‚| jd ur,t| jƒs,tdt| jdd�› d�ƒ‚| j	d u r6i | _	d S d S )NzUnsupported value type: 'T)Zinclude_module_nameú')
r-   r   rH   Ú
isinstanceÚtyperI   r   r(   r   r1   r;   r5   r5   r6   r=   X   s   


ÿ

ÿzContainerMetadata.__post_init__r?   )r@   rA   rB   rH   r   rC   rI   r=   r5   r5   r5   r6   rG   S   s   
 rG   c                   @   sò  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d„Z	d	eee
f fd
d„Zdeee
f d	dfdd„Zded d	dfdd„ZdVdd„Zd	ed fdd„Zd	ed fdd„Zdeee ef deeee  ee f d	d fdd„Zded	ee fdd„Zded	ee fd d!„Zded	ee fd"d#„Z		dWd$e
d%e
d&ed'ee d(e
d	dfd)d*„Zed$eeeef  d	efd+d,„ƒZdXd-d.„Z	/	dYd0ed1eee  d	ed  fd2d3„Z	dZd0ed1eee  d	ed  fd4d5„Z d[d6d7„Z!d	efd8d9„Z"d	efd:d;„Z#ed<e
d	efd=d>„ƒZ$ed<e
d	efd?d@„ƒZ%ed	efdAdB„ƒZ&ed	e
fdCdD„ƒZ'edZd%e
deeeef  d	dfdEdF„ƒZ(ed	efdGdH„ƒZ)ed	efdIdJ„ƒZ*d	e
fdKdL„Z+d$e
d	dfdMdN„Z,d	efdOdP„Z-dQed	dfdRdS„Z.d	efdTdU„Z/dS )\ÚNodeÚ	_metadataÚBoxÚ_parentÚ_flags_cacheÚparentÚmetadatac                 C   s"   || j d< || j d< d | j d< d S )NrN   rP   rQ   ©Ú__dict__©r<   rR   rS   r5   r5   r6   Ú__init__l   s   

zNode.__init__r:   c                 C   s   t   | j¡}|d= |S ©NrQ   )ÚcopyrU   ©r<   Ú
state_dictr5   r5   r6   Ú__getstate__q   s   zNode.__getstate__r[   Nc                 C   s   | j  |¡ d | j d< d S rX   )rU   ÚupdaterZ   r5   r5   r6   Ú__setstate__w   s   zNode.__setstate__c                 C   s,   |d u st |tƒsJ ‚|| jd< |  ¡  d S ©NrP   )rK   rO   rU   Ú_invalidate_flags_cache©r<   rR   r5   r5   r6   Ú_set_parent{   s   
zNode._set_parentc                 C   s   d | j d< d S rX   rT   r;   r5   r5   r6   r`   €   ó   zNode._invalidate_flags_cachec                 C   s$   | j d }|d u st|tƒsJ ‚|S r_   )rU   rK   rO   ra   r5   r5   r6   Ú_get_parentƒ   s   
zNode._get_parentÚ	Containerc                 C   sh   | j d }|du st|tƒsJ ‚t|tƒr'|j d }|du s%t|tƒs%J ‚|S |du s2t|tƒs2J ‚|S )z{
        Like _get_parent, but returns the grandparent
        in the case where `self` is wrapped by a UnionNode.
        rP   N)rU   rK   rO   Ú	UnionNodere   )r<   rR   Zgrandparentr5   r5   r6   Ú_get_parent_containerˆ   s   


zNode._get_parent_containerr1   Úvaluesc                 C   sÊ   t |tƒr|g}|d u st |tƒr|g}t|ƒdkr t|ƒ| }t|ƒt|ƒkr,tdƒ‚t|ƒD ].\}}|| }|d u rP| jjd usDJ ‚|| jjv rO| jj|= q0| jjd usXJ ‚|| jj|< q0|  ¡  | S )Nr   z3Inconsistent lengths of input flag names and values)	rK   rE   rD   ÚlenÚ
ValueErrorÚ	enumeraterN   r1   r`   )r<   r1   rh   ÚidxÚflagÚvaluer5   r5   r6   Ú	_set_flag˜   s&   

€zNode._set_flagrm   c                 C   s   | j jdusJ ‚| j j |¡S )zc
        :param flag: flag to inspect
        :return: the state of the flag on this node.
        N)rN   r1   Úget)r<   rm   r5   r5   r6   Ú_get_node_flagµ   s   zNode._get_node_flagc                 C   s`   | j d }|d u ri  }| j d< | |t¡}|tu r#|  |¡}|||< |d u s.t|tƒs.J ‚|S rX   )rU   rp   r   Ú_get_flag_no_cacherK   rD   )r<   rm   ÚcacheÚretr5   r5   r6   Ú	_get_flag½   s   

zNode._get_flagc                 C   sZ   | j j}|dus
J ‚||v r|| dur|| S |  ¡ rdS |  ¡ }|du r(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)rN   r1   Ú_is_flags_rootrd   ru   )r<   rm   r1   rR   r5   r5   r6   rr   É   s   
zNode._get_flag_no_cacher0   rn   ÚcauseÚmsgÚtype_overridec                 C   s(   t | |||d u rt|ƒn|||d� J ‚)N)Únoder0   rn   rx   rw   ry   )r   rE   )r<   r0   rn   rw   rx   ry   r5   r5   r6   Ú_format_and_raiseß   s   úzNode._format_and_raisec                 C   ó   d S r3   r5   ©r<   r0   r5   r5   r6   Ú_get_full_keyñ   ó   zNode._get_full_keyc                 C   s   | j dd�}|d usJ ‚|S )NT)Úthrow_on_resolution_failure©Ú_dereference_node_impl)r<   rz   r5   r5   r6   Ú_dereference_nodeõ   s   zNode._dereference_nodeFr€   Úmemoc                 C   s   | j ||d�S )N©r€   r„   r�   )r<   r€   r„   r5   r5   r6   Ú_maybe_dereference_nodeú   s   þzNode._maybe_dereference_nodec                 C   s^   |   ¡ s| S |  ¡ }|d u r|rtdƒ‚d S |d usJ ‚|  ¡ }|j||| tt| ƒƒ||d�S )Nz8Cannot resolve interpolation for a node without a parent)rR   r0   rn   Ú
parse_treer€   r„   )r   rg   r#   Ú_keyÚ&_resolve_interpolation_from_parse_treer*   r   )r<   r€   r„   rR   r0   r5   r5   r6   r‚     s&   ÿ
úzNode._dereference_node_implc                 C   sˆ   |   ¡ }|d u rt| tƒsJ ‚| S |d urt|tƒsJ ‚|  ¡ d ur7|  ¡ }|d ur/t|tƒs1J ‚|  ¡ d us"|d ur@t|tƒsBJ ‚|S r3   )rd   rK   re   rO   )r<   Úrootr5   r5   r6   Ú	_get_root  s   þzNode._get_rootc                 C   s   t | ƒS )zY
        Check if the node's value is `???` (does *not* resolve interpolations).
        )r   r;   r5   r5   r6   Ú_is_missing*  s   zNode._is_missingc                 C   s   |   ¡ du S )zZ
        Check if the node's value is `None` (does *not* resolve interpolations).
        N)Ú_valuer;   r5   r5   r6   Ú_is_none0  s   zNode._is_noneÚotherc                 C   r|   r3   r5   ©r<   r�   r5   r5   r6   Ú__eq__6  r   zNode.__eq__c                 C   r|   r3   r5   r�   r5   r5   r6   Ú__ne__:  r   zNode.__ne__c                 C   r|   r3   r5   r;   r5   r5   r6   Ú__hash__>  r   zNode.__hash__c                 C   r|   r3   r5   r;   r5   r5   r6   r�   B  r   zNode._valuec                 C   r|   r3   r5   )r<   rn   r1   r5   r5   r6   Ú
_set_valueF  r   zNode._set_valuec                 C   r|   r3   r5   r;   r5   r5   r6   Ú_is_optionalJ  r   zNode._is_optionalc                 C   r|   r3   r5   r;   r5   r5   r6   r   N  r   zNode._is_interpolationc                 C   ó   | j jS r3   ©rN   r0   r;   r5   r5   r6   rˆ   R  ó   z	Node._keyc                 C   s   || j _d S r3   r—   r}   r5   r5   r6   Ú_set_keyU  ó   zNode._set_keyc                 C   r–   r3   )rN   r2   r;   r5   r5   r6   rv   X  r˜   zNode._is_flags_rootr2   c                 C   s$   | j j|kr|| j _|  ¡  d S d S r3   )rN   r2   r`   )r<   r2   r5   r5   r6   Ú_set_flags_root[  s   þzNode._set_flags_rootc                 C   s   | j jtuS r3   )rN   r-   r   r;   r5   r5   r6   Ú_has_ref_type`  rš   zNode._has_ref_typer?   ©NN)r:   rM   )FNr3   )r:   re   )0r@   rA   rB   r,   rC   r   r	   rE   rD   rW   r   r\   r^   rb   r`   rd   rg   r   r   ro   rq   ru   rr   Ú	Exceptionr{   r   ÚDictKeyTypeÚintr~   rƒ   r   r†   r‚   r‹   rŒ   rŽ   r‘   r’   r“   r�   r”   r•   r   rˆ   r™   rv   r›   rœ   r5   r5   r5   r6   rM   f   sœ   
 
þý
üúþýüûú
ù 
ýþ
ý
üýþ
ý
ü
&rM   c                       sP   e Zd ZU dZeed< ded  def‡ fdd„Zdefdd	„Z	ddd„Z
‡  ZS )rO   zƒ
    Base class for nodes that can contain other nodes.
    Concrete subclasses include DictConfig, ListConfig, and UnionNode.
    Ú_contentrR   rS   c                    s   t ƒ j||d� d | jd< d S )N©rR   rS   r¡   )ÚsuperrW   rU   rV   ©Ú	__class__r5   r6   rW   l  s   zBox.__init__r:   c                 C   s
   t  | ¡S r3   )rY   Údeepcopyr;   r5   r5   r6   Ú__copy__p  s   
zBox.__copy__Nc                 C   s  ddl m} ddlm} t| |ƒr=| jd }t|tƒr9| jd  ¡ D ]\}}|d ur/| | ¡ t|t	ƒr8| 
¡  q"d S d S t| |ƒrj| jd }t|tƒrf| jd D ]}|d ur\| | ¡ t|t	ƒre| 
¡  qQd S d S t| tƒr‰| jd }t|tƒr‹| | ¡ t|t	ƒr�| 
¡  d S d S d S d S )Nr   ©Ú
DictConfig©Ú
ListConfigr¡   )Ú
dictconfigr©   Ú
listconfigr«   rK   rU   r4   Úitemsrb   rO   Ú
_re_parentÚlistrf   rM   )r<   r©   r«   Úcontentrˆ   rn   Úitemr5   r5   r6   r¯   t  sB   




€û




€û




ùzBox._re_parentr?   )r@   rA   rB   Ú__doc__r   rC   r   r,   rW   r§   r¯   Ú__classcell__r5   r5   r¤   r6   rO   d  s   
 rO   c                   @   s�  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d„ƒZe				d<dedededed	ed
e	e
e ee
e  f fdd„ƒZeded
dfdd„ƒZededed
dfdd„ƒZed
ee fdd„ƒZeded
efdd„ƒZded
ed ef fdd„Z	d=dededede
ee  d
ee
d  e
e e
e f f
dd „Zd!e
d  dd"ded#ejdede
ee  d
e
d" fd$d%„Zd!e
d  dd"ded&eded
e
d" fd'd(„Zd)ed*ed
dfd+d,„Zd-ede
ee  d
d"fd.d/„Zded)ed0ed1eed2f d3eed2f d
efd4d5„Z 	d=d!e
d  dededede
ee  d
e
e fd6d7„Z!		d>d#e"d)ede
ee  de
e d
ef
d8d9„Z#d?d:d;„Z$dS )@re   z%
    Container tagging interface
    rN   TFr0   Úvalidate_accessÚvalidate_keyÚthrow_on_missing_valueÚthrow_on_missing_keyr:   c                 C   r|   r3   r5   ©r<   r0   rµ   r¶   r·   r¸   r5   r5   r6   Ú
_get_child›  ó   	zContainer._get_childc                 C   r|   r3   r5   r¹   r5   r5   r6   Ú	_get_node¦  r»   zContainer._get_nodeNc                 C   r|   r3   r5   r}   r5   r5   r6   Ú__delitem__±  r   zContainer.__delitem__rn   c                 C   r|   r3   r5   )r<   r0   rn   r5   r5   r6   Ú__setitem__µ  r   zContainer.__setitem__c                 C   r|   r3   r5   r;   r5   r5   r6   Ú__iter__¹  r   zContainer.__iter__Úkey_or_indexc                 C   r|   r3   r5   )r<   rÀ   r5   r5   r6   Ú__getitem__½  r   zContainer.__getitem__c                 C   s|   |}|  d¡s|  ¡ |fS | }|  d¡sJ ‚	 |d usJ ‚|dd … }|  d¡s-	 ||fS | ¡ }|d u r=td|› d�ƒ‚q)NÚ.Tr   zError resolving key 'rJ   )Ú
startswithr‹   rg   r    )r<   r0   ÚorigrŠ   r5   r5   r6   Ú_resolve_key_and_rootÁ  s   

üùzContainer._resolve_key_and_rootÚthrow_on_missingr€   r„   c              	   C   s„  ddl m} |dkr| d| fS t|ƒ}| }tt|ƒd ƒD ]L}|du r% nE|| }	|||	||d�\}
}t|
tƒr?|
j||d�}
|
durgt|
tƒsgd 	|d|d … ¡}||d  }t
d	|› d
|› d|› d�ƒ‚|
}q|du rpdS |d }|||||d�\}}|du r‡||dfS |durœt|ƒ}||v r—tdƒ‚| |¡ z|j|||||d�}W |dur±| |¡ n|dur¼| |¡ w w |||fS )zA
        Select a value using dot separated key sequence
        r   )Ú_select_oneÚ N)Úcr0   rÆ   Zthrow_on_type_errorr…   rÂ   r   zError trying to access z: node `z.` is not a container and thus cannot contain `ú`)NNNéÿÿÿÿz Recursive interpolation detected)rR   r0   rn   r€   r„   )Ú	omegaconfrÇ   r   Úrangeri   rK   rM   r†   re   Újoinr!   Úidr#   ÚaddÚ_maybe_resolve_interpolationÚremove)r<   r0   rÆ   r€   r„   rÇ   ÚsplitrŠ   ÚiÚkrt   Ú_Ú
parent_keyZ	child_keyÚlast_keyrn   Zvidr5   r5   r6   Ú_select_implÓ  sx   


ü
þÿÿ
ü

û
€þþ
zContainer._select_implrR   rM   r‡   c                 C   sF   z| j ||||d�}W n ty   |r‚ Y dS w | j|||||d�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‡   rz   r0   r„   N)rR   rn   r0   Úresolvedr€   )Úresolve_parse_treer#   Ú*_validate_and_convert_interpolation_result)r<   rR   rn   r0   r‡   r€   r„   rÚ   r5   r5   r6   r‰   !  s    &
ÿýûz0Container._resolve_interpolation_from_parse_treerÚ   c                 C   sÒ   ddl m}m}m} t|tƒ }	t||ƒrWt||ƒsWt|ƒ}
z| |
¡}W n% tyJ } z|r?| j	||
|d|› d|› �t
d� W Y d }~d S d }~ww t|ƒt|
ƒkrWd}	|}|	r`||||d�S t|tƒsgJ ‚|S )Nr   )ÚAnyNodeÚInterpolationResultNodeÚ	ValueNodez#While dereferencing interpolation 'z': )r0   rn   rw   rx   ry   T)rn   r0   rR   )ÚnodesrÝ   rÞ   rß   rK   rM   r   Zvalidate_and_convertr(   r{   r%   rL   )r<   rR   rn   r0   rÚ   r€   rÝ   rÞ   rß   Z	must_wrapÚ	res_valueZ
conv_valueÚer5   r5   r6   rÜ   X  s2   û€÷z4Container._validate_and_convert_interpolation_resultrz   Útargetc                 C   s4   |}|d ur||u rt dƒ‚| ¡ }|d usd S d S )Nz%Interpolation to parent node detected)r#   rd   )r<   rz   rã   rR   r5   r5   r6   Ú%_validate_not_dereferencing_to_parentƒ  s   ÿûz/Container._validate_not_dereferencing_to_parentÚ	inter_keyc              
   C   sÌ   z	|   |¡\}}W n ty# } ztd|› �ƒ t ¡ d ¡‚d}~ww z|j|dd|d�\}}}W n tyL } ztd|› �ƒ t ¡ d ¡‚d}~ww |du sU|du r]td|› d�ƒ‚| j	| |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)rz   rã   )
rÅ   r    r"   Úwith_tracebackÚsysÚexc_inforÙ   r&   r$   rä   )r<   rå   r„   Ú	root_nodeÚexcrR   rØ   rn   r5   r5   r6   Ú_resolve_node_interpolationŒ  s:   ÿþ€ÿüÿþ€ÿz%Container._resolve_node_interpolationÚ
inter_typeÚ
inter_args.Úinter_args_strc           	      C   sD   ddl m} | |¡}|d ur|  ¡ }||| |||ƒS td|› �ƒ‚)Nr   )Ú	OmegaConfzUnsupported interpolation type )rÌ   rð   Z_get_resolverr‹   r'   )	r<   r0   rz   rí   rî   rï   rð   Úresolverrê   r5   r5   r6   Ú_evaluate_custom_resolver©  s   
ûÿz#Container._evaluate_custom_resolverc                 C   sJ   t |ƒ}|tjkr|S tt|ƒƒ}| j||||||d ur |d�S tƒ d�S )N)rR   rn   r0   r‡   r€   r„   )r   r   ZINTERPOLATIONr*   r   r‰   Úset)r<   rR   r0   rn   r€   r„   Ú
value_kindr‡   r5   r5   r6   rÑ   Â  s   

úúz&Container._maybe_resolve_interpolationc           	   
      sÀ   dt dttt  dtd f‡fdd„}dt dttd	f d
tt d	f dtf‡ ‡‡fdd„}t|||d�}z| |¡W S  tyA   ‚  t	y_ } ztt
|ƒj› d|› �ƒ t ¡ d ¡‚d}~w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:   rM   c                    s   ˆ j | |d�S )N©rå   r„   )rì   rõ   r;   r5   r6   Únode_interpolation_callbackæ  s   zAContainer.resolve_parse_tree.<locals>.node_interpolation_callbackÚnameÚargs.Úargs_strc                    s   ˆj ˆ ˆ| ||d�S )N)r0   rz   rí   rî   rï   )rò   )r÷   rø   rù   ©r0   rz   r<   r5   r6   Úresolver_interpolation_callbackë  s   ûzEContainer.resolve_parse_tree.<locals>.resolver_interpolation_callback)rö   rû   r„   z' raised while resolving interpolation: ræ   N)rE   r   r   r    r   r   r+   Úvisitr#   rž   rL   r@   rç   rè   ré   )	r<   r‡   rz   r„   r0   rö   rû   Úvisitorrë   r5   rú   r6   rÛ   Ø  sB   ÿ
ÿþÿ
ÿ
ÿþýÿþ€þzContainer.resolve_parse_treec                 C   s¸   ddl m} ddlm} | jd d urTd | jd< t| |ƒr9| jd }t|tƒr5| jd  ¡ D ]}| ¡  q.d S d S t| |ƒrV| jd }t|t	ƒrX| jd D ]}| ¡  qMd S d S d S d S )Nr   r¨   rª   rQ   r¡   )
r¬   r©   r­   r«   rU   rK   r4   rh   r`   r°   )r<   r©   r«   r±   rn   r²   r5   r5   r6   r`     s(   




þ



õz!Container._invalidate_flags_cache)TTFFr3   r�   r?   )%r@   rA   rB   r³   rG   rC   r   r   rD   r   r   rM   r   rº   r¼   r½   r¾   r
   r¿   rÁ   rE   r   rÅ   r   r    rÙ   r)   ZConfigValueContextr‰   rÜ   rä   rì   rò   rÑ   r   rÛ   r`   r5   r5   r5   r6   re   ”  s  
 úþýüûúù
úþýüûúù
ûþýü
û
úNþýüûú
ù
ø7þýüûú
ù+	ÿ
ÿ
þþýü
û
ú
ùúþýüû
ú
ùûþý
üû
ú-re   c                   @   s   e Zd ZdZdZdZdS )ÚSCModer   ræ   é   N)r@   rA   rB   ÚDICTZDICT_CONFIGZINSTANTIATEr5   r5   r5   r6   rþ     s    rþ   c                       sj  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d„Zd	eeeef  de	fdd„Zde
defdd„Zde
defdd„Zdefdd„Zdeede	f fdd„Zd+de
deee	ef  ddfdd„Z	d+de
deee	ef  ddfdd„Zdefdd „Zdefd!d"„Zde	fd#d$„Zde	fd%d&„Zd'eee
f dd fd(d)„Z‡  ZS ),rf   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).
    rP   Nr¡   Tr±   r-   Úis_optionalr0   rR   r:   c              
      s¦   z4t |ƒsd|› d�d }t|ƒ‚t|ttfƒstdƒ‚tƒ j|t|d ||ddid�d� |  	|¡ W d S  t
yR } ztd ||t|ƒ|d	� W Y d }~d S d }~w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-   r.   r/   r0   r1   r¢   )rz   r0   rn   rx   rw   )r   ÚAssertionErrorrK   re   r   r!   r£   rW   r,   r”   rž   r   rE   )r<   r±   r-   r  r0   rR   rx   Úexr¤   r5   r6   rW   .  s0   
ÿÿûþ
$€ÿzUnionNode.__init__c                 C   s:   |   ¡ }|d u r| jjd u rdS t| jjƒS | | jj¡S )NrÈ   )rd   rN   r0   rE   r~   )r<   r0   rR   r5   r5   r6   r~   M  s   zUnionNode._get_full_keyr�   c                 C   sZ   | j d }t|tƒr| |¡}nt|tƒr| |¡}n| |¡}t|tttƒfƒs+J ‚|S ©Nr¡   )rU   rK   rM   r‘   rD   rL   ÚNotImplemented)r<   r�   r±   rt   r5   r5   r6   r‘   W  s   



zUnionNode.__eq__c                 C   s   |   |¡}|tu rtS | S r3   )r‘   r  )r<   r�   Úxr5   r5   r6   r’   b  s   
zUnionNode.__ne__c                 C   ó   t | jd ƒS r  )ÚhashrU   r;   r5   r5   r6   r“   h  rc   zUnionNode.__hash__c                 C   s"   | j d }t|tttfƒsJ ‚|S r  )rU   rK   rM   r   rE   )r<   r±   r5   r5   r6   r�   k  s   
zUnionNode._valuern   r1   c              
   C   sX   | j d }| j d }z	|  ||¡ W d S  ty+ } z|| j d< || j d< |‚d }~ww )Nr¡   rN   )rU   Ú_set_value_implrž   )r<   rn   r1   Zprevious_contentZprevious_metadatarâ   r5   r5   r6   r”   p  s   



€ýzUnionNode._set_valuec              	   C   sÞ   ddl m} | jj}| jj}t|ƒ}t|ƒr8t|tt	fƒsJ ‚|d u r1|  
¡ s1tdt|ƒ› d�ƒ‚|| jd< d S t|tƒrFtdt|ƒ› �ƒ‚|jD ]}z|||dd | d�| jd< W  d S  tyd   Y qIw td	t|ƒ› d�ƒ‚)
Nr   )Ú
_node_wrapz/Value '$VALUE' is incompatible with type hint 'rJ   r¡   z:Cannot assign container '$VALUE' of type '$VALUE_TYPE' to F)rn   r-   r  r0   rR   zEValue '$VALUE' of type '$VALUE_TYPE' is incompatible with type hint ')Zomegaconf.omegaconfr  rN   r-   r>   r   r   rK   rE   r   r•   r(   r   rU   re   Ú__args__)r<   rn   r1   r  r-   r>   Zcandidate_ref_typer5   r5   r6   r
  z  s@   ÿ
ÿ
ûÿÿzUnionNode._set_value_implc                 C   s   | j d jdu S )NrN   T)rU   r/   r;   r5   r5   r6   r•   ¡  s   zUnionNode._is_optionalc                 C   r  r  )r   rU   r;   r5   r5   r6   r   ¤  rc   zUnionNode._is_interpolationc                 C   r  r  )rE   rU   r;   r5   r5   r6   Ú__str__§  rc   zUnionNode.__str__c                 C   r  r  )ÚreprrU   r;   r5   r5   r6   Ú__repr__ª  rc   zUnionNode.__repr__r„   c              	   C   s¼   t  t| ƒ¡}| j ¡ D ]\}}|dvrtj||d�|j|< q| jd }t|tƒrM|jd }zd |jd< tj||d�}||jd< W ||jd< n||jd< w |}||jd< | jd |jd< |S )N)r¡   rP   )r„   r¡   rP   )	ÚobjectÚ__new__rL   rU   r®   rY   r¦   rK   rM   )r<   r„   Úresr0   rn   Zsrc_contentZ
old_parentZcontent_copyr5   r5   r6   Ú__deepcopy__­  s"   €




zUnionNode.__deepcopy__)TNNr3   )r@   rA   rB   r³   r   re   rC   r   rM   rE   r   rD   rO   rW   rŸ   r    r~   r‘   r’   r“   r�   r	   r”   r
  r•   r   r  r  r  r´   r5   r5   r¤   r6   rf     sN   
 úþýüûúù
$ÿÿÿ
þ'"rf   )CrY   rè   Úabcr   r   Úcollectionsr   Údataclassesr   r   Úenumr   Útypingr   r	   r
   r   r   r   r   r   r   Zantlr4r   Ú_utilsr   r   r   r   r   r   r   r   r   r   r   r   r   Úerrorsr    r!   r"   r#   r$   r%   r&   r'   r(   Z"grammar.gen.OmegaConfGrammarParserr)   Zgrammar_parserr*   Zgrammar_visitorr+   rE   Úbytesr    ÚfloatrD   rŸ   r,   rG   rM   rO   re   rþ   rf   r5   r5   r5   r6   Ú<module>   s6    ,<,& 0   