a
    d~                     @   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dZeeee ef d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   W/var/www/html/stable-diffusion-webui/venv/lib/python3.9/site-packages/omegaconf/base.py<lambda>A       zMetadata.<lambda>)default_factoryresolver_cachereturnc                 C   s   | j d u ri | _ 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 dS )z<Compute `type_hint` from `self.optional` and `self.ref_type`N)r/   r   r-   r=   r5   r5   r6   	type_hintG   s    
zMetadata.type_hint)__name__
__module____qualname__r   r   r   __annotations__boolr1   r   r	   strr2   r   r:   r?   propertyr@   r5   r5   r5   r6   r,   ,   s   
r,   c                   @   s4   e Zd ZU dZeed< dZeed< ddddZdS )ContainerMetadataNkey_typeelement_typer;   c                 C   sl   | j d u rt| _ | jtu s*t| jts*J | jd urXt| jsXtdt| jdd d| j	d u rhi | _	d S )NzUnsupported value type: 'T)Zinclude_module_name')
r-   r   rI   
isinstancetyperJ   r   r(   r   r1   r=   r5   r5   r6   r?   X   s    



zContainerMetadata.__post_init__)rA   rB   rC   rI   r   rD   rJ   r?   r5   r5   r5   r6   rH   S   s   
rH   c                   @   s  e Zd ZU eed< ed ed< eeeee f  ed< ed edddZ	eee
f dd	d
Zeee
f ddddZed ddddZddddZed dddZed dddZeee ef eeee  ee f d dddZeee dddZeee ddd Zeee dd!d"ZdRe
e
eee e
dd#d$d%Zeeeeef  ed&d'd(Zd dd)d*ZdSeeee  ed  d,d-d.ZdTeeee  ed  d,d/d0Z ddd1d2Z!edd3d4Z"edd5d6Z#ee
ed7d8d9Z$ee
ed7d:d;Z%eedd<d=Z&ee
dd>d?Z'edUe
eeeef  dd@dAdBZ(eeddCdDZ)eeddEdFZ*e
ddGdHZ+e
dd&dIdJZ,eddKdLZ-eddMdNdOZ.eddPdQZ/dS )VNode	_metadataBox_parent_flags_cacheparentmetadatac                 C   s"   || j d< || j d< d | j d< d S )NrO   rQ   rR   __dict__r>   rT   rU   r5   r5   r6   __init__l   s    

zNode.__init__r;   c                 C   s   t  | j}|d= |S NrR   )copyrW   r>   
state_dictr5   r5   r6   __getstate__q   s    zNode.__getstate__N)r]   r<   c                 C   s   | j | d | j d< d S rZ   )rW   updater\   r5   r5   r6   __setstate__w   s    zNode.__setstate__)rT   r<   c                 C   s,   |d u st |tsJ || jd< |   d S NrQ   )rL   rP   rW   _invalidate_flags_cacher>   rT   r5   r5   r6   _set_parent{   s    
zNode._set_parentc                 C   s   d | j d< d S rZ   rV   r=   r5   r5   r6   rb      s    zNode._invalidate_flags_cachec                 C   s$   | j d }|d u s t|ts J |S ra   )rW   rL   rP   rc   r5   r5   r6   _get_parent   s    
zNode._get_parent	Containerc                 C   sl   | j d }|du s t|ts J t|trN|j d }|du sJt|tsJJ |S |du sdt|tsdJ |S dS )z{
        Like _get_parent, but returns the grandparent
        in the case where `self` is wrapped by a UnionNode.
        rQ   N)rW   rL   rP   	UnionNoderf   )r>   rT   Zgrandparentr5   r5   r6   _get_parent_container   s    


zNode._get_parent_container)r1   valuesr<   c                 C   s   t |tr|g}|d u s"t |tr(|g}t|dkr@t|| }t|t|krXtdt|D ]\\}}|| }|d u r| jjd usJ || jjv r| jj|= q`| jjd usJ || jj|< q`|   | S )Nr   z3Inconsistent lengths of input flag names and values)	rL   rF   rE   len
ValueError	enumeraterO   r1   rb   )r>   r1   ri   idxflagvaluer5   r5   r6   	_set_flag   s$    
zNode._set_flag)rn   r<   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)rO   r1   get)r>   rn   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 rF| |}|||< |d u s\t|ts\J |S rZ   )rW   rq   r   _get_flag_no_cacherL   rE   )r>   rn   cacheretr5   r5   r6   	_get_flag   s    

