
    Jc                     |   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!ee*e+f         d"e)fd#Z,dHd%ed&e-d"e*fd'Z.d(ed"e)fd)Z/d$d*d%ed(ee*         d&e-d"dfd+Z0d!ee*e+f         d"e)fd,Z1d"e)fd-Z2d.ee*e3f         d"efd/Z4d.ee*e5f         d"efd0Z6d.e*d"efd1Z7d$d$d2d3d.e*d4e-d5e-d6e-d"ef
d7Z8d.e*d"efd8Z9d.e*d"e"fd9Z:d.e*d"efd:Z dId.e*d"efd;Z;dHd<e-d"e!fd=Z<d"efd>Z=d"efd?Z>d@ee*ee*         f         d"efdAZ?d.e*d"efdBZ@dCe*d"eeef         fdDZAdCe*d"e$fdEZBd"e$fdFZCd!e*d"efdGZDdS )J    N)Mapping)IO)Iterable)Tuple)Union   )parse_rfc3339)	Container)UnexpectedCharErrorAoT)Array)Bool)Comment)Date)DateTime)	DottedKey)Float)InlineTable)Integer)Item)Key)	SingleKey)String)
StringType)Table)Time)Trivia
Whitespaceitem)ParserTOMLDocumentstringreturnc                      t          |           S )zF
    Parses a string into a TOMLDocument.

    Alias for parse().
    )parser&   s    +lib/python3.11/site-packages/tomlkit/api.pyloadsr,   $   s     ==    Fdata	sort_keysc                 &   t          | t                    s3t          | t                    rt          t	          |           |          } 	 |                                 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)r.   r/   exmsgs       r+   dumpsr:   -   s     dI&& 6:dG+D+D 6DJJ9555% ~~ % % %Hd4jjHHHnn"$%s   
A 
B(#BBfpc                 D    t          |                                           S )z5
    Load toml document from a file-like object.
    )r)   read)r;   s    r+   loadr>   =   s     r-   r/   c                N    |                     t          | |                     dS )z
    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
    r?   N)writer:   )r.   r;   r/   s      r+   dumprB   D   s)     HHU49---.....r-   c                 D    t          |                                           S )z7
    Parses a string or bytes into a TOMLDocument.
    )r#   r)   r*   s    r+   r)   r)   N   s     &>>!!!r-   c                      t                      S )z.
    Returns a new TOMLDocument instance.
    r$    r-   r+   documentrF   U   s     >>r-   rawc                 :    t          t          |                     S )z/Create an integer item from a number or string.)r"   intrG   s    r+   integerrK   ]   s    C>>r-   c                 :    t          t          |                     S )z-Create an float item from a number or string.)r"   floatrJ   s    r+   float_rN   b   s    c

r-   c                 (    t          | dk              S )z+Turn `true` or `false` into a boolean item.truer!   rJ   s    r+   booleanrQ   g   s    vr-   T)literal	multilineescaperR   rS   rT   c                X    t          j        ||          }t          j        | ||          S )a?  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)rG   rR   rS   rT   type_s        r+   r&   r&   l   s*    ( w	22E?3v...r-   c                     t          |           }t          |t          j                  st	          d          t          |          S )zCreate a TOML date.z!date() only accepts date strings.)r	   r2   	_datetimedate
ValueErrorr"   rG   values     r+   r\   r\      >    #EeY^,, ><===;;r-   c                     t          |           }t          |t          j                  st	          d          t          |          S )zCreate a TOML time.z!time() only accepts time strings.)r	   r2   r[   timer]   r"   r^   s     r+   rb   rb      r`   r-   c                     t          |           }t          |t          j                  st	          d          t          |          S )zCreate a TOML datetime.z)datetime() only accepts datetime strings.)r	   r2   r[   datetimer]   r"   r^   s     r+   rd   rd      s@    #EeY/00 FDEEE;;r-   c                 (    | d} 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]
    Nz[])r_   rJ   s    r+   arrayrf      s      ::r-   is_super_tablec                 V    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   )rg   s    r+   tableri      s     " fhh~>>>r-   c                  V    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{{FHH$77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     r77Nr-   kc                 |    t          | t                    rt          |           S t          d | D                       S )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
    c                 ,    g | ]}t          |          S rE   )key).0_ks     r+   
<listcomp>zkey.<locals>.<listcomp>   s    ***"c"gg***r-   )r2   strr   r   )ro   s    r+   rr   rr      s?     !S ||*****+++r-   c                     t          |           }|                                }|                                s!|                    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)rG   parservs      r+   r_   r_      sR     C[[FA::<< L  !46? KKKHr-   srcc                 D    t          |                                           S )zkParse a key-value pair from a string.

    :Example:

    >>> key_value("foo = 1")
    (Key('foo'), 1)
    )r#   _parse_key_valuer   s    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    d88Or-   c                 D    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AABBBr-   )F)N)Erd   r[   collections.abcr   typingr   r   r   r   _utilsr	   	containerr
   
exceptionsr   itemsr   r   r   r   r   r   r   r   r   r   r   _Itemr   r   r   r   rV   r   r   r   r    r"   r}   r#   toml_documentr%   rv   bytesr,   boolr:   r>   rB   r)   rF   rI   rK   rM   rN   rQ   r&   r\   rb   rf   ri   rl   rn   rr   r_   r   r   r   r   rE   r-   r+   <module>r      s       # # # # # #                         ! ! ! ! ! !             + + + + + +                                                                                           , , , , , ,                                     ' ' ' ' ' '%U
#     % % %D %S % % % % R L     ;@ / / /w /BsG /4 /D / / / /"%U
# " " " " ",    sCx W    
c5j! e    
      / / /	/ / 	/
 / / / / /0c d    c d    # (     s e    $? ?$ ?5 ? ? ? ?(
8k 
8 
8 
8 
8S     ,5hsm#$ , , , , ,$s u    &*3 *5e, * * * *'C 'J ' ' ' '
J    
CC CG C C C C C Cr-   