
    0;ji                         d Z ddlmZmZ ddlmZ ddlZddlmZm	Z	 	  G d
 de          Z eeej                  Zd Zd ZddZdS )z6
some helper functions that might be generally useful
    )absolute_importprint_function)partialN   )	text_typebinary_typeF)AnyDictOptionalListText)StreamTextTypec                   $    e Zd ZdZd Zd Zd ZdS )LazyEvala  
    Lightweight wrapper around lazily evaluated func(*args, **kwargs).

    func is only evaluated when any attribute of its return value is accessed.
    Every attribute access is passed through to the wrapped value.
    (This only excludes special cases like method-wrappers, e.g., __hash__.)
    The sole additional attribute is the lazy_self function which holds the
    return value (or, prior to evaluation, func and arguments), in its closure.
    c                 V      fd}t                                d|           d S )Nc                  X      i  t                               d fd            S )N	lazy_selfc                       S N )return_values   P/root/voice-cloning/.venv/lib/python3.11/site-packages/srsly/ruamel_yaml/util.py<lambda>z6LazyEval.__init__.<locals>.lazy_self.<locals>.<lambda>#   s    ,     object__setattr__)r   argsfunckwargsselfs   @r   r   z$LazyEval.__init__.<locals>.lazy_self    s@    4000Lt[2F2F2F2FGGGr   r   r   )r!   r   r   r    r   s   ```` r   __init__zLazyEval.__init__   sN    	  	  	  	  	  	  	  	  	4i88888r   c                 x    t                               | d          }|dk    r|S t           |            |          S )Nr   )r   __getattribute__getattr)r!   namer   s      r   r$   zLazyEval.__getattribute__(   s>    ++D+>>	;yy{{D)))r   c                 L    t          |                                 ||           d S r   )setattrr   )r!   r&   values      r   r   zLazyEval.__setattr__/   s$      $.....r   N)__name__
__module____qualname____doc__r"   r$   r   r   r   r   r   r      sK         9 9 9* * */ / / / /r   r   c                    ddl m} d }t          | t                    r| }n?t          | t                    r|                     d          }n|                                 }d}d}d}d}d}	|                                D ]}
|
                                }|	                                }|
                    d          rF ||
          }||	z
  }|dz   }|
|         dk    r|dz  }|
|         dk    |
|         d	k    r~||	z
  } nq|*|(|r&d}|
|         d
v r|dz  }|
|         d
v ||k    r||z
  }|                    d          r- ||
          }	d}|
|         dk    r|dz  }|
|         dk    |}d}|||} ||fi |||fS )at  guess the indent and block sequence indent of yaml stream/string

    returns round_trip_loaded stream, indent level, block sequence indent
    - block sequence indent is the number of spaces before a dash relative to previous indent
    - if there are no block sequences, indent is taken from nested mappings, block sequence
      indent is unset (None) in that case
    r   )round_trip_loadc                     d}|t          |           k     r0| |         dk    r$|dz  }|t          |           k     r| |         dk    $|S )Nr    r   )len)lidxs     r   leading_spacesz.load_yaml_guess_indent.<locals>.leading_spacesH   sM    CFFllqv}}1HC CFFllqv}}
r   zutf-8Nr   z- r1   #z -:)mainr/   
isinstancer   r   decoderead
splitlinesrstriplstrip
startswithendswith)streamkwr/   r5   yaml_str
map_indentindentblock_seq_indentprev_line_key_only
key_indentlinerlinellinel_sr4   s                  r   load_yaml_guess_indentrM   <   s-    &%%%%%   &)$$ !	FK	(	( !==));;==JFJ##%% " "D!! 		 .&&C"Z/'Cs)s""q s)s""CyC:%FE"4"@U"@Cs)t##q s)t##''' #55
>># 	'--JCs)s""q s)s""!$!~*0?8**r**F4DDDr   c              #     K   ddl m} t          | |          sJ | j        D ]}|                                r|V  t          |           D ]}|                                r|V  | j        D ]}|                                r|V  dS )zv
    walks over a ConfigObj (INI file with comments) generating
    corresponding YAML output (including comments
    r   )	ConfigObjN)	configobjrO   r9   initial_commentstrip_walk_sectionfinal_comment)cfgrO   css       r   configobj_walkerrX   {   s       $#####c9%%%%%   7799 	GGG3  7799 	GGG  7799 	GGG r   c              #     K   ddl m} t          | |          sJ d|z  }| j        D ]}| j        |         D ]}||                                z   V  | |         }d|v r7|dz   }d|z   |                                                    dd|z             z   }n d|v rd|                    dd          z   dz   }d	                    |||          }| j        |         }|r|d
|z   z  }|V  | j	        D ]}}| j        |         D ]}||                                z   V  d                    ||          }| j        |         }|r|d
|z   z  }|V  t          | |         |dz             D ]}	|	V  ~d S )Nr   )Sectionz  
z|
r7   'z''z{0}{1}: {2}r1   z{0}{1}:r   )level)rP   rZ   r9   scalarscommentsrR   replaceformatinline_commentssectionsrS   )
rW   r]   rZ   rE   r&   rV   xirI   vals
             r   rS   rS      s     !!!!!!a!!!!!U]F	  D! 	% 	%A17799$$$$$dGA::A
QWWYY..ueai@@@AAAXXqyyu---4A$$VT155d# 	D1HD




 	 	D! 	% 	%A17799$$$$$  ..d# 	D1HD


 4	::: 	 	CIIII		 	r   )r   )r-   
__future__r   r   	functoolsr   recompatr   r   typingr	   r
   r   r   r   r   r   r   compileRegExprM   rX   rS   r   r   r   <module>rn      s     7 6 6 6 6 6 6 6       				 * * * * * * * *'
/ / / / /v / / /B 
2:	&	&<E <E <E~  (     r   