o
    tfPU                     @   s*  d dl Z d dlZd dlmZmZmZmZmZmZm	Z	m
Z
mZ d dlZddlmZ ddddddddddedee d	dd
eeeeef gef  deeegef  deeegef  deeegef  deeee
eef  gef  dedefddZddddddddddedee d	dd
eeeeef gef  deeegef  deeegef  deeegef  deeee
eef  gef  defddZdd Zdeee
eef  gef fddZddddddddddddddedededed ed!ed	dd"eeeef  d#ee
eef  d$eeegef  d%ed&ed'edefd(d)Zddddddddddddddededed ed!ed	dd"eeeef  d#ee
eef  d$eeegef  d%ed&ed'edefd*d+Zd,ee	e  d-ed.efd/d0Zd1d2 Zd3d4 Zd5d6 Zd7d8 Zd9d: Zd;d< Zdad=d> Z d?d@ Z!dS )A    N)	AnyCallableIOIterableMappingOptionalSetTupleUnion   )ParserTencodingclsobject_hookparse_float	parse_intparse_constantobject_pairs_hookallow_duplicate_keysfpr   r   r   r   r   r   r   r   returnc          
      C   s"   |   }	t|	||||||||d	S )a  Deserialize ``fp`` (a ``.read()``-supporting file-like object
    containing a JSON document) to a Python object.

    Supports almost the same arguments as ``json.load()`` except that:
        - the `cls` keyword is ignored.
        - an extra `allow_duplicate_keys` parameter supports checking for
          duplicate keys in a object; by default, this is True for
          compatibility with ``json.load()``, but if set to False and
          the object contains duplicate keys, a ValueError will be raised.
    r   )readloads)
r   r   r   r   r   r   r   r   r   s r   R/var/www/html/software/conda/envs/catlas/lib/python3.10/site-packages/json5/lib.pyload!   s   r   r   c                   s   |du sJ dt | tr|pd}| |} | stdt| d}	|	 \}
}}|r.t|dd }|r7|}nr@fdd	}nt}|sL|  fd
d	}|pOt}|pSt}|pW|}t	|
||||S )a  Deserialize ``s`` (a string containing a JSON5 document) to a Python
    object.

    Supports the same arguments as ``json.load()`` except that:
        - the `cls` keyword is ignored.
        - an extra `allow_duplicate_keys` parameter supports checking for
          duplicate keys in a object; by default, this is True for
          compatibility with ``json.load()``, but if set to False and
          the object contains duplicate keys, a ValueError will be raised.
    Nz!Custom decoders are not supportedzutf-8z!Empty strings are not legal JSON5z<string>c                 S   s   t | ddddS )NInfinityinfNaNnan)floatreplace)r   r   r   r   _fp_constant_parsern   s   z"loads.<locals>._fp_constant_parserc                    s    t | S N)dictpairs)r   r   r   dictifyu   s   zloads.<locals>.dictifyc                    s
   t |  S r%   )_reject_duplicate_keysr'   )_orig_dictifyr   r   r)   }   s   
)

isinstancebytesdecode
ValueErrorr   parser&   r"   int	_walk_ast)r   r   r   r   r   r   r   r   r   parserasterr_r$   r)   r   )r+   r   r   r   H   s.   


