
    Mhx              
          U d Z ddlmZ ddlZddlZddlZddlZ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 g dZdZ e ej        d                    ZdXdZd ZdddefdZdddefdZ G d d          Z G d de          Z d Z! G d de           Z" G d d          Z# G d de#          Z$ G d  d!e#          Z% G d" d#e#          Z& G d$ d%          Z' G d& d'          Z( G d( d)          Z) G d* d+          Z*d, Z+d- Z,d. Z-d/ Z.d0 Z/ G d1 d2          Z0d3 Z1d4 Z2d5 Z3d6 Z4d7 Z5d8 Z6ee7d9<   	 e8Z9n# e:$ r e;Z9Y nw xY wi e<e4e=e4e>e4e? e,d:d;          e@ e,d<d=          eA e.d>d?          eB e-d>d?          eC e-d@dA          eDe/ee1ee3ejE        e5ejF        e5ejG        e4ejH        e2ej        e4ejI        e4e9e6iZJ eejK                  ZLeLeAur e.dBd?          eJeL<    e.dCdA          eJejM        <   e4eJeN<   e4eJeO<   e4eJeP<   i ZQee7dD<   dE ZRdF ZSeAT                     eUeVddGdeWeXg          e4          ZYdH ZZdI Z[dJ Z\dK Z]dL Z^ eSdMdNeZ            eSdMdOe[            eSdMdPe\            eSdMdQe]            eSdMdRe^           e_dSk    r*ddTl`maZa  G dU dV          Zb e eb            dGW           dS dS )Ya
  
Python advanced pretty printer.  This pretty printer is intended to
replace the old `pprint` python module which does not allow developers
to provide their own pretty print callbacks.

This module is based on ruby's `prettyprint.rb` library by `Tanaka Akira`.


Example Usage
-------------

To directly print the representation of an object use `pprint`::

    from pretty import pprint
    pprint(complex_object)

To get a string of the output use `pretty`::

    from pretty import pretty
    string = pretty(complex_object)


Extending
---------

The pretty library allows developers to add pretty printing rules for their
own objects.  This process is straightforward.  All you have to do is to
add a `_repr_pretty_` method to your object and call the methods on the
pretty printer passed::

    class MyObject(object):

        def _repr_pretty_(self, p, cycle):
            ...

Here's an example for a class with a simple constructor::

    class MySimpleObject:

        def __init__(self, a, b, *, c=None):
            self.a = a
            self.b = b
            self.c = c

        def _repr_pretty_(self, p, cycle):
            ctor = CallExpression.factory(self.__class__.__name__)
            if self.c is None:
                p.pretty(ctor(a, b))
            else:
                p.pretty(ctor(a, b, c=c))

Here is an example implementation of a `_repr_pretty_` method for a list
subclass::

    class MyList(list):

        def _repr_pretty_(self, p, cycle):
            if cycle:
                p.text('MyList(...)')
            else:
                with p.group(8, 'MyList([', '])'):
                    for idx, item in enumerate(self):
                        if idx:
                            p.text(',')
                            p.breakable()
                        p.pretty(item)

The `cycle` parameter is `True` if pretty detected a cycle.  You *have* to
react to that or the result is an infinite loop.  `p.text()` just adds
non breaking text to the output, `p.breakable()` either adds a whitespace
or breaks here.  If you pass it an argument it's used instead of the
default space.  `p.pretty` prettyprints another object using the pretty print
method.

The first parameter to the `group` function specifies the extra indentation
of the next line.  In this example the next item will either be on the same
line (if the items are short enough) or aligned with the right edge of the
opening bracket of `MyList`.

If you just want to indent something you can use the group function
without open / close parameters.  You can also use this code::

    with p.indent(2):
        ...

Inheritance diagram:

.. inheritance-diagram:: IPython.lib.pretty
   :parts: 3

:copyright: 2007 by Armin Ronacher.
            Portions (c) 2009 by Robert Kern.