zNode._get_flagc                 C   s^   | j j}|dusJ ||v r0|| dur0|| S |  r<dS |  }|du rPdS ||S d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)rO   r1   _is_flags_rootre   rv   )r>   rn   r1   rT   r5   r5   r6   rs      s    zNode._get_flag_no_cache)r0   ro   causemsgtype_overrider<   c                 C   s0   t | |||d u rt|n|||d ds,J d S )N)noder0   ro   ry   rx   rz   F)r   rF   )r>   r0   ro   rx   ry   rz   r5   r5   r6   _format_and_raise   s    zNode._format_and_raiser0   r<   c                 C   s   d S r3   r5   r>   r0   r5   r5   r6   _get_full_key   s    zNode._get_full_keyc                 C   s   | j dd}|d usJ |S )NT)throw_on_resolution_failure_dereference_node_impl)r>   r{   r5   r5   r6   _dereference_node   s    zNode._dereference_nodeF)r   memor<   c                 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s8J |  }|j||| tt| ||dS )Nz8Cannot resolve interpolation for a node without a parent)rT   r0   ro   
parse_treer   r   )r   rh   r#   _key&_resolve_interpolation_from_parse_treer*   r   )r>   r   r   rT   r0   r5   r5   r6   r     s&    
zNode._dereference_node_implc                 C   s~   |   }|d u r"t| tsJ | S |d ur4t|ts8J |  d urd|  }|d ur^t|ts8J q8|d urvt|tszJ |S r3   )re   rL   rf   rP   )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otherr<   c                 C   s   d S r3   r5   r>   r   r5   r5   r6   __eq__6  s    zNode.__eq__c                 C   s   d S r3   r5   r   r5   r5   r6   __ne__:  s    zNode.__ne__c                 C   s   d S r3   r5   r=   r5   r5   r6   __hash__>  s    zNode.__hash__c                 C   s   d S r3   r5   r=   r5   r5   r6   r   B  s    zNode._valuero   r1   r<   c                 C   s   d S r3   r5   )r>   ro   r1   r5   r5   r6   
_set_valueF  s    zNode._set_valuec                 C   s   d S r3   r5   r=   r5   r5   r6   _is_optionalJ  s    zNode._is_optionalc                 C   s   d S r3   r5   r=   r5   r5   r6   r   N  s    zNode._is_interpolationc                 C   s   | j jS r3   rO   r0   r=   r5   r5   r6   r   R  s    z	Node._keyc                 C   s   || j _d S r3   r   r~   r5   r5   r6   _set_keyU  s    zNode._set_keyc                 C   s   | j jS r3   )rO   r2   r=   r5   r5   r6   rw   X  s    zNode._is_flags_root)r2   r<   c                 C   s    | j j|kr|| j _|   d S r3   )rO   r2   rb   )r>   r2   r5   r5   r6   _set_flags_root[  s    zNode._set_flags_rootc                 C   s   | j jtuS r3   )rO   r-   r   r=   r5   r5   r6   _has_ref_type`  s    zNode._has_ref_type)NN)FN)N)N)0rA   rB   rC   r,   rD   r   r	   rF   rE   rY   r   r^   r`   rd   rb   re   rh   r   r   rp   rr   rv   rs   	Exceptionr|   r   DictKeyTypeintr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rw   r   r   r5   r5   r5   r6   rN   f   s   
    
 
"rN   c                       sR   e Zd ZU dZeed< ed  ed fddZedddZ	d	dd
dZ
  ZS )rP   z
    Base class for nodes that can contain other nodes.
    Concrete subclasses include DictConfig, ListConfig, and UnionNode.
    _contentrS   c                    s   t  j||d d | jd< d S )NrS   r   )superrY   rW   rX   	__class__r5   r6   rY   l  s    zBox.__init__r;   c                 C   s
   t | S r3   )r[   deepcopyr=   r5   r5   r6   __copy__p  s    zBox.__copy__Nc                 C   s  ddl m} ddlm} t| |rt| jd }t|trr| jd  D ],\}}|d ur^||  t|t	rD|
  qDnt| |r| jd }t|tr| jd D ](}|d ur||  t|t	r|
  qn@t| tr| jd }t|tr||  t|t	r|
  d S )Nr   
