
    Mh%                         d Z ddlZddlZddlZddlZej        Z G d dej                  Z G d de	          Z
d Zd Zd	 Zd
 ZddZddZ	d Zej        Zej        ZdS )zImproved JSON serialization.
    Nc                   "     e Zd ZdZ fdZ xZS )JsonEncoderzCustomizable JSON encoder.

    If the object implements __getstate__, then that method is invoked, and its
    result is serialized instead of the object itself.
    c                     	 |j         } |            S # t          $ r Y nw xY wt                                          |          S N)__getstate__AttributeErrorsuperdefault)selfvalue	get_state	__class__s      S/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/debugpy/common/json.pyr
   zJsonEncoder.default   sX    	*I 9;;  	 	 	D	 wwu%%%s    
!!)__name__
__module____qualname____doc__r
   __classcell__)r   s   @r   r   r      sB         & & & & & & & & &    r   c                   P    e Zd ZdZeZ	  ed          Z	 d Zd Zd Z	d Z
d Zd	S )

JsonObjectzzA wrapped Python object that formats itself as JSON when asked for a string
    representation via str() or format().
       )indentc                 B    t          |t                    rJ || _        d S r   )
isinstancer   r   )r   r   s     r   __init__zJsonObject.__init__-   s#    eZ00000


r   c                     t           r   )NotImplementedErrorr   s    r   r   zJsonObject.__getstate__1   s    !!r   c                 4    t          j        | j                  S r   )builtinsreprr   r   s    r   __repr__zJsonObject.__repr__4   s    }TZ(((r   c                      t          |           S r   )formatr   s    r   __str__zJsonObject.__str__7   s    d||r   c                     |r d|z   dz   }t          |d| j        i          }n| j        }|                    | j                  S )a  If format_spec is empty, uses self.json_encoder to serialize self.value
        as a string. Otherwise, format_spec is treated as an argument list to be
        passed to self.json_encoder_factory - which defaults to JSONEncoder - and
        then the resulting formatter is used to serialize self.value as a string.

        Example::

            format("{0} {0:indent=4,sort_keys=True}", json.repr(x))
        zjson_encoder_factory()json_encoder_factory)evalr)   json_encoderencoder   )r   format_specmake_encoderencoders       r   