:license: BSD License.
    )contextmanagerN)deque)	signature)StringIO)warn)undoc)PYPY)Dict)	prettypprintPrettyPrinterRepresentationPrinterfor_typefor_type_by_nameRawTextRawStringLiteralCallExpressioni   c                 J    	 t          | ||          S # t          $ r |cY S w xY w)zzSafe version of getattr.

    Same as getattr, but will return ``default`` on any Exception,
    rather than raising.
    )getattr	Exception)objattrdefaults      R/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/IPython/lib/pretty.py_safe_getattrr   w   s=    sD'***   s    ""c                     t          |           } 	 t          |           S # t          $ r. 	 t          | t                    cY S # t          $ r | cY cY S w xY ww xY w)z
    Sort the given items for pretty printing. Since some predictable
    sorting is better than no sorting at all, we sort on the string
    representation if normal sorting fails.
    )key)listsortedr   str)itemss    r   _sorted_for_pprintr#      s     KKEe}}   	%S)))))) 	 	 	LLLLL	s,     
AA AAAAAFO   
c                     t                      }t          |||||          }|                    |            |                                 |                                S )z3
    Pretty print the object's representation.
    max_seq_length)r   r   r   flushgetvalue)r   verbose	max_widthnewliner(   streamprinters          r   r   r      sU     ZZF#FGYXfgggGNN3MMOOO??    c                    t          t          j        ||||          }|                    |            |                                 t          j                            |           t          j                                         dS )z,
    Like `pretty` but print to stdout.
    r'   N)r   sysstdoutr   r)   write)r   r+   r,   r-   r(   r/   s         r   r   r      sn     $CJG\jkkkGNN3MMOOOJWJr0   c                   <    e Zd Zed             Zedd            ZdS )_PrettyPrinterBasec              #   ~   K   | xj         |z  c_         	 dV  | xj         |z  c_         dS # | xj         |z  c_         w xY w)z/with statement support for indenting/dedenting.N)indentation)selfindents     r   r:   z_PrettyPrinterBase.indent   sd       	F"	'EEE&D&s   * <r   r   c              #      K   |                      ||           	 dV  |                     ||           dS # |                     ||           w xY w)z8like begin_group / end_group but for the with statement.N)begin_group	end_group)r9   r:   opencloses       r   groupz_PrettyPrinterBase.group   s`       	&&&	*EEENN65)))))DNN65))))s	   6 AN)r   r   r   )__name__
__module____qualname__r   r:   r@    r0   r   r6   r6      sM        ' ' ^' * * * ^* * *r0   r6   c                   \    e Zd ZdZddefdZd Zd Zd Zdd	Z	d
 Z
ddZd ZddZd ZdS )r   a  
    Baseclass for the `RepresentationPrinter` prettyprinter that is used to
    generate pretty reprs of objects.  Contrary to the `RepresentationPrinter`
    this printer knows nothing about the default pprinters or the `_repr_pretty_`
    callback method.
    r$   r%   c                     || _         || _        || _        || _        d| _        d| _        t                      | _        t          d          }|g| _	        t          |          | _        d| _        d S Nr   )outputr,   r-   r(   output_widthbuffer_widthr   bufferGroupgroup_stack
GroupQueuegroup_queuer8   )r9   rH   r,   r-   r(   
root_groups         r   __init__zPrettyPrinter.__init__   sm    ",gg1XX
&<%j11r0   c                    |j         rZ| j                                        }|                    | j        | j                  | _        | xj        |j        z  c_        |j         Z| j        rt          | j        d         t                    r| j                                        }|                    | j        | j                  | _        | xj        |j        z  c_        | j        r$t          | j        d         t                    zd S d S d S d S rG   )	
breakablesrK   popleftrH   rI   rJ   width
isinstanceText)r9   r@   xs      r   _break_one_groupzPrettyPrinter._break_one_group   s    	)##%%A !d6G H HD(  	) k 	)jQ>> 	)##%%A !d6G H HD( k 	)jQ>> 	) 	) 	) 	) 	) 	) 	) 	) 	)r0   c                     | j         | j        | j        z   k     rL| j                                        }|sd S |                     |           | j         | j        | j        z   k     Jd S d S N)r,   rI   rJ   rO   deqrY   r9   r@   s     r   _break_outer_groupsz!PrettyPrinter._break_outer_groups   su    nt043DDDD$((**E !!%(((	 nt043DDDDDDDDr0   c                    t          |          }| j        r| j        d         }t          |t                    s(t                      }| j                            |           |                    ||           | xj        |z  c_        |                                  dS | j        	                    |           | xj
        |z  c_
        dS )zAdd literal text to the output.N)lenrK   rV   rW   appendaddrJ   r^   rH   r4   rI   )r9   r   rU   texts       r   rd   zPrettyPrinter.text   s    C; 
	';r?DdD)) )vv""4(((HHS%   &$$&&&&&Kc"""&r0    c                    t          |          }| j        d         }|j        rj|                                  | j                            | j                   | j                            d| j        z             | j        | _        d| _	        dS | j
                            t          |||                      | xj	        |z  c_	        |                                  dS )z
        Add a breakable separator to the output.  This does not mean that it
        will automatically break here.  If no breaking on this position takes
        place the `sep` is inserted which default to one space.
        r`   re   r   N)ra   rM   
want_breakr)   rH   r4   r-   r8   rI   rJ   rK   rb   	Breakabler^   )r9   seprU   r@   s       r   	breakablezPrettyPrinter.breakable   s     C $ 		'JJLLLKdl+++KcD$44555 $ 0D !DKyeT::;;;&$$&&&&&r0   c                 6   | j                                         }|r|                     |           |                                  | j                            | j                   | j                            d| j        z             | j        | _        d| _	        dS )z_
        Explicitly insert a newline into the output, maintaining correct indentation.
        re   r   N)
rO   r\   rY   r)   rH   r4   r-   r8   rI   rJ   r]   s     r   break_zPrettyPrinter.break_  s      $$&& 	)!!%(((

$,'''# 00111 ,r0   r   r   c                     |r|                      |           t          | j        d         j        dz             }| j                            |           | j                            |           | xj        |z  c_        dS )z
        Begin a group.
        The first parameter specifies the indentation for the next line (usually
        the width of the opening text), the second the opening text.  All
        parameters are optional.
        r`      N)rd   rL   rM   depthrb   rO   enqr8   )r9   r:   r>   r@   s       r   r<   zPrettyPrinter.begin_group  s      	IIdOOOd&r*01455&&&U###F"r0   c              #      K   t          |          D ]^\  }}| j        rL|| j        k    rA|                     d           |                                  |                     d            dS ||fV  _dS )z>like enumerate, but with an upper limit on the number of items,...N)	enumerater(   rd   rj   )r9   seqidxrX   s       r   
