
    i                        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y)    )UnionIOAny)StringION   )YAML)RepresenterError)
force_pathFilePath	YAMLInput
YAMLOutputc                       e Zd ZddZddZy)
CustomYamlc                 ^    t        j                  | ||       d| _        d| _        d| _        y )N)typpureFTzutf-8)r   __init__default_flow_styleallow_unicodeencoding)selfr   r   s      `/var/www/vps2.regionflexible.com/Desarrollo/venv/lib/python3.12/site-packages/srsly/_yaml_api.pyr   zCustomYaml.__init__   s)    d$/"'!    Nc                 x    d}|d}t               }t        j                  | ||fi | |r|j                         S y )NFT)r   r   dumpgetvalue)r   datastreamkwinefficients        r   r   zCustomYaml.dump   sB    >KZF		$f++??$$ r   )safeT)N)__name__
__module____qualname__r   r    r   r   r   r   
   s     %r   r   r   indent_mappingindent_sequenceindent_offset	sort_keysreturnc                 n    t               }||_        |j                  |||       |j                  |       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_dumpsr2      s3    $ <D,5D)KKKW99T?r   c                 x    t               }	 |j                  |       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   r1   es      r   
yaml_loadsr8   4   s@     <D/yy />!-../s    	949pathc                     | dk(  r)t         j                  j                         }t        |      S t	        |       }|j                  dd      5 }t        |      cddd       S # 1 sw Y   yxY w)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readr8   r
   open)r9   r   	file_pathfs       r   	read_yamlrE   A   s^     s{yy~~$4 I	f	- !}  s   A""A+c                     t        |||||      }| dk(  rt        |       yt        | d      }|j                  dd      5 }|j	                  |       ddd       y# 1 sw Y   yxY w)	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)r2   printr
   rB   write)	r9   r   r&   r'   r(   r)   	yaml_datarC   rD   s	            r   
write_yamlrL   O   sm    $ %'#I s{itE:	^^C&^1 	QGGI	 	 	s   AA&objc                 :    	 t        |        y# t        $ r Y y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)r2   r	   )rM   s    r   is_yaml_serializablerO   p   s#    3 s    	)      rP   F)typingr   r   r   ior   r?   ruamel_yamlr   ruamel_yaml.representerr	   utilr
   r   r   r   r   intboolstrr2   r8   rE   rL   rO   r%   r   r   <module>rZ      s   ! !  
  5 = =% %( 
  	
  	0
/U37^ 
/
 
/H  " 

  	
   
B
c 
d 
r   