
    6Ii?                         S SK r S SK Jr  / SQr " S S\5      r " S S\ R
                  5      r " S S	\ R                  5      rS
 r	\R                  \\	5        S rSS jrSS jr
g)    N)	YAMLError)r   	safe_loaddumpadd_representerc                   Z   ^  \ rS rSr% SrSr\S-  \S'   Sr\S-  \S'   SU 4S jjr	Sr
U =r$ )	QuotedString   z>A string that remembers if it was quoted in the original YAML.Nquote_styleblock_stylec                 >   > [         TU ]  X5      nX$l        X4l        U$ N)super__new__r
   r   )clsvaluer
   r   instance	__class__s        :/venv/lib/python3.13/site-packages/keep/functions/cyaml.pyr   QuotedString.__new__   s"    7?3.**     NN)__name__
__module____qualname____firstlineno____doc__r
   str__annotations__r   r   __static_attributes____classcell__r   s   @r   r   r      s,    H"Kt""Kt" r   r   c                   ,   ^  \ rS rSrSrU 4S jrSrU =r$ )QuotePreservingLoader   z=A YAML Loader that marks strings that were originally quoted.c                    > [         TU ]  U5      nUR                  S;   a  [        X!R                  S9$ UR                  S:X  a
  [        USS9$ U$ )N)"')r
   |)r   )r   construct_scalarstyler   )selfnoder   r   s      r   r*   &QuotePreservingLoader.construct_scalar   sM    (. ::#::>>ZZ3377r   r   )r   r   r   r   r   r*   r    r!   r"   s   @r   r$   r$      s    G r   r$   c                   0   ^  \ rS rSrSrSU 4S jjrSrU =r$ )QuotePreservingDumper#   z7A YAML Dumper that preserves quotes for marked strings.c                    > [        U[        5      (       a;  UR                  (       a  UR                  nOUR                  (       a  UR                  n[        TU ]  XU5      $ r   )
isinstancer   r   r
   r   represent_scalar)r,   tagr   r+   r   s       r   r4   &QuotePreservingDumper.represent_scalar&   sJ    e\**  ))""))w'E::r   r   r   )r   r   r   r   r   r4   r    r!   r"   s   @r   r0   r0   #   s    A; ;r   r0   c                 t    UR                   =(       d    UR                  nU R                  S[        U5      US9$ )Nztag:yaml.org,2002:str)r+   )r   r
   r4   r   )dumperdatar+   s      r   represent_quoted_stringr:   1   s5    0 0 0E""#:CIU"SSr   c                 4    [         R                  " U [        S9$ )zFLoad YAML content safely, preserving information about quoted strings.)Loader)yamlloadr$   )streams    r   r   r   7   s    99V$9::r   c                     U=(       d    [         nUR                  SS5        UR                  SS5        [        R                  " X4SU0UD6$ )ap  
Dump YAML data while preserving quotes in strings that were originally quoted.

Args:
    data: The Python object to dump as YAML
    stream: Optional stream to write to (if None, returns a string)
    Dumper: Optional custom YAML dumper class
    **kwds: Additional keyword arguments for yaml.dump
    
Returns:
    The YAML string if stream is None, otherwise None
default_flow_styleF	sort_keysDumper)r0   
setdefaultr=   r   )r9   r?   rC   kwdss       r   r   r   ;   sE     ,,FOO(%0OOK'99T9&9D99r   c                 D    U=(       d    [         nUR                  X5        g)z2Add a custom representer for a specific data type.N)r0   r   )	data_typerepresenterrC   s      r   r   r   N   s    ,,F
92r   r   r   )r=   r   __all__r   r   CSafeLoaderr$   CDumperr0   r:   r   r   r   r   r   r   <module>rL      si      @	3 	D,, ";DLL ;T  % %l4K L;:&3r   