_enumeratezPrettyPrinter._enumerate  s      nn 	 	FC" sd.A'A'A		#   		%   q&LLLL	 	r0   c                     | xj         |z  c_         | j                                        }|j        s| j                            |           |r|                     |           dS dS )z0End a group. See `begin_group` for more details.N)r8   rM   poprS   rO   removerd   )r9   dedentr?   r@   s       r   r=   zPrettyPrinter.end_group)  sv    F" $$&& 	+##E*** 	IIe	 	r0   c                     | j         D ]0}| xj        |                    | j        | j                  z  c_        1| j                                          d| _        dS )z&Flush data that is left in the buffer.r   N)rK   rI   rH   clearrJ   )r9   datas     r   r)   zPrettyPrinter.flush2  sa    K 	M 	MDT[$:K!L!LLr0   N)re   )r   r   )rA   rB   rC   __doc__MAX_SEQ_LENGTHrQ   rY   r^   rd   rj   rl   r<   rw   r=   r)   rD   r0   r   r   r      s          *,T.    ) ) )) ) )' ' '' ' ' '&  # # # #         r0   r   c                     t          | d          sA	 t          | j        | t          fi           } | j        dd         }n# t
          $ r | g}Y nw xY w| j        }|S )z| Get a reasonable method resolution order of a class and its superclasses
    for both old-style and new-style classes.
    __mro__rn   r`   )hasattrtyperA   objectr   	TypeError)	obj_classmros     r   _get_mror   :  s     9i((  	*Y/)V1DbIII #AbD)CC  	 	 	 +CCC	 Js   ? AAc                   4    e Zd ZdZddddddefdZd Zd ZdS )	r   a  
    Special pretty printer that has a `pretty` method that calls the pretty
    printer for a python object.

    This class stores processing data on `self` so you must *never* use
    this class in a threaded environment.  Always lock it or reinstanciate
    it.

    Instances also have a verbose flag callbacks can access to control their
    output.  For example the default instance repr prints all attributes and
    methods that are not prefixed by an underscore if the printer is in
    verbose mode.
    Fr$   r%   Nc	                 ,   t                               | ||||           || _        g | _        |t                                          }|| _        |t                                          }|| _        |t                                          }|| _
        d S )Nr'   )r   rQ   r+   stack_singleton_pprinterscopysingleton_pprinters_type_pprinterstype_pprinters_deferred_type_pprintersdeferred_pprinters)	r9   rH   r+   r,   r-   r   r   r   r(   s	            r   rQ   zRepresentationPrinter.__init__\  s     	tVYP^___
&"6";";"="=#6 !,1133N,%!9!>!>!@!@"4r0   c                 r   t          |          }|| j        v }| j                            |           |                                  	 t	          |dd          pt          |          }	 | j        |         } ||| |          |                                  | j                                         S # t          t          f$ r Y nw xY wt          |          D ]q}|| j        v rG | j        |         || |          c |                                  | j                                         S |                     |          }|< ||| |          c |                                  | j                                         S d|j        v rR|j        }t!          |          r< ||| |          c |                                  | j                                         S |t"          urgd|j        v r^t!          t	          |dd                    r@t%          || |          c |                                  | j                                         S st'          || |          |                                  | j                                         S # |                                  | j                                         w xY w)zPretty print the given object.	__class__N_repr_pretty___repr__)idr   rb   r<   r   r   r   r=   ry   r   KeyErrorr   r   _in_deferred_types__dict__r   callabler   _repr_pprint_default_pprint)r9   r   obj_idcycler   r/   clsmeths           r   r   zRepresentationPrinter.prettym  s   C$*$
&!!!-	%c;==JcI126: wsD%00H NNJNNQ x(     	** B B$---34.s3CuEEEE: NNJNN7 #55c::G*&wsD%88880 NNJNN' +cl::#&#4D'~~ >'+tCu'='= = = NNJNN  v-- *cl : :
 !)sJ)M)M N N !; $0T5#A#AAA NNJNN #3e44NNJNN NNJNNsI    J )B0 6J 0CJ C7J )%J <-J AJ J /J6c                     t          |dd          }t          |dd          }||f}d}|| j        v r$| j                            |          }|| j        |<   |S )a  
        Check if the given class is specified in the deferred type registry.

        Returns the printer from the registry if it exists, and None if the
        class is not in the registry. Successful matches will be moved to the
        regular type registry for future use.
        rB   NrA   )r   r   ry   r   )r9   r   modnamer   r/   s         r   r   z(RepresentationPrinter._in_deferred_types  sj     Ct44S*d33Dk$)))-11#66G'.D$r0   )rA   rB   rC   r   r   rQ   r   r   rD   r0   r   r   r   M  sd          (-D $%5 5 5 5"3 3 3j    r0   r   c                       e Zd Zd ZdS )	Printablec                     |S r[   rD   r9   r.   rI   s      r   rH   zPrintable.output  s    r0   N)rA   rB   rC   rH   rD   r0   r   r   r     s#            r0   r   c                        e Zd Zd Zd Zd ZdS )rW   c                 "    g | _         d| _        d S rG   )objsrU   r9   s    r   rQ   zText.__init__  s    	


r0   c                 T    | j         D ]}|                    |           || j        z   S r[   )r   r4   rU   )r9   r.   rI   r   s       r   rH   zText.output  s5    9 	 	CLLdj((r0   c                 Z    | j                             |           | xj        |z  c_        d S r[   )r   rb   rU   )r9   r   rU   s      r   rc   zText.add  s,    	

e



r0   N)rA   rB   rC   rQ   rH   rc   rD   r0   r   rW   rW     sA          ) ) )
    r0   rW   c                       e Zd Zd Zd ZdS )rh   c                     || _         || _        || _        |j        | _        |j        d         | _        | j        j                            |            d S )Nr`   )r   rU   r   r8   rM   r@   rS   rb   )r9   ru   rU   r   s       r   rQ   zBreakable.__init__  sP    