r   c                 C   s>   t  }| D ]\}}||v rtd| d|| q|| S )NzDuplicate key "z" found in object)setr/   add)r(   r)   keyskeyr6   r   r   r   r*      s   r*   r)   c                    s  | dkrd S | dkrdS | dkrdS | \}}|dkrJ| ds$| dr*|d	d
S d|v s6d|v s6d|v r:|S d|v sBd|v rF|S |S |dkrP|S |dkrpg }|D ]\}}	t|	 }
|||
f qX |S |dkr fdd|D S td|  )NNoneTrueTFalseFnumber0x0X   )base.eEr   r    stringobjectarrayc                    s   g | ]
}t | qS r   )r2   .0elr)   r   r   r   r   r   
<listcomp>   s    z_walk_ast.<locals>.<listcomp>zunknown el: )
startswithr2   appendr/   )rK   r)   r   r   r   tyvr(   r:   Zval_exprvalr   rL   r   r2      s<   
r2   F)skipkeysensure_asciicheck_circular	allow_nanr   indent
separatorsdefault	sort_keys
quote_keystrailing_commasr   objrS   rT   rU   rV   rW   rX   rY   rZ   r[   r\   c                K   s.   ~| t| ||||||||	|
|||d dS )a  Serialize ``obj`` to a JSON5-formatted stream to ``fp``,
    a ``.write()``-supporting file-like object.

    Supports the same arguments as ``json.dump()``, except that:

    - The ``cls`` keyword is not supported.
    - The ``encoding`` keyword is ignored; Unicode strings are always
      written.
    - By default, object keys that are legal identifiers are not quoted;
      if you pass ``quote_keys=True``, they will be.
    - By default, if lists and objects span multiple lines of output (i.e.,
      when ``indent`` >=0), the last item will have a trailing comma
      after it. If you pass ``trailing_commas=False``, it will not.
    - If you use a number, a boolean, or ``None`` as a key value in a dict,
      it will be converted to the corresponding JSON string value, e.g.
      "1", "true", or "null". By default, ``dump()`` will match the `json`
      modules behavior and produce malformed JSON if you mix keys of
      different types that have the same converted value; e.g.,
      ``{1: "foo", "1": "bar"}`` produces '{"1": "foo", "1": "bar"}', an
      object with duplicated keys. If you pass
      ``allow_duplicate_keys=False``, an exception will be raised instead.
    - If `quote_keys` is true, then keys of objects will be enclosed in
      quotes, as in regular JSON. Otherwise, keys will not be enclosed in
      quotes unless they contain whitespace.
    - If `trailing_commas` is false, then commas will not be inserted after
      the final elements of objects and arrays, as in regular JSON.
      Otherwise, such commas will be inserted.
    - If `allow_duplicate_keys` is false, then only the last entry with a
      given key will be written. Otherwise, all entries with the same key
      will be written.

    Calling ``dump(obj, fp, quote_keys=True, trailing_commas=False,                    allow_duplicate_keys=True)``
    should produce exactly the same output as ``json.dump(obj, fp).``
    )r]   rS   rT   rU   rV   r   rW   rX   rY   rZ   r[   r\   r   N)writedumps)r]   r   rS   rT   rU   rV   r   rW   rX   rY   rZ   r[   r\   r   kwargsr   r   r   dump   s$   6ra   c                K   s   | dddu sJ d~|du r|du rd}nd}|pt}|r$t }nd}d}d}t| ||||||||	|
