
    h                        S SK JrJrJr  S SKJr  S SKrSSKJr  SSK	J
r
  SSKJrJrJrJr   " S S	\5      r    SS
\S\S\S\S\S\4S jjrS
\\\4   S\4S jrS\S\4S jr    SS\S
\S\S\S\S\SS4S jjrS\S\4S jrg)    )UnionIOAny)StringION   )YAML)RepresenterError)
force_pathFilePath	YAMLInput
YAMLOutputc                   (    \ rS rSrSS jrSS jrSrg)
CustomYaml
   c                 X    [         R                  " XUS9  SU l        SU l        SU l        g )N)typpureFTzutf-8)r   __init__default_flow_styleallow_unicodeencoding)selfr   r   s      I/home/james-whalen/.local/lib/python3.13/site-packages/srsly/_yaml_api.pyr   CustomYaml.__init__   s'    d$/"'!    Nc                     SnUc  Sn[        5       n[        R                  " XU40 UD6  U(       a  UR                  5       $ g )NFT)r   r   dumpgetvalue)r   datastreamkwinefficients        r   r   CustomYaml.dump   s@    >KZF		$f++??$$ r   )r   r   r   )safeT)N)__name__
__module____qualname____firstlineno__r   r   __static_attributes__ r   r   r   r   
   s     %r   r   r   indent_mappingindent_sequenceindent_offset	sort_keysreturnc                 d    [        5       nXEl        UR                  XUS9  UR                  U 5      $ )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_dumpsr7      s/    $ <D,5)KKKW99T?r   c                 z    [        5       n UR                  U 5      $ ! [         a  n[        SU 35      eSnAff = f)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   r6   es      r   
yaml_loadsr=   4   s@     <D/yy />!-../s    
:5:pathc                     U S:X  a)  [         R                  R                  5       n[        U5      $ [	        U 5      nUR                  SSS9 n[        U5      sSSS5        $ ! , (       d  f       g= f)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_yamlrJ   A   sU     s{yy~~$4 I	f	-!} 
.	-	-s   A  
A.c                     [        UUUUUS9nU S:X  a  [        U5        g[        U SS9nUR                  SSS9 nUR	                  U5        SSS5        g! , (       d  f       g= f)	ad  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wrB   rC   N)r7   printr
   rG   write)	r>   r   r+   r,   r-   r.   	yaml_datarH   rI   s	            r   
write_yamlrQ   O   sd    $ %'#I s{itE:	^^C&^1QGGI 211s   A
A#objc                 <     [        U 5        g! [         a     gf = f)zCheck if a Python object is YAML-serializable (strict).

obj: The object to check.
RETURNS (bool): Whether the object is YAML-serializable.
TF)r7   r	   )rR   s    r   is_yaml_serializablerT   p   s#    3 s    
)      rU   F)typingr   r   r   ior   rD   ruamel_yamlr   ruamel_yaml.representerr	   utilr
   r   r   r   r   intboolstrr7   r=   rJ   rQ   rT   r*   r   r   <module>r_      s   ! !  
  5 = =% %( 
  	
  	0
/U37^ 
/
 
/H  " 

  	
   
B
c 
d 
r   