
    rZhb
                         d dl Z d dlmZmZ d dlmZ d dlmZmZm	Z	m
Z
mZmZ d dlmZ d dlmZ d dlmZ  G d dej(                        Z e       Zy)	    N)StringIOTextIOWrapper)Path)AnyCallableListOptionalTextUnion)open)CommentedMapc                        e Zd Zddddddedeeee   ef      dededed	df fd
Zdee	e
ef   d	ef fdZee	e
ef   fdddeded	df fdZ xZS )TAMLNFtyppureoutputplug_insselfr   r   r   r   returnc                T    t         |   ||||       | j                  ddd       y)a  
		typ: 'rt'/None -> RoundTripLoader/RoundTripDumper,  (default)
			'safe'    -> SafeLoader/SafeDumper,
			'unsafe'  -> normal/unsafe Loader/Dumper (pending deprecation)
			'full'    -> full Dumper only, including python built-ins that are potentially unsafe to load
			'base'    -> baseloader
		pure: if True only use Python modules
		input/output: needed to work as context manager
		plug_ins: a list of plug-in files
		r      )mappingsequenceoffsetN)super__init__indent)r   r   r   r   r   	__class__s        X/mounts/lovelace/software/anaconda3/envs/py312/lib/python3.12/site-packages/taml/main.pyr   zTAML.__init__   s-     'sfxH++a!A+.    streamc                 `   t        |t        t        f      r&t        |d      5 }|j	                         }ddd       n't        |t
              r|j	                         }nt        t        j                  dd       }t        | )  t        dj                  |                  S # 1 sw Y   HxY w)a  
		at this point you either have the non-pure Parser (which has its own reader and
		scanner) or you have the pure Parser.
		If the pure Parser is set, then set the Reader and Scanner, if not already set.
		If either the Scanner or Reader are set, you cannot use the non-pure Parser,
			so reset it to the pure parser and set the Reader resp. Scanner if necessary

		this description was copied from ruamel.yaml
		rNz(?<=\n)(\t+)c                 <    dt        | j                  d            z  S )Nz     lengroupmatchs    r    <lambda>zTAML.load.<locals>.<lambda>/   s    tc%++a.6I/I r!    )
isinstancestrr   r   readr   	TypeErrorresubr   loadr   join)r   r"   ffiler   s       r    r4   z	TAML.load   s     d$VS Q668D &-(
++-4	? 
!I4	P$	hrwwt}-	.. s   B$$B-	transformr9   c                    t               }| j                  dk7  s| j                  dk7  s| j                  dk7  rt	        d       t
        |   |||       |j                  d       |j                         }t        j                  dd |      }t        |t        t        f      r't        |d      5 }|j                  |       d d d        y t        |t               r|j                  |       y t"        # 1 sw Y   y xY w)Nr   z8warning: changing indentation may cause this to not workr8   r   z(?<=\n)( {2})+c                 B    dt        | j                  d            dz  z  S )N	r   r   r'   r*   s    r    r,   zTAML.dump.<locals>.<lambda>?   s    EKKN8Kq8P0Q r!   w)r   
map_indentsequence_indentsequence_dash_offsetprintr   dumpseekr0   r2   r3   r.   r/   r   r   writer   r1   )r   datar"   r9   tmpr6   r   s         r    rB   z	TAML.dump3   s    
# 
__T11Q6$:S:SWX:X	CD',tSI,.((1+ 	
#
 "QSVW# d$VS QGGCL &-(	<<	? s   1C44C=)__name__
__module____qualname__r   r	   r   r   r
   r   r/   r   r   r   r4   r   rB   __classcell__)r   s   @r    r   r      s    EIW\lp  CG /C /%T
D0@*A!B /QT /fi /| /  LP / /c467 /L /. %*#t]*B$C ^b c S[ gk  r!   r   )r2   ior   r   pathlibr   typingr   r   r   r	   r
   r   ruamel.yamlyamlraml	epicstuffr   ruamel.yaml.commentsr   YAMLr   taml r!   r    <module>rV      s7    	 &  = =   -=499 =@ vr!   