DictConfig
ListConfigr   )
dictconfigr   
listconfigr   rL   rW   r4   itemsrd   rP   
_re_parentlistrg   rN   )r>   r   r   contentr   ro   itemr5   r5   r6   r   t  s0    











zBox._re_parent)rA   rB   rC   __doc__r   rD   r   r,   rY   r   r   __classcell__r5   r5   r   r6   rP   d  s
   
rP   c                   @   s  e Zd ZU dZeed< ed5eeeeee	e
e ee
e  f dddZed6eeeeee	e
e ee
e  f ddd	Zeed
dddZeeed
dddZeee dddZeeedddZeed ef dddZd7eeee
ee  ee
d  e
e e
e f dddZe
d  deejee
ee  e
d dddZe
d  deeee
d d d!d"Zeed
d#d$d%Zee
ee  dd&d'd(Zeeeeed)f eed)f ed*d+d,Z d8e
d  eeee
ee  e
e d-d.d/Z!d9e"ee
ee  e
e ed0d1d2Z#d
dd3d4Z$d
S ):rf   z%
    Container tagging interface
    rO   TF)r0   validate_accessvalidate_keythrow_on_missing_valuethrow_on_missing_keyr<   c                 C   s   d S r3   r5   r>   r0   r   r   r   r   r5   r5   r6   
_get_child  s    	zContainer._get_childc                 C   s   d S r3   r5   r   r5   r5   r6   	_get_node  s    	zContainer._get_nodeNr}   c                 C   s   d S r3   r5   r~   r5   r5   r6   __delitem__  s    zContainer.__delitem__)r0   ro   r<   c                 C   s   d S r3   r5   )r>   r0   ro   r5   r5   r6   __setitem__  s    zContainer.__setitem__r;   c                 C   s   d S r3   r5   r=   r5   r5   r6   __iter__  s    zContainer.__iter__)key_or_indexr<   c                 C   s   d S r3   r5   )r>   r   r5   r5   r6   __getitem__  s    zContainer.__getitem__c                 C   s~   |}| ds|  |fS | }| ds,J |d us8J |dd  }| dsPqr| }|d u r,td| dq,||fS d S )N.r   zError resolving key 'rK   )
startswithr   rh   r    )r>   r0   origr   r5   r5   r6   _resolve_key_and_root  s    

zContainer._resolve_key_and_root)r0   throw_on_missingr   r   r<   c              	   C   s  ddl m} |dkr| d| fS t|}| }tt|d D ]}|du rJ q|| }	|||	||d\}
}t|
tr~|
j||d}
|
durt|
tsd	|d|d  }||d  }t
d	| d
| d| d|
}q:|du rdS |d }|||||d\}}|du r||dfS |dur>t|}||v r4td|| z,|j|||||d}W |dur|| n|dur|| 0 |||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 ``)NNNz Recursive interpolation detected)rT   r0   ro   r   r   )	omegaconfr   r   rangerj   rL   rN   r   rf   joinr!   idr#   add_maybe_resolve_interpolationremove)r>   r0   r   r   r   r   splitr   ikru   _Z
parent_keyZ	child_keylast_keyro   Zvidr5   r5   r6   _select_impl  st    











