
    /;ji                        d dl mZmZmZ d dlmZ d dlZddlmZ ddl	m
Z
 ddlmZmZmZmZ  G d d	e          Z	 	 	 	 ddedededededefdZdeeef         defdZdedefdZ	 	 	 	 ddededededededdfdZdedefdZdS )    )UnionIOAny)StringION   )YAML)RepresenterError)
force_pathFilePath	YAMLInput
YAMLOutputc                       e Zd ZddZddZdS )
CustomYamlsafeTc                 ^    t          j        | ||           d| _        d| _        d| _        d S )N)typpureFTzutf-8)r   __init__default_flow_styleallow_unicodeencoding)selfr   r   s      I/root/voice-cloning/.venv/lib/python3.11/site-packages/srsly/_yaml_api.pyr   zCustomYaml.__init__   s4    d$////"'!    Nc                     d}|d}t                      }t          j        | ||fi | |r|                                S d S )NFT)r   r   dumpgetvalue)r   datastreamkwinefficients        r   r   zCustomYaml.dump   sX    >KZZF	$f+++++ 	%??$$$	% 	%r   )r   T)N)__name__
__module____qualname__r   r    r   r   r   r   
   s<               % % % % % %r   r         Fr   indent_mappingindent_sequenceindent_offset	sort_keysreturnc                     t                      }||_        |                    |||           |                    |           S )a  Serialize an object to a YAML string. See the ruamel.yaml docs on
    indentation for more details on the expected format.
    https://yaml.readthedocs.io/en/latest/detail.html?highlight=indentation#indentation-of-block-sequences

    data: The YAML-serializable data.
    indent_mapping (int): Mapping indentation.
    indent_sequence (int): Sequence indentation.
    indent_offset (int): Indentation offset.
    sort_keys (bool): Sort dictionary keys.
    RETURNS (str): The serialized string.
    )mappingsequenceoffset)r    sort_base_mapping_type_on_outputindentr   )r   r(   r)   r*   r+   yamls         r   
yaml_dumpsr4      s=    $ <<D,5D)KKKWWW99T??r   c                     t                      }	 |                    |           S # t          $ r}t          d|           d}~ww xY w)zDeserialize unicode or a file object a Python object.

    data (str / file): The data to deserialize.
    RETURNS: The deserialized Python object.
    zInvalid YAML: N)r   load	Exception
ValueError)r   r3   es      r   
yaml_loadsr:   4   sX     <<D/yy / / /-!--.../s   % 
AAApathc                    | dk    r-t           j                                        }t          |          S t	          |           }|                    dd          5 }t          |          cddd           S # 1 swxY w Y   dS )zLoad YAML from file or standard input.

    location (FilePath): The file path. "-" for reading from stdin.
    RETURNS (YAMLOutput): The loaded content.
    -rutf8r   N)sysstdinreadr:   r
   open)r;   r   	file_pathfs       r   	read_yamlrG   A   s     s{{y~~$4  I	f	-	- !}}                 s   A66A:=A:c                    t          |||||          }| dk    rt          |           dS t          | d          }|                    dd          5 }|                    |           ddd           dS # 1 swxY w Y   dS )	a  Create a .json file and dump contents or write to standard
    output.

    location (FilePath): The file path. "-" for writing to stdout.
    data (YAMLInput): The JSON-serializable data to output.
    indent_mapping (int): Mapping indentation.
    indent_sequence (int): Sequence indentation.
    indent_offset (int): Indentation offset.
    sort_keys (bool): Sort dictionary keys.
    )r(   r)   r*   r+   r=   F)require_existswr?   r@   N)r4   printr
   rD   write)	r;   r   r(   r)   r*   r+   	yaml_datarE   rF   s	            r   
write_yamlrN   O   s    $ %'#  I s{{itE:::	^^C&^11 	QGGI	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   A77A;>A;objc                 H    	 t          |            dS # t          $ r Y dS w xY w)zCheck if a Python object is YAML-serializable (strict).

    obj: The object to check.
    RETURNS (bool): Whether the object is YAML-serializable.
    TF)r4   r	   )rO   s    r   is_yaml_serializablerQ   p   s9    3t   uus    
!!)r&   r'   r&   F)typingr   r   r   ior   rA   ruamel_yamlr   ruamel_yaml.representerr	   utilr
   r   r   r   r   intboolstrr4   r:   rG   rN   rQ   r%   r   r   <module>rZ      s   ! ! ! ! ! ! ! ! ! !       



       5 5 5 5 5 5 = = = = = = = = = = = =% % % % % % % %(  
  	
  	   0
/U37^ 
/
 
/ 
/ 
/ 
/H     "  

  	
   
   B
c 
d 
 
 
 
 
 
r   