!-'+

$$T*****r0   c                    | j         j                                         | j         j        rC|                    | j        j                   |                    d| j        z             | j        S | j         j        s$| j        j        	                    | j                    |                    | j
                   || j        z   S )Nre   )r@   rS   rT   rg   r4   r   r-   r8   rO   rz   r   rU   r   s      r   rH   zBreakable.output  s    
%%''':  	$LL,---LLt//000##z$ 	7K#**4:666TXdj((r0   N)rA   rB   rC   rQ   rH   rD   r0   r   rh   rh     s2        + + +	) 	) 	) 	) 	)r0   rh   c                       e Zd Zd ZdS )rL   c                 H    || _         t                      | _        d| _        d S )NF)ro   r   rS   rg   )r9   ro   s     r   rQ   zGroup.__init__  s    
''r0   N)rA   rB   rC   rQ   rD   r0   r   rL   rL     s#                 r0   rL   c                   &    e Zd Zd Zd Zd Zd ZdS )rN   c                 H    g | _         |D ]}|                     |           d S r[   )queuerp   )r9   groupsr@   s      r   rQ   zGroupQueue.__init__  s3    
 	 	EHHUOOOO	 	r0   c                     |j         }|t          | j                  dz
  k    r5| j                            g            |t          | j                  dz
  k    5| j        |                             |           d S )Nrn   )ro   ra   r   rb   )r9   r@   ro   s      r   rp   zGroupQueue.enq  sr    c$*oo)))Jb!!! c$*oo)))
5  '''''r0   c                     | j         D ]L}t          t          |                    D ]\  }}|j        r||= d|_        |c c S |D ]	}d|_        
|d d = Md S )NT)r   rt   reversedrS   rg   )r9   r   rv   r@   s       r   r\   zGroupQueue.deq  s    Z 	 	E'88 ! !
U# !c
'+E$ LLLLL!  ( (#'  aaa	 	r0   c                 t    	 | j         |j                                     |           d S # t          $ r Y d S w xY wr[   )r   ro   rz   
ValueErrorr]   s     r   rz   zGroupQueue.remove  sL    	Ju{#**511111 	 	 	DD	s   %) 
77N)rA   rB   rC   rQ   rp   r\   rz   rD   r0   r   rN   rN     sP          
( ( (	 	 	    r0   rN   c                       e Zd ZdZd Zd ZdS )r   z Object such that ``p.pretty(RawText(value))`` is the same as ``p.text(value)``.

    An example usage of this would be to show a list as binary numbers, using
    ``p.pretty([RawText(bin(i)) for i in integers])``.
    c                     || _         d S r[   valuer9   r   s     r   rQ   zRawText.__init__      


r0   c                 :    |                     | j                   d S r[   )rd   r   )r9   pr   s      r   r   zRawText._repr_pretty_  s    	tzr0   NrA   rB   rC   r   rQ   r   rD   r0   r   r   r     s<         
      r0   r   c                   4    e Zd ZdZd Zed             Zd ZdS )r   zY Object which emits a line-wrapped call expression in the form `__name(*args, **kwargs)` c                 4    | }||_         ||_        ||_        d S r[   )r   argskwargs)_CallExpression__self_CallExpression__namer   r   r9   s        r   rQ   zCallExpression.__init__  s"     		r0   c                       fd}|S )Nc                       g| R i |S r[   rD   )r   r   r   r   s     r   innerz%CallExpression.factory.<locals>.inner!  s#    3t-d---f---r0   rD   )r   r   r   s   `` r   factoryzCallExpression.factory  s'    	. 	. 	. 	. 	. 	.r0   c                    dfd}| j         dz   }                    t          |          |d          5  | j        D ]!} |                                 |           "| j                                        D ]d\  }} |             |dz   }                    t          |          |          5                      |           d d d            n# 1 swxY w Y   e	 d d d            d S # 1 swxY w Y   d S )NFc                  b    r)                      d                                             dd S )Nrr   T)rd   rj   )r   starteds   r   new_itemz.CallExpression._repr_pretty_.<locals>.new_item*  s0     sGGGr0   ()=)r   r@   ra   r   r   r   r"   )	r9   r   r   r   prefixargarg_name
