
    .Ph                        d dl mZ d dlmZ d dlmZ d dlmZ d dlmZ d dlm	Z	  G d d          Z
 G d	 d
          Z G d de          ZdS )    )annotations)copy)Any)
ParseError)UnexpectedCharErrorTOMLCharc                  *    e Zd Z	 	 ddd	Zdd
Zd ZdS )_StateFsourceSourcesave_markerbool | NonerestorereturnNonec                0    || _         || _        || _        d S N)_source_save_markerr   )selfr   r   r   s       N/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/tomlkit/source.py__init__z_State.__init__   s     '    c                    t          | j        j                  | _        | j        j        | _        | j        j        | _        | j        j        | _        | S r   )r   r   _chars_idx_current_markerr   s    r   	__enter__z_State.__enter__   s?    4<.//L%	-|+r   c                    | j         s|rO| j        | j        _        | j        | j        _        | j        | j        _        | j        r| j        | j        _        d S d S d S r   )r   r   r   r   r   r   r   )r   exception_typeexception_valtraces       r   __exit__z_State.__exit__   sh    < 	4> 	4"&+DL $	DL$(MDL!  4'+|$$$4 4		4 	4r   N)FF)r   r   r   r   r   r   r   r   r   r   )__name__
__module____qualname__r   r!   r&    r   r   r   r      sX         $)$	       4 4 4 4 4r   r   c                  .    e Zd ZdZddZd Zdd	Zd
 ZdS )_StateHandlerz)
    State preserver for the Parser.
    r   r   r   r   c                "    || _         g | _        d S r   )r   _states)r   r   s     r   r   z_StateHandler.__init__.   s    r   c                ,    t          | j        g|R i |S r   )r   r   )r   argskwargss      r   __call__z_StateHandler.__call__2   s"    dl4T444V444r   r   c                r     |             }| j                             |           |                                S r   )r/   appendr!   )r   states     r   r!   z_StateHandler.__enter__5   s3    E"""   r   c                b    | j                                         }|                    |||          S r   )r/   popr&   )r   r#   r$   r%   r6   s        r   r&   z_StateHandler.__exit__:   s+      ""~~nmUCCCr   N)r   r   r   r   r'   )r(   r)   r*   __doc__r   r3   r!   r&   r+   r   r   r-   r-   )   si            5 5 5! ! ! !
D D D D Dr   r-   c                       e Zd Z ed          Zd$ fdZd Zed%d	            Zed&d            Z	ed'd            Z
ed&d            Zd(dZd)d*dZd)d+dZd,dZd-dZd.dZefd/d!Zd0d#Z xZS )1r    _strr   r   c                2   t                                                       t          d t          |           D                       | _        d| _        d| _        t          d          | _        t          |           | _
        |                                  d S )Nc                6    g | ]\  }}|t          |          fS r+   r   ).0ics      r   
<listcomp>z#Source.__init__.<locals>.<listcomp>F   s'    IIIAQ,IIIr   r    )superr   iter	enumerater   r   r   r	   r   r-   _stateinc)r   r<   	__class__s     r   r   zSource.__init__B   sz     II4IIIJJ	 #D))




r   c                V    |                                   |                                  d S r   )rI   markr    s    r   resetzSource.resetP   s"    


 			r   r-   c                    | j         S r   )rH   r    s    r   r6   zSource.stateW   s
    {r   intc                    | j         S r   )r   r    s    r   idxz
Source.idx[   s
    yr   r	   c                    | j         S r   )r   r    s    r   currentzSource.current_   s
    }r   c                    | j         S r   )r   r    s    r   markerzSource.markerc   s
    |r   c                *    | | j         | j                 S )z=
        Extracts the value between marker and index
        )r   r   r    s    r   extractzSource.extractg   s     DL49,--r   N	exceptiontype[ParseError] | Noneboolc                    	 t          | j                  \  | _        | _        dS # t          $ r< t          |           | _        | j        | _        |r|                     |          dY dS w xY w)z
        Increments the parser if the end of the input has not been reached.
        Returns whether or not it was able to advance.
        TNF)nextr   r   r   StopIterationlenEOFparse_error)r   rX   s     r   rI   z
Source.incm   sz    

	'+DK'8'8$DIt}4 	 	 	D		DI HDM <&&y11t;55	s   !% AA+*A+nc                X     t           fdt          |          D                       S )zm
        Increments the parser by n characters
        if the end of the input has not been reached.
        c              3  D   K   | ]}                                V  dS ))rX   N)rI   )r@   r<   rX   r   s     r   	<genexpr>zSource.inc_n.<locals>.<genexpr>   s1      CCQ488i800CCCCCCr   )allrange)r   ra   rX   s   ` `r   inc_nzSource.inc_n~   s2    
 CCCCC%((CCCCCCr   r   c                    | j         |v r4|dk    r.|dz  }|dz  }|                                 sn| j         |v r|dk    .|dk    r |                     t          | j                   dS )zD
        Consume chars until min/max is satisfied is valid.
        r      N)rS   rI   r`   r   )r   charsminmaxs       r   consumezSource.consume   s     le##q1HC1HC88:: 	 le##q 77""#6EEE 7r   c                    | j         | j        u S )zN
        Returns True if the parser has reached the end of the input.
        )r   r_   r    s    r   endz
Source.end   s     }((r   c                    | j         | _        dS )zA
        Sets the marker to the index's current position
        N)r   r   r    s    r   rL   zSource.mark   s     yr   type[ParseError]r1   r   r2   r   c                J    |                                  \  }} |||g|R i |S )zJ
        Creates a generic "parse error" at the current position.
        )_to_linecol)r   rX   r1   r2   linecols         r   r`   zSource.parse_error   s;     $$&&	cys4T444V444r   tuple[int, int]c                "   d}t          |                                           D ]I\  }}|t          |          z   dz   | j        k    r|dz   | j        |z
  fc S |t          |          dz   z  }Jt          |                                           dfS )Nr   rj   )rG   
splitlinesr^   rQ   )r   currA   ru   s       r   rt   zSource._to_linecol   s     !2!233 	! 	!GAtSYY"TX--Atx#~....3t99q= CC4??$$%%q((r   )r<   r=   r   r   )r   r-   )r   rO   )r   r	   )r   r=   r   )rX   rY   r   rZ   )ra   rO   rX   rY   r   rZ   )r   rh   )r   rZ   )r   r   )rX   rr   r1   r   r2   r   r   r   )r   rw   )r(   r)   r*   r	   r_   r   rM   propertyr6   rQ   rS   rU   rW   rI   rg   rn   rp   rL   r   r`   rt   __classcell__)rJ   s   @r   r   r   ?   s       
(4..C           X    X    X    X. . . .    "D D D D DF F F F) ) ) )! ! ! ! '15 5 5 5 5) ) ) ) ) ) ) )r   r   N)
__future__r   r   typingr   tomlkit.exceptionsr   r   tomlkit.toml_charr	   r   r-   r=   r   r+   r   r   <module>r      s   " " " " " "             ) ) ) ) ) ) 2 2 2 2 2 2 & & & & & &4 4 4 4 4 4 4 4<D D D D D D D D,u) u) u) u) u)S u) u) u) u) u)r   