|||||\}}|S )aQ  Serialize ``obj`` to a JSON5-formatted string.

    Supports the same arguments as ``json.dumps()``, except that:

    - The ``cls`` keyword is not supported.
    - The ``encoding`` keyword is ignored; Unicode strings are always
      written.
    - By default, object keys that are legal identifiers are not quoted;
      if you pass ``quote_keys=True``, they will be.
    - By default, if lists and objects span multiple lines of output (i.e.,
      when ``indent`` >=0), the last item will have a trailing comma
      after it. If you pass ``trailing_commas=False``, it will not.
    - If you use a number, a boolean, or ``None`` as a key value in a dict,
      it will be converted to the corresponding JSON string value, e.g.
      "1", "true", or "null". By default, ``dump()`` will match the `json`
      modules behavior and produce malformed JSON if you mix keys of
      different types that have the same converted value; e.g.,
      ``{1: "foo", "1": "bar"}`` produces '{"1": "foo", "1": "bar"}', an
      object with duplicated keys. If you pass
      ``allow_duplicate_keys=False``, an exception will be raised instead.
    - If `quote_keys` is true, then keys of objects will be enclosed
      in quotes, as in regular JSON. Otheriwse, keys will not be enclosed
      in quotes unless they contain whitespace.
    - If `trailing_commas` is false, then commas will not be inserted after
      the final elements of objects and arrays, as in regular JSON.
      Otherwise, such commas will be inserted.
    - If `allow_duplicate_keys` is false, then only the last entry with a
      given key will be written. Otherwise, all entries with the same key
      will be written.

    Calling ``dumps(obj, quote_keys=True, trailing_commas=False,                     allow_duplicate_keys=True)``
    should produce exactly the same output as ``json.dumps(obj).``
    r   Nz!Custom encoders are not supported)z, : ),rb   r   F)get_raise_type_errorr7   _dumps)r]   rS   rT   rU   rV   r   rW   rX   rY   rZ   r[   r\   r   r`   seenlevelis_keyr6   rQ   r   r   r   r_     s<   4r_   rg   rh   ri   c                 C   s  | du rd}np| du rd}ni| d u rd}nb| t dkr#|r d}nWt | t dkr1|r.d	}nIt t| t rCt| rC|r@d
}n7t t| tr_|rXt| rX|	sXt| sXd| fS dt| |fS t| t	rjt	
| }nt| t rut 
| }nd }|r|d urdd| dfS |rdS tdt|  |d urd|fS |d urd}|
rd}t|t	r|dkrdd| |  }|dd| |d   7 }nd}|d7 }nd||  }|d||d   7 }nd}d}|\}}||7 }|d urt| }||v rtd|| t| drt| drt| |||||||||	|
|||d ||||}n9t| drBt| drBt| |||||||||	|
|||d |||}nt|| |||||||||	|
||||d }|d urb|| d|fS )NTtrueFfalsenullr   r   z-infz	-Infinityr    ")FNzinvalid key  rc   r   
 r   zCircular reference detected.r9   __getitem____iter__)r"   r/   r,   mathisnanstr	_is_ident_is_reserved_word	_dump_strr1   __repr__	TypeErrorrepridr8   hasattr
_dump_dict_dump_arrayrf   remove)r]   rS   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r   rg   rh   ri   r   end_str
indent_stritem_sepkv_sepir   r   r   rf   ]  s   







rf   c                 C   s   | sdS |rt |  }n|  }d| }d}t }|D ]W}t||||||||||	|
|||dd\}}|r8|s8q|sL||v rGtdt| || |rR||7 }||| t| | |||||||||	|
|||ddd  7 }|d7 }q||d	 7 }|S )
Nz{}{r   T)ri   zduplicate key Fr   })sortedr9   r7   rf   r/   r{   r8   )r]   rS   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r   rg   rh   r   r   r   r   r9   r   Znum_items_addedZnew_keysr:   Z	valid_keyZkey_strr   r   r   r~     s|   


r~   c                    sH   | sdS d| |  	
fdd| D  | d S )Nz[][c                    s4   g | ]}t |
	 d d qS )Fr   )rf   rI   r   rV   rU   rY   rT   rW   rh   r[   rg   rX   rS   rZ   r\   r   r   rM   u  s,    z_dump_array.<locals>.<listcomp>])join)r]   rS   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r   rg   rh   r   r   r   r   r   r   r   \  s    "r   c                 C   s  dg}| D ]}|dkr| d q|dkr| d q|dkr%| d q|dkr/| d q|d	kr9| d
 q|dkrC| d q|dkrM| d q|dkrW| d q|dkra| d q|dkrk| d q|dkru| d q|s}| | qt|}d|  krdk rn n| | q|dk r| d|d q|d }d|d?  }d|d@  }| d|dd|d qd |d S )!Nrm   \z\\z\"u    z\u2028u    z\u2029ro   z\nz\rz\bz\f	z\tz\v z\0       i   z\uZ04xi   
   i   i  rn   )rO   ordr   )r]   rT   retchorR   highlowr   r   r   rx     sH   rx   c                 C   sL   | rt | d s| d dvrdS | dd  D ]}t|s#|dvr# dS qdS )Nr   )$r6   Fr   T)_is_id_start_is_id_continue)kr   r   r   r   rv     s   rv   c                 C      t | dv S )N)LuLlLiLtLmLoNlunicodedatacategoryr   r   r   r   r        r   c                 C   r   )N)r   r   r   r   r   r   r   ZNdZMnZMcZPcr   r   r   r   r   r     r   r   c                 C   s2   t d u rtddg d d a t | d uS )N(|)$breakcaseZcatchclassconstcontinueZdebuggerrY   deletedoelseenumZexportZextendsrk   finallyforfunctionifimportinZ
instanceofnewrl   r   superswitchthisthrowrj   tryZtypeofvarvoidwhilewithz)$)_reserved_word_rerecompiler   match)r   r   r   r   rw     s   ),rw   c                 C   s   t t|  d)Nz is not JSON5 serializable)rz   r{   )r]   r   r   r   re     s   re   )"rs   r   typingr   r   r   r   r   r   r   r	   r
   r   r3   r   ru   boolr   r   r*   r2   r1   ra   r_   rf   r~   r   rx   rv   r   r   r   rw   re   r   r   r   r   <module>   sL  ,	
*	
?	
,	

M	

[

 'Y3)	4