
    Eh                        S r SSKJr  SSKrSSKrSSKrSSKrSSKJr  SSK	J	r	  SSK
Jr  Sr\R                  " S5      r\	R                  " S	S
5        SrSrSrSrSrSrSrSS jrSS jrg)z%Utilities to manipulate JSON objects.    )annotationsN)
b2a_base64)datetime)Anyz%Y-%m-%dT%H:%M:%S.%fzJ^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})(\.\d{1,6})?Z?([\+\-]\d{2}:?\d{2})?$z
2000-01-01z%Y-%m-%ds   PNG

s	   iVBORw0KGs   s   /9s   R0lGODdhs   R0lGODlhs   JVBERc                    U $ )ao  b64-encodes images in a displaypub format dict

Perhaps this should be handled in json_clean itself?

Parameters
----------

format_dict : dict
    A dictionary of display data keyed by mime-type

Returns
-------

format_dict : dict
    A copy of the same dictionary,
    but binary image data ('image/png', 'image/jpeg' or 'application/pdf')
    is base64-encoded.

 )format_dicts    dC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\nbclient/jsonutil.pyencode_imagesr   2   s
    (     c                   [         [        S5      4n[        [        [        R
                  4n[        U [        5      (       a  U $ [        U [        R                  5      (       a  [        U 5      $ [        U [        R                  5      (       aL  [        R                  " U 5      (       d  [        R                  " U 5      (       a  [        U 5      $ [!        U 5      $ [        X5      (       a  U $ [        U ["        5      (       a  [%        U 5      R'                  S5      $ [        X5      (       d"  [)        U S5      (       a  [)        U S5      (       a  [+        U 5      n [        U [*        5      (       a  U  Vs/ s H  n[-        U5      PM     sn$ [        U [.        5      (       az  [1        U 5      n[1        [        [3        [         U 5      5      5      nXE:w  a  [5        S5      e0 n[7        U R9                  5       5       H  u  px[-        U5      U[        U5      '   M     U$ [        U [:        5      (       a  U R=                  [>        5      $ [5        SU -  5      es  snf )a  Clean an object to ensure it's safe to encode in JSON.

Atomic, immutable objects are returned unmodified.  Sets and tuples are
converted to lists, lists are copied and dicts are also copied.

Note: dicts whose keys could cause collisions upon encoding (such as a dict
with both the number 1 and the string '1' as keys) will cause a ValueError
to be raised.

Parameters
----------
obj : any python object

Returns
-------
out : object

  A version of the input which will not cause an encoding error when
  encoded as JSON.  Note that this function does not *encode* its inputs,
  it simply sanitizes it so that there will be no encoding errors later.

Nascii__iter____next__zSdict cannot be safely converted to JSON: key collision would lead to dropped valueszCan't clean for JSON: %r) strtypetuplesettypesGeneratorType
isinstanceboolnumbersIntegralintRealmathisnanisinfreprfloatbytesr   decodehasattrlist
json_cleandictlenmap
ValueErroriteritemsr   strftimeISO8601)	obj	atomic_okcontainer_to_listxnkeysnkeys_collapsedoutkvs	            r
   r&   r&   I   s   0 d4j!I U%8%89
 #t
#w''((3x#w||$$::c??djjoo9Sz#!!
#u#%%g..#))Z  WS*%=%=3i#t'*+s!
1s++#t Cc#c3-01#= 
 %DA$Q-CAK &
#x  ||G$$ /#5
66- ,s   0I)r	   dict[str, str]returnr8   )r/   r   r9   r   )__doc__
__future__r   r   r   rer   binasciir   r   typingr   r.   compileISO8601_PATstrptimePNGPNG64JPEGJPEG64GIF_64GIF89_64PDF64r   r&   r   r   r
   <module>rI      s|    + #   	     !jjQ 	  ,
 + 		.O7r   