
    -Ph                     ~    d dl Z d dlmZ d dlT d dlT ddZ G d d	e          Z G d
 de          ZddZ	d Z
d ZdS )    N)PrettyPrinter)*      P   c           
          t          | t                    rd\  }}n:t          | t                    rd\  }}nt          dt	          |           z            t          |           |k    r| }n4t          | d|                   dgz   t          | | d                   z   }|d                    d |D                       z   |z   }d                    t          j        ||d	|d
z   z  d	|d
z   z                      	                                }	|	S )a  
    Return a string representation for of a list where list is elided if
    it has more than n elements

    Parameters
    ----------
    v : list
        Input list
    threshold :
        Maximum number of elements to display

    Returns
    -------
    str
    )[])()zInvalid value of type: %sNz...z, c                 ,    g | ]}t          |          S  )str).0es     L/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/plotly/utils.py
<listcomp>z%_list_repr_elided.<locals>.<listcomp>%   s    ":":":a3q66":":":    
    )widthinitial_indentsubsequent_indent)

isinstancelisttuple
ValueErrortypelenjointextwrapwrapstrip)
v	threshold	edgeitemsindentr   	open_char
close_chardisp_vv_str	v_wrappeds
             r   _list_repr_elidedr.   	   s,     !T @ (	::	Au		 @ (	::4tAww>???
1vva

m$$w.a
n1E1EE		":":6":":":;;;jHE		&1*-!VaZ0		
 	
 	
  egg  r   c                   4    e Zd ZdZd Zed             Zd ZdS )ElidedWrapperz
    Helper class that wraps values of certain types and produces a custom
    __repr__() that may be elided and is suitable for use during pretty
    printing
    c                 0    || _         || _        || _        d S N)r%   r(   r&   )selfr%   r&   r(   s       r   __init__zElidedWrapper.__init__9   s    "r   c                    t          d          }t          | t          t          f          r0t	          |           dk    rt          | d         t
                    sdS |rt          | |j                  rdS t          | t                    rdS dS )Nnumpyr   TF)
get_moduler   r   r   r    dictndarrayr   )r%   r6   s     r   is_wrappablezElidedWrapper.is_wrappable>   s    7##a$'' 	CFFQJJz!A$PT?U?UJ4 	z!U]33 	43 	45r   c           
      T   t          d          }t          | j        t          t          f          r#t          | j        | j        | j                  }|S |rt          | j        |j                  r|	                                } |j
        di t          || j        dd           | j                                        }|                    d          }dd| j        z  z                       |          } |j
        di | |S t          | j        t                    rst!          | j                  dk    rBdt#          | j        d d	                   z   d
z   t#          | j        dd                    z   dz   S | j                                        S | j                                        S )Nr6   )r&   r(   r   r   )r&   r'   	linewidthr   r   r      z ... ir   r   )r7   r   r%   r   r   r.   r&   r(   r9   get_printoptionsset_printoptionsr8   __repr__splitr!   r   r    repr)r3   r6   res	orig_opts	res_liness        r   r@   zElidedWrapper.__repr__J   s   7##dftUm,, !	%#$.  C J 	%z$&%-88 	% ..00I #E"  yDNaSUVVV   &//##C 		$I#++11)<<C #E"//Y///J$$ 	%46{{RT$&"+...84stt;M;MMPSSSv(((6??$$$r   N)__name__
__module____qualname____doc__r4   staticmethodr:   r@   r   r   r   r0   r0   2   sW         # # #
 	 	 \	#% #% #% #% #%r   r0   c                       e Zd ZdZd Zd ZdS )ElidedPrettyPrinterzF
    PrettyPrinter subclass that elides long lists/arrays/strings
    c                 f    |                     dd          | _        t          j        | g|R i | d S )Nr&   r   )popr&   r   r4   )r3   argskwargss      r   r4   zElidedPrettyPrinter.__init__u   s>    K55t5d555f55555r   c           	          t                               |          r0t          || j        |          }|                     ||||||          S t	          j        | ||||||          S r2   )r0   r:   r&   _formatr   )r3   valstreamr(   	allowancecontextlevel
elided_vals           r   rR   zElidedPrettyPrinter._formaty   sl    %%c** 	&sDNFCCJ<<
FFIwPUVVV (c669gu  r   N)rF   rG   rH   rI   r4   rR   r   r   r   rL   rL   p   s<         6 6 6    r   rL   r   c              #      K   t          | t                    sdS | |fV  |                                 D ]5\  }}t          |t                    rt          |||fz             D ]}|V  6dS )a  
    General, node-yielding generator.

    Yields (node, path) tuples when it finds values that are dict
    instances.

    A path is a sequence of hashable values that can be used as either keys to
    a mapping (dict) or indices to a sequence (list). A path is always wrt to
    some object. Given an object, a path explains how to get from the top level
    of that object to a nested value in the object.

    :param (dict) node: Part of a dict to be traversed.
    :param (tuple[str]) path: Defines the path of the current node.
    :return: (Generator)

    Example:

        >>> for node, path in node_generator({'a': {'b': 5}}):
        ...     print(node, path)
        {'a': {'b': 5}} ()
        {'b': 5} ('a',)

    N)r   r8   itemsnode_generator)nodepathkeyrS   items        r   r[   r[      s      0 dD!! 
*JJLL  Sc4   	&sDC6M::  



 r   c                      |D ]
}| |         } | S )aR  
    Iteratively get on obj for each key in path.

    :param (list|dict) obj: The top-level object.
    :param (tuple[str]|tuple[int]) path: Keys to access parts of obj.

    :return: (*)

    Example:

        >>> figure = {'data': [{'x': [5]}]}
        >>> path = ('data', 0, 'x')
        >>> get_by_path(figure, path)
        [5]
    r   )objr]   r^   s      r   get_by_pathrb      s#        #hJr   c                     t          | t                    r~t          |           D ]m\  }}t          |t          t          f          rt	          |          | |<   4t          |t
                    r$	 t          |          | |<   ]# t          $ r Y iw xY wnnt          | t                    rt          |                                           t          |                                           }}t          ||          D ]\  }}t          |t          t          f          rt	          |          | |<   n9t          |t
                    r$	 t          |          | |<   n# t          $ r Y nw xY w| 
                    |          | t          |          <   | S r2   )r   r   	enumerater8   decode_unicoder   UnicodeEncodeErrorkeysvaluesziprN   )collnoentryrg   valsr^   rS   s          r   re   re      s   $ +"4 	 	IB%$.. )%00ReS)) #&u::R-   		 
D$		 
+$))++&&T[[]](;(;dD$ 	+ 	+HC#d|,, *3//S		C%%  #CDII)   D!XXc]]DSNNKs$   /B
BBE
E%$E%)r   r   r   r   )r   )r"   pprintr   _plotly_utils.utils_plotly_utils.data_utilsr.   objectr0   rL   r[   rb   re   r   r   r   <module>rr      s                 ! ! ! ! & & & && & & &R;% ;% ;% ;% ;%F ;% ;% ;%|    -   (   B  *    r   