__format__zJsonObject.__format__:   sZ      	( 3[@3FL5t7PQ GG 'G~~dj)))r   N)r   r   r   r   r   r)   r+   r   r   r#   r&   r0    r   r   r   r   "   s          ';''q111LK  " " ") ) )  * * * * *r   r   c                     |D ]:}t          |t          j                  r	  ||           c S # t          $ r Y 6w xY w;dS )zGConvert value (str) to number, otherwise return None if is not possibleN)
issubclassnumbersNumber
ValueError)r   	classinfoone_infos      r   
_converterr9   `   sm      h// 	x&&&   	 s   
-
::c                       t                     sJ |                    dd          t          |          rJ  fd}|S )zReturns a validator for a JSON property that requires it to have a value of
    the specified type. If optional=True, () is also allowed.

    The meaning of classinfo is the same as for isinstance().
    optionalFc                     r| dk    st          |           r| S t          |           }|r|S s| dk    rt          d          t          dd                    d D                       z             )Nr1   zmust be specifiedzmust be  or c              3   $   K   | ]}|j         V  d S r   )r   ).0ts     r   	<genexpr>z,of_type.<locals>.validate.<locals>.<genexpr>   s$      4S4SAQZ4S4S4S4S4S4Sr   )r   r9   r6   	TypeErrorjoin)r   converted_valuer7   r;   s     r   validatezof_type.<locals>.validateu   s     		U"E9)E)EL(	::O '&& 6 !4555J4S4S4S4S4S)S)SSTTTr   lenpop)r7   kwargsrE   r;   s   `  @r   of_typerJ   j   sh     y>>zz*e,,H6{{
U 
U 
U 
U 
U 
U Or   c                       fd}|S )zReturns a validator for a JSON property with a default value.

    The validator will only allow property values that have the same type as the
    specified default value.
    c                     | dk    rS t          | t                              r| S t          d                    t                    j                            )Nr1   zmust be {0})r   typerB   r%   r   )r   r
   s    r   rE   zdefault.<locals>.validate   sT    B;;NtG}}-- 	JLM00g1GHHIIIr   r1   )r
   rE   s   ` r   r
   r
      s(    J J J J J Or   c                       t                     sJ |                    dd          t          |          rJ  fd}|S )zReturns a validator for a JSON enum.

    The validator will only allow the property to have one of the specified values.

    If optional=True, and the property is missing, the first value specified is used
    as the default.
    r;   Fc                     r| dk    rd         S | v r| S t          d                    t                                        )Nr1   r   zmust be one of: {0!r})r6   r%   list)r   r;   valuess    r   rE   zenum.<locals>.validate   sO     	K!9f__L4;;DLLIIJJJr   rF   )rQ   rI   rE   r;   s   `  @r   enumrR      sh     v;;zz*e,,H6{{K K K K K K Or   Fc                      sd  n9t           t                    st           t                    rt                      d nt          t                    rd D             fdn|t          t                    rNdt                    cxk    rdk    sn J t          d D                       d	z   d
d         \  fdnt          j                  fd fd}|S )a  Returns a validator for a JSON array.

    If the property is missing, it is treated as if it were []. Otherwise, it must
    be a list.

    If validate_item=False, it's treated as if it were (lambda x: x) - i.e. any item
    is considered valid, and is unchanged. If validate_item is a type or a tuple,
    it's treated as if it were json.of_type(validate).

    Every item in the list is replaced with validate_item(item) in-place, propagating
    any exceptions raised by the latter. If validate_item is a type or a tuple, it is
    treated as if it were json.of_type(validate_item).

    If vectorize=True, and the value is neither a list nor a dict, it is treated as
    if it were a single-element list containing that single value - e.g. "foo" is
    then the same as ["foo"]; but {} is an error, and not [{}].

    If size is not None, it can be an int, a tuple of one int, a tuple of two ints,
    or a set. If it's an int, the array must have exactly that many elements. If it's
    a tuple of one int, it's the minimum length. If it's a tuple of two ints, they
    are the minimum and the maximum lengths. If it's a set, it's the set of sizes that
    are valid - e.g. for {2, 4}, the array can be either 2 or 4 elements long.
    c                     | S r   r1   )xs    r   <lambda>zarray.<locals>.<lambda>   s    ! r   Nc                     dS )NTr1   )_s    r   rV   zarray.<locals>.<lambda>   s    $ r   c                 6    h | ]}t          j        |          S r1   operatorindexr?   ns     r   	<setcomp>zarray.<locals>.<setcomp>   s"    000aq!!000r   c                     t          |           v p>d                    d                    d t                    D                                 S )Nmust have {0} elementsr=   c              3   4   K   | ]}t          |          V  d S r   )strr]   s     r   rA   z*array.<locals>.<lambda>.<locals>.<genexpr>   s(      99qCFF999999r   )rG   r%   rC   sortedr   sizes    r   rV   zarray.<locals>.<lambda>   sR    JJ$ '..99F4LL99999  r         c              3   >   K   | ]}t          j        |          V  d S r   rZ   r]   s     r   rA   zarray.<locals>.<genexpr>   s,      551X^A&&555555r   r   r   c                     t          |           k     rd                              n+(t          |           k     rd                              ndS )Nzmust have at least {0} elementszmust have at most {0} elementsTrG   r%   )r   max_lenmin_lens    r   rV   zarray.<locals>.<lambda>   s`    5zzG## .44W=== "s5zzG';'; 288AAA r   c                 T    t          |           k    pd                              S )Nra   rk   re   s    r   rV   zarray.<locals>.<lambda>   s*    JJ$G":"A"A$"G"G r   c                    | dk    rg } n!rt          | t          t          f          s| g}  t          t                    |             |           }|durt	          |          t          |           D ]X\  }}	  |          | |<   # t          t          f$ r0} t          |          dt          |           d|           d }~ww xY w| S )Nr1   T[] )	r   rP   dictrJ   r6   	enumeraterB   rM   r"   )r   size_erriitemexcvalidate_itemvalidate_size	vectorizes        r   rE   zarray.<locals>.validate   s    B;;EE 	z%$>> 	GEe =''4X&&& '' 	6 	6GAt6(=..az* 6 6 6d3ii 4DGG 4 4s 4 45556s   <BC+CC)r   rM   tuplerJ   setrG   r[   r\   )rx   rz   rf   rE   rl   rm   ry   s   ``` @@@r   arrayr}      sv   2  /#	M4	(	( /J}e,L,L /..|&	D#		 
004000
 
 
 
 
D%	 	  
CII""""""""""5555555 7NAaC0
 
 
 
 
 ~d##
 
 
 
      & Or   c                      t           t                    st           t                    rt                       fd}|S )av  Returns a validator for a JSON object.

    If the property is missing, it is treated as if it were {}. Otherwise, it must
    be a dict.

    If validate_value=False, it's treated as if it were (lambda x: x) - i.e. any
    value is considered valid, and is unchanged. If validate_value is a type or a
    tuple, it's treated as if it were json.of_type(validate_value).

    Every value in the dict is replaced with validate_value(value) in-place, propagating
    any exceptions raised by the latter. If validate_value is a type or a tuple, it is
    treated as if it were json.of_type(validate_value). Keys are not affected.
    c                 0   | dk    ri S  t          t                    |            rm|                                 D ]X\  }}	  |          | |<   # t          t          f$ r0} t          |          dt          |           d|           d }~ww xY w| S )Nr1   rp   rq   )rJ   rr   itemsrB   r6   rM   r"   )r   kvrw   validate_values       r   rE   zobject.<locals>.validate  s    B;;Ie 	: : :1:-~a00E!HH!:. : : :#$s))$8Q$8$83$8$8999:s   AB#+BB)r   rM   r{   rJ   )r   rE   s   ` r   objectr      sU     .$'' 1:ne+L+L 1 00     Or   c                      t          |           S r   )r   )r   s    r   r"   r"     s    er   )FFN)F)r   r!   jsonr4   r[   JSONDecoderJsonDecoderJSONEncoderr   r   r   r9   rJ   r
   rR   r}   r"   dumpsloadsr1   r   r   <module>r      s$  
      & & & & &$" & & &"0* 0* 0* 0* 0* 0* 0* 0*|    4  $  0L L L L^   D   	

r   