zContainer._select_implrN   )rT   ro   r0   r   r   r   r<   c                 C   sF   z| j ||||d}W n ty0   |r* Y dS 0 | 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   r{   r0   r   N)rT   ro   r0   resolvedr   )resolve_parse_treer#   *_validate_and_convert_interpolation_result)r>   rT   ro   r0   r   r   r   r   r5   r5   r6   r   !  s    &
z0Container._resolve_interpolation_from_parse_tree)rT   ro   r0   r   r   r<   c                 C   s   ddl m}m}m} t|t }	t||rt||st|}
z||
}W nJ ty } z2|r~| j	||
|d| d| t
d W Y d }~d S d }~0 0 t|t|
krd}	|}|	r||||dS t|tsJ |S d S )Nr   )AnyNodeInterpolationResultNode	ValueNodez#While dereferencing interpolation 'z': )r0   ro   rx   ry   rz   T)ro   r0   rT   )nodesr   r   r   rL   rN   r   Zvalidate_and_convertr(   r|   r%   rM   )r>   rT   ro   r0   r   r   r   r   r   Z	must_wrapZ	res_valueZ
conv_valueer5   r5   r6   r   X  s.    z4Container._validate_and_convert_interpolation_result)r{   targetr<   c                 C   s*   |}|d ur&||u rt d| }qd S )Nz%Interpolation to parent node detected)r#   re   )r>   r{   r   rT   r5   r5   r6   %_validate_not_dereferencing_to_parent  s    z/Container._validate_not_dereferencing_to_parent	inter_keyr   r<   c              
   C   s   z|  |\}}W n@ tyR } z(td| t d W Y d}~n
d}~0 0 z|j|dd|d\}}}W n@ ty } z(td| t d W Y d}~n
d}~0 0 |du s|du rtd| dn| j	| |d	 |S 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   )r>   r   r   	root_nodeexcrT   r   ro   r5   r5   r6   _resolve_node_interpolation  s2    

z%Container._resolve_node_interpolation.)r0   r{   
inter_type
inter_argsinter_args_strr<   c           	      C   sH   ddl m} ||}|d ur6|  }||| |||S td| d S )Nr   )	OmegaConfzUnsupported interpolation type )r   r   Z_get_resolverr   r'   )	r>   r0   r{   r   r   r   r   resolverr   r5   r5   r6   _evaluate_custom_resolver  s    
z#Container._evaluate_custom_resolver)rT   r0   ro   r   r   r<   c                 C   sF   t |}|tjkr|S tt|}| j||||||d ur<|nt dS )N)rT   ro   r0   r   r   r   )r   r   ZINTERPOLATIONr*   r   r   set)r>   rT   r0   ro   r   r   Z
value_kindr   r5   r5   r6   r     s    
z&Container._maybe_resolve_interpolation)r   r{   r   r0   r<   c           	   
      s   t ttt  td dfdd}t ttdf tt df td fdd}t|||d	}z||W S  ty|    Y nJ t	y } z2tt
|j d
| t d W Y d}~n
d}~0 0 dS )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.
        rN   r   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_strr<   c                    s   j  | ||dS )N)r0   r{   r   r   r   )r   )r   r   r   r0   r{   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)rF   r   r   r   r   r   r+   visitr#   r   rM   rA   r   r   r   )	r>   r   r{   r   r0   r   r   visitorr   r5   r   r6   r     s*    
zContainer.resolve_parse_treec                 C   s   ddl m} ddlm} | jd d urd | jd< t| |rl| jd }t|tr| jd  D ]}|  q\n6t| |r| jd }t|t	r| jd D ]}|  qd S )Nr   r   r   rR   r   )
r   r   r   r   rW   rL   r4   ri   rb   r   )r>   r   r   r   ro   r   r5   r5   r6   rb     s    






z!Container._invalidate_flags_cache)TTFF)TTFF)N)N)NN)%rA   rB   rC   r   rH   rD   r   r   rE   r   r   rN   r   r   r   r   r   r
   r   r   rF   r   r   r   r   r   r)   ZConfigValueContextr   r   r   r   r   r   r   r   rb   r5   r5   r5   r6   rf     s   
    
    
 
P
9+


 
  
