
    v;3hS                       d dl mZ d dlZd dl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 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 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 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" 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) d d l*m+Z+ d d!l,m-Z- dAd"Z.dBdCd$Z/dDd%Z0d#d&dEd'Z1dAd(Z2dFd)Z3dGd*Z4dHd+Z5dId,Z6d#d#d-d.	 	 	 	 	 	 	 	 	 dJd/Z7dKd0Z8dLd1Z9dMd2ZdNdOd3Z:dPdQd4Z;dRd5Z<dSd6Z=dTd7Z>dUd8Z?dVd9Z@dWd:ZAdXd;ZBdYd<ZC e
d=e>      ZDdZd?ZEd[d@ZFy)\    )annotationsN)Mapping)IO)Iterable)TypeVar)parse_rfc3339)	Container)UnexpectedCharError)CUSTOM_ENCODERSAoT)Array)Bool)Comment)Date)DateTime)	DottedKey)Encoder)Float)InlineTable)Integer)Item)Key)	SingleKey)String)
StringType)Table)Time)Trivia
Whitespaceitem)ParserTOMLDocumentc                    t        |       S )zF
    Parses a string into a TOMLDocument.

    Alias for parse().
    )parsestrings    K/var/www/html/audio-gradio/venv/lib/python3.12/site-packages/tomlkit/api.pyloadsr,   (   s     =    Fc                    t        | t              s&t        | t              rt        t	        |       |      } 	 | j                         S # t        $ r }dt        |        d}t        |      |d}~ww xY w)z-
    Dumps a TOMLDocument into a string.
    )
_sort_keysz%Expecting Mapping or TOML Container, z givenN)	
isinstancer	   r   r#   dict	as_stringAttributeErrortype	TypeError)data	sort_keysexmsgs       r+   dumpsr:   1   si     dI&:dG+DDJ95% ~~ %5d4j\Hn"$%s   A 	A1A,,A1c                4    t        | j                               S )z5
    Load toml document from a file-like object.
    )r(   read)fps    r+   loadr>   A   s     r-   r7   c               <    |j                  t        | |             y)a  
    Dump a TOMLDocument into a writable file stream.

    :param data: a dict-like object to dump
    :param sort_keys: if true, sort the keys in alphabetic order

    :Example:

    >>> with open("output.toml", "w") as fp:
    ...     tomlkit.dump(data, fp)
    r?   N)writer:   )r6   r=   r7   s      r+   dumprB   H   s     HHU49-.r-   c                4    t        |       j                         S )z7
    Parses a string or bytes into a TOMLDocument.
    )r$   r(   r)   s    r+   r(   r(   W   s     &>!!r-   c                     t               S )z.
    Returns a new TOMLDocument instance.
    r%    r-   r+   documentrF   ^   s     >r-   c                *    t        t        |             S )z/Create an integer item from a number or string.)r#   intraws    r+   integerrK   f   s    C>r-   c                *    t        t        |             S )z-Create an float item from a number or string.)r#   floatrI   s    r+   float_rN   k   s    c
r-   c                    t        | dk(        S )z+Turn `true` or `false` into a boolean item.truer"   rI   s    r+   booleanrQ   p   s    vr-   T)literal	multilineescapec               \    t        j                  ||      }t        j                  | ||      S )aB  Create a string item.

    By default, this function will create *single line basic* strings, but
    boolean flags (e.g. ``literal=True`` and/or ``multiline=True``)
    can be used for personalization.

    For more information, please check the spec: `<https://toml.io/en/v1.0.0#string>`__.

    Common escaping rules will be applied for basic strings.
    This can be controlled by explicitly setting ``escape=False``.
    Please note that, if you disable escaping, you will have to make sure that
    the given strings don't contain any forbidden character or sequence.
    )_StringTypeselectr   from_raw)rJ   rR   rS   rT   type_s        r+   r*   r*   u   s)    ( w	2E??3v..r-   c                x    t        |       }t        |t        j                        st	        d      t        |      S )zCreate a TOML date.z!date() only accepts date strings.)r   r0   	_datetimedate