arg_prefixr   s	    `      @r   r   zCallExpression._repr_pretty_%  s    	 	 	 	 	 	 SWWS[[&#.. 	" 	"y  


!%!2!2!4!4 " "#


%^
WWS__j99 " "HHSMMM" " " " " " " " " " " " " " ""		" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"s6   A:C/3C	C/CC/CC//C36C3N)rA   rB   rC   r   rQ   classmethodr   r   rD   r0   r   r   r     sS        cc     [
" " " " "r0   r   c                       e Zd ZdZd Zd ZdS )r   z/ Wrapper that shows a string with a `r` prefix c                     || _         d S r[   r   r   s     r   rQ   zRawStringLiteral.__init__?  r   r0   c                     t          | j                  }|d d         dv r|dd          }d}nd}||                    dd          z   }|                    |           d S )Nrn   uUurrz\\\)reprr   replacerd   )r9   r   r   	base_reprr   s        r   r   zRawStringLiteral._repr_pretty_B  so    $$	RaR=D  !!""IFFFY..vt<<<		yr0   Nr   rD   r0   r   r   r   =  s8        99      r0   r   c                    t          | dd          pt          |           }t          |dd          t          j        urt	          | ||           dS |                    dd           |                    |           |                    dt          |           z             |r|                    d           n|j	        rd}t          |           D ]}|                    d	          s	 t          | |          }n# t          $ r Y 5w xY wt          |t          j                  rT|s|                    d
           |                                 |                    |           |                    d           t%          |          dz   }|xj        |z  c_        |                    |           |xj        |z  c_        d}|                    dd           dS )zw
    The default print function.  Used if an object does not provide one and
    it's none of the builtin objects.
    r   Nr   rn   <z at 0x%xz ...T_rr   r   F>)r   r   r   r   r   r<   r   rd   r   r+   dir
startswithr   AttributeErrorrV   types
MethodTyperj   ra   r8   r=   )r   r   r   klassfirstr   r   steps           r   r   r   M  s   
 #{D11>T#YYEUJ--V_DDS!U###MM!SHHUOOOFF:3    	v	
 s88 	 	C>>#&& #C--EE%   HeU%566   FF3KKKss3xx!|%%KK3s   +C<<
D	D	c                       fd}|S )z|
    Factory that returns a pprint function useful for sequences.  Used by
    the default pprint for tuples and lists.
    c                    |r|                     dz   z             S t                    }|                    |           |                    |           D ]E\  }}|r)|                     d           |                                 |                    |           Ft          |           dk    r*t          | t                    r|                     d           |                    |           d S )Nrs   rr   rn   )	rd   ra   r<   rw   rj   r   rV   tupler=   )r   r   r   r   rv   rX   endstarts         r   r   z$_seq_pprinter_factory.<locals>.innerx  s     	/66%%-#-...5zz	dE"""ll3'' 	 	FC sHHQKKKKs88q==ZU33=FF3KKK	D#r0   rD   r   r   r   s   `` r   _seq_pprinter_factoryr   s  )    
      Lr0   c                       fd}|S )zP
    Factory that returns a pprint function useful for sets and frozensets.
    c                 N   |r|                     dz   z             S t          |           dk    r,|                     t          |           j        dz              d S t                    }|                    |           |j        rt          |           |j        k    st          |           }n| }|                    |          D ]E\  }}|r)|                     d           |                                 |	                    |           F|
                    |           d S )Nrs   r   z()rr   )rd   ra   r   rA   r<   r(   r#   rw   rj   r   r=   )	r   r   r   r   r"   rv   rX   r   r   s	          r   r   z$_set_pprinter_factory.<locals>.inner  s    	/66%%-#-...s88q==FF499%,-----u::DMM$&&&$ SQ5E)E)E*3//,,u--  Q "FF3KKKKKMMMKKc"""""r0   rD   r   s   `` r   _set_pprinter_factoryr     s)    # # # # # #( Lr0   c                       fd}|S )zj
    Factory that returns a pprint function used by the default pprint of
    dicts and dict proxies.
    c                    |r|                     d          S t                    }|                    |           |                                 }|                    |          D ]u\  }}|r)|                     d           |                                 |                    |           |                     d           |                    | |                    v|                    |           d S )Nz{...}rr   z: )rd   ra   r<   keysrw   rj   r   r=   )	r   r   r   r   r   rv   r   r   r   s	          r   r   z%_dict_pprinter_factory.<locals>.inner  s     	#66'??"5zz	dE"""xxzzT** 	 	HC sHHSMMMFF4LLLHHSX	D#r0   rD   r   s   `` r   _dict_pprinter_factoryr    r   r0   c                 v   |                     dd           |                    | j                   |                    d           |                                 t
          r(| j        j        }|                    || u rdn|           n|                    | j                   |                    dd           dS )zThe pprint for the super type.   z<super: rr   Nr   )	r<   r   __thisclass__rd   rj   r	   r   __self__r=   )r   r   r   dselfs       r   _super_pprintr    s    MM!Z   HHSFF3KKKKKMMM %	#51111	KK3r0   c                       e Zd Zd Zd ZdS )_ReFlagsc                     || _         d S r[   r   r   s     r   rQ   z_ReFlags.__init__  r   r0   c                     d}dD ]P}| j         t          t          |          z  r1|r|                    d           |                    d|z              d}Qd S )NF)
IGNORECASELOCALE	MULTILINEDOTALLUNICODEVERBOSEDEBUG|zre.T)r   r   rerd   )r9   r   r   done_oneflags        r   r   z_ReFlags._repr_pretty_  sp    
 	  	 D zGB---    FF3KKKut|$$$	  	 r0   N)rA   rB   rC   rQ   r   rD   r0   r   r	  r	    s2                   r0   r	  c                 2   t                               d          }| j        rE|                     |t	          | j                  t          | j                                       dS |                     |t	          | j                                       dS )z4The pprint function for regular expression patterns.z
re.compileN)r   r   flagsr   r   patternr	  )r   r   r   
re_compiles       r   _re_pattern_pprintr    s    ''55J
y <	,S[998CI;N;NOOPPPPP	,S[99::;;;;;r0   c                     t                               d          }|r-|                     |t          d                               dS |                     |di | j                   dS )z.The pprint function for types.SimpleNamespace.	namespacers   NrD   )r   r   r   r   r   )r   r   r   r  s       r   _types_simplenamespace_pprintr    so    &&{33I ,	75>>**+++++	**S\**+++++r0   c                    d t          t          |                     D             dd         t          gk    rt          | ||           dS t          | dd          }	 | j        }t          |t                    st          d          n.# t          $ r! | j        }t          |t                    sd}Y nw xY w|dv r|	                    |           dS |	                    |dz   |z              dS )	z!The pprint for classes and types.c                 4    g | ]}d t          |          v |S )r   )vars).0ms     r   
<listcomp>z _type_pprint.<locals>.<listcomp>  s(    @@@a*Q*?*?*?*?*?r0   Nrn   rB   zTry __name__z<unknown type>)N__builtin__builtins
exceptions.)
r   r   r   r   rC   rV   r!   r   rA   rd   )r   r   r   r   r   s        r   _type_pprintr)    s    A@8DII&&@@@!DNNS!U###
\4
0
0C	$$$$ 	, N+++	,  $ $ $|$$$ 	$#D$
 ===	t	sSy4     s   +B
 
(B54B5c                 (   t          |           }|                                }|                                5  t          |          D ]0\  }}|r|                                 |                    |           1	 ddd           dS # 1 swxY w Y   dS )z9A pprint that just redirects to the normal repr function.N)r   
splitlinesr@   rt   rl   rd   )r   r   r   rH   linesrv   output_lines          r   r   r     s     #YYFE	
     )% 0 0 	  	 C 


FF;	                                    s   ABBBc                     t          | d| j                  }| j        }|r|dvr|dz   |z   }	 |t          t	          |                     z   }n# t
          $ r |}Y nw xY w|                    d|z             dS )z4Base pprint for all functions and builtin functions.rC   )r%  r&  r'  r(  z<function %s>N)r   rA   rB   r!   r   r   rd   )r   r   r   r   r   func_defs         r   _function_pprintr0    s    ncl;;D
.C
  sCCCSy4Ys^^,,,xx   xxxFF?X%&&&&&s   A AAc           
          t          | j        d| j        j                  }| j        j        dvr| j        j        d|}|                    t          |gt          | dd          R             dS )zBase pprint for all exceptions.rC   )r'  r&  r(  r   rD   N)r   r   rA   rB   r   r   )r   r   r   r   s       r   _exception_pprintr2  (  sv    3=.#-2HIID
}'AAA-222DD9HH^D<73#;#;<<<=====r0   _exception_baser   r   []{}zfrozenset({z})zenviron{zmappingproxy({r   c                 T    t                               | d          }|
|t           | <   |S )z0
    Add a pretty printer for a given type.
    N)r   get)typfuncoldfuncs      r   r   r   _  s.     !!#t,,G#Nr0   c                 \    | |f}t                               |d          }|
|t           |<   |S )z|
    Add a pretty printer for a type specified by the module and name of a type
    rather than the type object itself.
    N)r   r9  )type_module	type_namer;  r   r<  s        r   r   r   i  s9    
 	
"C&**355G(, %Nr0   Tc                    t                               | j        j                  }|r-|                     |t          d                               d S |                     || j        t          |                                d S Nrs   )r   r   r   rA   r   r   default_factorydictr   r   r   cls_ctors       r   _defaultdict_pprintrF  {  sw    %%cm&<==H ;	'%..))*****	#-tCyy99:::::r0   c                    t                               | j        j                  }|r-|                     |t          d                               d S t          |           r?|                     |t          |                                                                d S |                     |                       d S rA  )	r   r   r   rA   r   r   ra   r   r"   rD  s       r   _ordereddict_pprintrH    s    %%cm&<==H 	'%..))*****	S 	$syy{{++,,-----	r0   c                 x   t                               | j        j                  }|r-|                     |t          d                               d S | j        4|                     |t          |           | j                             d S |                     |t          |                                d S )Nrs   )maxlen)r   r   r   rA   r   r   rJ  r   rD  s       r   _deque_pprintrK    s    %%cm&<==H &	'%..))*****			$s))CJ77788888	$s))$$%%%%%r0   c                    t                               | j        j                  }|r-|                     |t          d                               d S t          |           r?|                     |t          |                                                                d S |                     |                       d S rA  )	r   r   r   rA   r   r   ra   rC  most_commonrD  s       r   _counter_pprintrN    s    %%cm&<==H 	'%..))*****	S 	$s00112233333	r0   c                     t                               | j        j                  }|r-|                     |t          d                               d S |                     || j                             d S rA  )r   r   r   rA   r   r   r~   rD  s       r   _userlist_pprintrP    sn    %%cm&<==H %	'%..))*****	#(##$$$$$r0   collectionsdefaultdictOrderedDictr   CounterUserList__main__)	randrangec                       e Zd Zd Zd ZdS )Fooc                     d| _         t          j        d          | _        t                              t          d          t          dd                    | _        d| _	        dd| g| _
        d S )Nrn   z\s+   (   gg@blubblah)foor  compilebarrC  fromkeysrangerW  r]  heher   r   s    r   rQ   zFoo.__init__  sX    DHz&))DHeBii1b1A1ABBDI$DI.DIIIr0   c                 $    t          d           d S )Nr_  )printr   s    r   get_foozFoo.get_foo  s    %LLLLLr0   N)rA   rB   rC   rQ   rg  rD   r0   r   rY  rY    s2        	/ 	/ 	/	 	 	 	 	r0   rY  )r+   r[   )cr   
contextlibr   datetimeosr  r2   r   rQ  r   inspectr   ior   warningsr   IPython.utils.decoratorsr   IPython.utils.py3compatr	   typingr
   __all__r   r   r`  _re_pattern_typer   r#   r   r   r6   r   r   r   r   rW   rh   rL   rN   r   r   r   r   r   r   r  r  r	  r  r  r)  r   r0  r2  __annotations__BaseExceptionr3  	NameErrorr   intfloatr!   r   r   rC  set	frozensetsuperFunctionTypeBuiltinFunctionTyper   SimpleNamespace	timedeltar   environ	_env_typeMappingProxyTypeslicerc  bytesr   r   r   rb  mapr   EllipsisNotImplementedr   rF  rH  rK  rN  rP  rA   randomrW  rY  rD   r0   r   <module>r     s  ] ] ]~ & % % % % %  				 				 



                          * * * * * * ( ( ( ( ( (      U U U 4

2'' 	 	 	 	   T.     T.    * * * * * * * *(} } } } }& } } }@  &e e e e eM e e eP           9    ) ) ) ) )	 ) ) ),         I             >
 
 
 
 
 
 
 
%" %" %" %" %" %" %" %"P        # # #L  ,  6  ,                 ,< < <, , ,! ! !<	  	  	 
' 
' 
'> > >     #OO      OOO 
	  
 5 5c3 ? ?	
 	 5 5c3 ? ? 	 6 6sC @ @  5 5c3 ? ?  5 5mT J J 
  2 	 
 0 
 0 
 
 =  !" #$  1% , D	D!7!7
C!H!HOI*@*@AQSW*X*X& '% % %  "$ $ # # #  
 
 
 }}SSdD%&4.6 &7 &78DF F ; ; ;  & & &  % % %  /B C C C  /B C C C   7 7 7  	? ; ; ;  
,< = = =z      	 	 	 	 	 	 	 	 F3355$ s   	E EE