-rf   c                   @   s   e Zd ZdZdZdZdS )SCModer   r      N)rA   rB   rC   DICTZDICT_CONFIGZINSTANTIATEr5   r5   r5   r6   r     s   r   c                       sH  e Zd ZU dZee ed< eede	f ed< d&e
e
ee
ee dd fddZeeeef  e	d	d
dZe
edddZe
edddZedddZeede	f dddZd'e
eee	ef  ddddZd(e
eee	ef  ddddZedddZedddZe	ddd Ze	dd!d"Zeee
f d d#d$d%Z  ZS ))rg   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).
    rQ   Nr   T)r   r-   is_optionalr0   rT   r<   c              
      s   zft |s"d| dd }t|t|ttfs8tdt j|t|d ||ddidd | 	| W n: t
y } z"td ||t||d	 W Y d }~n
d }~0 0 d S )
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   rS   )r{   r0   ro   ry   rx   )r   AssertionErrorrL   rf   r   r!   r   rY   r,   r   r   r   rF   )r>   r   r-   r   r0   rT   ry   exr   r5   r6   rY   .  s,    

zUnionNode.__init__r}   c                 C   s@   |   }|d u r.| jjd u r dS t| jjS n|| jjS d S )Nr   )re   rO   r0   rF   r   )r>   r0   rT   r5   r5   r6   r   M  s    zUnionNode._get_full_keyr   c                 C   sZ   | j d }t|tr ||}n t|tr6||}n
||}t|tttfsVJ |S Nr   )rW   rL   rN   r   rE   rM   NotImplemented)r>   r   r   ru   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__r;   c                 C   s   t | jd S r   )hashrW   r=   r5   r5   r6   r   h  s    zUnionNode.__hash__c                 C   s"   | j d }t|tttfsJ |S r   )rW   rL   rN   r   rF   )r>   r   r5   r5   r6   r   k  s    
zUnionNode._valuer   c              
   C   sf   | j d }| j d }z| || W n< ty` } z$|| j d< || j d< |W Y d }~n
d }~0 0 d S )Nr   rO   )rW   _set_value_implr   )r>   ro   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|rnt|tt	fs>J |d u rb| 
 sbtdt| d|| jd< nxt|trtdt| nZ|jD ]>}z"|||dd | d| jd< W  qW q ty   Y qY q0 qtd	t| dd S )
Nr   )
_node_wrapz/Value '$VALUE' is incompatible with type hint 'rK   r   z:Cannot assign container '$VALUE' of type '$VALUE_TYPE' to F)ro   r-   r   r0   rT   zEValue '$VALUE' of type '$VALUE_TYPE' is incompatible with type hint ')Zomegaconf.omegaconfr  rO   r-   r@   r   r   rL   rF   r   r   r(   r   rW   rf   __args__)r>   ro   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 )NrO   T)rW   r/   r=   r5   r5   r6   r     s    zUnionNode._is_optionalc                 C   s   t | jd S r   )r   rW   r=   r5   r5   r6   r     s    zUnionNode._is_interpolationc                 C   s   t | jd S r   )rF   rW   r=   r5   r5   r6   __str__  s    zUnionNode.__str__c                 C   s   t | jd S r   )reprrW   r=   r5   r5   r6   __repr__  s    zUnionNode.__repr__)r   r<   c              	   C   s   t t| }| j D ]$\}}|dvrtj||d|j|< q| jd }t|tr|jd }z0d |jd< tj||d}||jd< W ||jd< q||jd< 0 n|}||jd< | jd |jd< |S )N)r   rQ   )r   r   rQ   )	object__new__rM   rW   r   r[   r   rL   rN   )r>   r   resr0   ro   Zsrc_contentZ
old_parentZcontent_copyr5   r5   r6   __deepcopy__  s     




zUnionNode.__deepcopy__)TNN)N)N)rA   rB   rC   r   r   rf   rD   r   rN   rF   r   rE   rP   rY   r   r   r   r   r   r   r   r	   r   r  r   r   r  r  r  r   r5   r5   r   r6   rg     s<   
   
  'rg   )Cr[   r   abcr   r   collectionsr   Z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+   rF   bytesr   floatrE   r   r,   rH   rN   rP   rf   r   rg   r5   r5   r5   r6   <module>   s6   ,<,&   0   