ValueErrorr#   rJ   values     r+   r\   r\      0    #EeY^^,<==;r-   c                x    t        |       }t        |t        j                        st	        d      t        |      S )zCreate a TOML time.z!time() only accepts time strings.)r   r0   r[   timer]   r#   r^   s     r+   rb   rb      r`   r-   c                x    t        |       }t        |t        j                        st	        d      t        |      S )zCreate a TOML datetime.z)datetime() only accepts datetime strings.)r   r0   r[   datetimer]   r#   r^   s     r+   rd   rd      s2    #EeY//0DEE;r-   c                    t        |       S )zCreate an array item for its string representation.

    :Example:

    >>> array("[1, 2, 3]")  # Create from a string
    [1, 2, 3]
    >>> a = array()
    >>> a.extend([1, 2, 3])  # Create from a list
    >>> a
    [1, 2, 3]
    )r_   rI   s    r+   arrayrf      s     :r-   c                >    t        t               t               d|       S )aF  Create an empty table.

    :param is_super_table: if true, the table is a super table

    :Example:

    >>> doc = document()
    >>> foo = table(True)
    >>> bar = table()
    >>> bar.update({'x': 1})
    >>> foo.append('bar', bar)
    >>> doc.append('foo', foo)
    >>> print(doc.as_string())
    [foo.bar]
    x = 1
    F)r   r	   r   )is_super_tables    r+   tableri      s    " fh~>>r-   c                 >    t        t               t               d      S )zCreate an inline table.

    :Example:

    >>> table = inline_table()
    >>> table.update({'x': 1, 'y': 2})
    >>> print(table.as_string())
    {x = 1, y = 2}
    T)new)r   r	   r   rE   r-   r+   inline_tablerl      s     y{FH$77r-   c                     t        g       S )zCreate an array of table.

    :Example:

    >>> doc = document()
    >>> aot = aot()
    >>> aot.append(item({'x': 1}))
    >>> doc.append('foo', aot)
    >>> print(doc.as_string())
    [[foo]]
    x = 1
    r   rE   r-   r+   aotrn      s     r7Nr-   c                    t        | t              rt        |       S t        | D cg c]  }t	        |       c}      S c c}w )a  Create a key from a string. When a list of string is given,
    it will create a dotted key.

    :Example:

    >>> doc = document()
    >>> doc.append(key('foo'), 1)
    >>> doc.append(key(['bar', 'baz']), 2)
    >>> print(doc.as_string())
    foo = 1
    bar.baz = 2
    )r0   strr   r   key)k_ks     r+   rq   rq      s5     !S|*"c"g*++*s   >c                    t        |       }|j                         }|j                         s!|j                  t        |j
                        |S )zParse a simple value from a string.

    :Example:

    >>> value("1")
    1
    >>> value("true")
    True
    >>> value("[1, 2, 3]")
    [1, 2, 3]
    )char)r$   _parse_valueendparse_errorr
   _current)rJ   parservs      r+   r_   r_      sD     C[FA::<  !46?? KKHr-   c                4    t        |       j                         S )zkParse a key-value pair from a string.

    :Example:

    >>> key_value("foo = 1")
    (Key('foo'), 1)
    )r$   _parse_key_valuesrcs    r+   	key_valuer     s     #;''))r-   c                    t        | d      S )z"Create a whitespace from a string.T)fixedr    r~   s    r+   wsr     s    c&&r-   c                     t        d      S )zCreate a newline item.
)r   rE   r-   r+   nlr     s    d8Or-   c                4    t        t        dd| z               S )zCreate a comment item.z  z# )
comment_wscomment)r   r   r)   s    r+   r   r   "  s    6T4&=ABBr-   E)boundc                0    t        j                  |        | S )zAdd a custom encoder, which should be a function that will be called
    if the value can't otherwise be converted. It should takes a single value
    and return a TOMLKit item or raise a ``TypeError``.
    )r   appendencoders    r+   register_encoderr   *  s    
 7#Nr-   c                    t        j                  t              5  t        j                  |        ddd       y# 1 sw Y   yxY w)zUnregister a custom encoder.N)
contextlibsuppressr]   r   remover   s    r+   unregister_encoderr   3  s3    			Z	( (w'( ( (s	   9A)r*   zstr | bytesreturnr&   )F)r6   r   r7   boolr   rp   )r=   zIO[str] | IO[bytes]r   r&   )r6   r   r=   zIO[str]r7   r   r   None)r   r&   )rJ   z	str | intr   r   )rJ   zstr | floatr   r   )rJ   rp   r   r   )
rJ   rp   rR   r   rS   r   rT   r   r   r   )rJ   rp   r   r   )rJ   rp   r   r   )rJ   rp   r   r   )z[])rJ   rp   r   r   )N)rh   zbool | Noner   r   )r   r   )r   r   )rr   zstr | Iterable[str]r   r   )rJ   rp   r   _Item)r   rp   r   ztuple[Key, _Item])r   rp   r   r!   )r   r!   )r*   rp   r   r   )r   r   r   r   )r   r   r   r   )G
__future__r   r   rd   r[   collections.abcr   typingr   r   r   tomlkit._utilsr   tomlkit.containerr	   tomlkit.exceptionsr
   tomlkit.itemsr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rV   r   r   r   r!   r#   tomlkit.parserr$   tomlkit.toml_documentr&   r,   r:   r>   rB   r(   rF   rK   rN   rQ   r*   r\   rb   rf   ri   rl   rn   rq   r_   r   r   r   r   r   r   r   rE   r-   r+   <module>r      s8   "   #    ( ' 2 )    !  " # !  % ! '  #   3     $  ! .%  ;@ /"

 /	/ / 	/
 / /0?(
8 ,$&*'

C
 Cw(r-   