
    [FiL                     $   d dl Zd dlZd dlm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 d d
l
mZ d dl
mZ  G d d      Zd Z G d d      Z eeeeeee ed      eh      Z dedefdZ!dedededee   fdZ"y)    N)StringIO)Any)Callable)Dict)IO)Iterator)List)Optional)Set)Tuplec                   "    e Zd ZdZdgZd Zd Zy)	_safe_keyaU  Helper function for key functions when sorting unorderable objects.

    The wrapped-object will fallback to a Py2.x style comparison for
    unorderable types (sorting first comparing the type name and then by
    the obj ids).  Does not work recursively, so dict.items() must have
    _safe_key applied to both the key and the value.

    objc                     || _         y N)r   )selfr   s     d/var/www/html/BankruptcyAI-uat/bankruptcy-ai/venv/lib/python3.12/site-packages/_pytest/_io/pprint.py__init__z_safe_key.__init__,   s	        c                 "   	 | j                   |j                   k  S # t        $ rj t        t        | j                               t	        | j                         ft        t        |j                               t	        |j                         fk  cY S w xY wr   )r   	TypeErrorstrtypeid)r   others     r   __lt__z_safe_key.__lt__/   sp    	88eii'' 	TXX'DHH6DO$599:  	s    A0BBN)__name__
__module____qualname____doc__	__slots__r   r    r   r   r   r       s     Ir   r   c                 :    t        | d         t        | d         fS )z&Helper function for comparing 2-tuplesr      )r   )ts    r   _safe_tupler&   9   s    QqT?IadO++r   c                      e Zd ZU 	 	 	 d)dededee   ddfdZdedefdZded	e	e   ded
ede
e   deddfdZded	e	e   ded
ede
e   deddfdZi Zeedef   ed ee	e   eee
e   egdf   f   ed<   ded	e	e   ded
ede
e   deddfdZeeej&                  <   ded	e	e   ded
ede
e   deddfdZeeej,                  j&                  <   ded	e	e   ded
ede
e   deddfdZeeej&                  <   ded	e	e   ded
ede
e   deddfdZeeej&                  <   ded	e	e   ded
ede
e   deddfdZeeej&                  <   eeej&                  <   ded	e	e   ded
ede
e   deddfdZeeej&                  <   ded	e	e   ded
ede
e   deddfdZeee j&                  <   ded	e	e   ded
ede
e   deddfdZ!e!ee"j&                  <   ded	e	e   ded
ede
e   deddfdZ#e#ee$jJ                  j&                  <   ded	e	e   ded
ede
e   deddfdZ&e&ee$jN                  j&                  <   de(e)eef      d	e	e   ded
ede
e   deddfdZ*de(e)eef      d	e	e   ded
ede
e   deddfdZ+de(e   d	e	e   ded
ede
e   deddfdZ,dede
e   dedefdZ-ded	e	e   ded
ede
e   deddfd Z.e.eej^                  j&                  <   ded	e	e   ded
ede
e   deddfd!Z0e0eejb                  j&                  <   ded	e	e   ded
ede
e   deddfd"Z2e2eejf                  j&                  <   ded	e	e   ded
ede
e   deddfd#Z4e4eejj                  j&                  <   ded	e	e   ded
ede
e   deddfd$Z6e6eejn                  j&                  <   ded	e	e   ded
ede
e   deddfd%Z8e8eejr                  j&                  <   ded	e	e   ded
ede
e   deddfd&Z:e:eejv                  j&                  <   dede
e   d'ee   dedef
d(Z<y)*PrettyPrinterNindentwidthdepthreturnc                     |dk  rt        d      ||dk  rt        d      |st        d      || _        || _        || _        y)aT  Handle pretty printing operations onto a stream using a set of
        configured parameters.

        indent
            Number of spaces to indent for each level of nesting.

        width
            Attempted maximum number of columns in the output.

        depth
            The maximum depth to print out nested structures.

        r   zindent must be >= 0Nzdepth must be > 0zwidth must be != 0)
ValueError_depth_indent_per_level_width)r   r)   r*   r+   s       r   r   zPrettyPrinter.__init__?   sT    & A:233!011122!'r   objectc                 r    t               }| j                  ||ddt               d       |j                         S )Nr   )	_StringIO_formatsetgetvalue)r   r2   sios      r   pformatzPrettyPrinter.pformat\   s-    kVS!Qq1||~r   stream	allowancecontextlevelc           
         t        |      }||v r|j                  t        |             y | j                  j	                  t        |      j                  d       }|4|j                  |        || ||||||dz          |j                  |       y t        j                  |      rt        |t
              s|j                  j                  rtt        |j                  d      r^d|j                  j                  j                   v r<|j                  |       | j#                  ||||||dz          |j                  |       y |j                  | j%                  |||             y )Nr$   __wrapped____create_fn__)r   write
_recursion	_dispatchgetr   __repr__addremove_dataclassesis_dataclass
isinstance__dataclass_params__reprhasattrr?   r   _pprint_dataclass_repr)	r   r2   r:   r)   r;   r<   r=   objidps	            r   r5   zPrettyPrinter._formata   s    6
GLLF+,NNtF|44d;=KKdFFFIw	JNN5!%%f-vt,++00 FOO]36??#>#>#K#KKKK""	7EAI NN5!LLFGU;<r   c                 L   |j                   j                  }t        j                  |      D cg c]0  }|j                  r"|j
                  t        ||j
                        f2 }	}|j                  |dz          | j                  |	|||||       |j                  d       y c c}w N())		__class__r   rH   fieldsrL   namegetattrrA   _format_namespace_items)
r   r2   r:   r)   r;   r<   r=   cls_namefitemss
             r   rN   zPrettyPrinter._pprint_dataclass   s     ##,, "((0
vv VVWVQVV,-
 

 	X^$$$UFFIwPUVS
s   5B!.rC   c                     |j                   } |d       t        |j                         t              }| j	                  ||||||        |d       y )N{key})rA   sortedr]   r&   _format_dict_items)	r   r2   r:   r)   r;   r<   r=   rA   r]   s	            r   _pprint_dictzPrettyPrinter._pprint_dict   sE     c
v||~;7vvy'5Qc
r   c                     t        |      s|j                  t        |             y |j                  }|j                  |j                  dz          | j                  ||||||       |j                  d       y rS   )lenrA   rL   rV   r   re   )r   r2   r:   r)   r;   r<   r=   clss           r   _pprint_ordered_dictz"PrettyPrinter._pprint_ordered_dict   sb     6{LLf&S\\C'(&&&)WeLSr   c                 t    |j                  d       | j                  ||||||       |j                  d       y )N[]rA   _format_itemsr   r2   r:   r)   r;   r<   r=   s          r   _pprint_listzPrettyPrinter._pprint_list   4     	S6669guMSr   c                 t    |j                  d       | j                  ||||||       |j                  d       y rS   rm   ro   s          r   _pprint_tuplezPrettyPrinter._pprint_tuple   rq   r   c                 P   t        |      s|j                  t        |             y |j                  }|t        u r|j                  d       d}n |j                  |j
                  dz          d}t        |t              }| j                  ||||||       |j                  |       y )Nr_   rb   z({z})r`   )	rg   rA   rL   rV   r6   r   rc   r   rn   )	r   r2   r:   r)   r;   r<   r=   typendchars	            r   _pprint_setzPrettyPrinter._pprint_set   s     6{LLf&#:LLGLL,-GI.6669guMWr   c                    |j                   }t        |      s |t        |             y g }|j                  d      }	|dk(  r
|dz  }|dz  }| j                  |z
  x}
}t        |	      D ]  \  }}t        |      }|t        |	      dz
  k(  r|
|z  }
t        |      |
k  r|j                  |       Ht        j                  d|      }|sJ |d   rJ |j                          |}d}t        |      D ]i  \  }}||z   }|t        |      dz
  k(  r|t        |	      dz
  k(  r||z  }t        t        |            |kD  r|r|j                  t        |             |}h|}k |s|j                  t        |              t        |      dk(  r	 |       y |dk(  r |d       t        |      D ]   \  }}|dkD  r |dd	|z  z           ||       " |dk(  r	 |d
       y y )NTr$   z\S*\s* rT   r   
 rU   )
rA   rg   rL   
splitlinesr1   	enumerateappendrefindallpop)r   r2   r:   r)   r;   r<   r=   rA   chunkslines
max_width1	max_widthilinerepparts
max_width2currentjpart	candidates                        r   _pprint_strzPrettyPrinter._pprint_str   s    6{$v,!!$'A:aKFNI!%v!55
Y ' 	1GAtt*CCJN"i'
3x:%c" 

9d3u 9$}		&
(/ 	,GAt '$ICJN*qCJN/B"i/
4	?+j8""MM$w-8"&"+	, MM$w-03	14 v;!#JA:#J' 	FAs1udS6\)*#J	 A:#J r   c                    |j                   }t        |      dk  r |t        |             y |dk(  }|r|dz  }|dz  } |d       d}	t        || j                  |z
  |      D ]  }
 ||	        ||
       |	rdd|z  z   }	 |r	 |d       y y )N   r$   rT   rz   r{   r|   rU   )rA   rg   rL   _wrap_bytes_reprr1   )r   r2   r:   r)   r;   r<   r=   rA   parensdelimr   s              r   _pprint_byteszPrettyPrinter._pprint_bytes4  s     v;!$v,!aKFNI#J#FDKK&,@)L 	,C%L#JsV|+		,
 #J r   c           	          |j                   } |d       | j                  t        |      ||dz   |dz   ||dz           |d       y )Nz
bytearray(
   r$   rU   )rA   r   bytes)r   r2   r:   r)   r;   r<   r=   rA   s           r   _pprint_bytearrayzPrettyPrinter._pprint_bytearrayQ  sJ     l&M66B;	AwPQ		
 	c
r   c                     |j                  d       | j                  |j                         |||||       |j                  d       y )Nzmappingproxy(rU   )rA   r5   copyro   s          r   _pprint_mappingproxyz"PrettyPrinter._pprint_mappingproxyc  s8     	_%V[[]FFIwNSr   c                    t        |      t        j                  u rd}n|j                  j                  }|j
                  j                         }|j                  |dz          | j                  ||||||       |j                  d       y )N	namespacerT   rU   )	r   _typesSimpleNamespacerV   r   __dict__r]   rA   rZ   )	r   r2   r:   r)   r;   r<   r=   r[   r]   s	            r   _pprint_simplenamespacez%PrettyPrinter._pprint_simplenamespacer  su     <6111 #H''00H%%'X^$$$UFFIwPUVSr   r]   c           	         |sy |j                   }|| j                  z   }dd|z  z   }	|D ]L  \  }
} ||	        || j                  |
||              |d       | j                  |||d||        |d       N  |dd|z  z          y )Nr{   r|   : r$   ,)rA   r0   rO   r5   r   r]   r:   r)   r;   r<   r=   rA   item_indentdelimnlra   ents               r   rd   z PrettyPrinter._format_dict_items  s     t555{** 	HC'N$**S'512$KLLfk1guE#J	 	dS6\!"r   c           	      6   |sy |j                   }|| j                  z   }dd|z  z   }	|D ]`  \  }
} ||	        ||
        |d       t        |      |v r	 |d       n%| j                  |||t	        |
      z   dz   d||        |d       b  |dd|z  z          y )Nr{   r|   =...r$   r   )rA   r0   r   r5   rg   r   s               r   rZ   z%PrettyPrinter._format_namespace_items  s     t555{** 	HC'N#J#J#w'! e#c(*Q. #J%	( 	dS6\!"r   c           	          |sy |j                   }|| j                  z   }dd|z  z   }	|D ](  }
 ||	       | j                  |
||d||        |d       *  |dd|z  z          y )Nr{   r|   r$   r   )rA   r0   r5   )r   r]   r:   r)   r;   r<   r=   rA   r   r   items              r   rn   zPrettyPrinter._format_items  sx     t555{** 	D'NLLv{AwF#J	
 	dS6\!"r   c                 Z    | j                  ||j                         | j                  |      S r   )
_safe_reprr   r/   )r   r2   r<   r=   s       r   rO   zPrettyPrinter._repr  s!    vw||~t{{EJJr   c                     | j                  |j                  ||      }|j                  |j                  j                   d| d       | j                  ||||||       |j                  d       y )NrT   , rU   )rO   default_factoryrA   rV   r   re   )r   r2   r:   r)   r;   r<   r=   rdfs           r   _pprint_default_dictz"PrettyPrinter._pprint_default_dict  sf     jj//%@((112!C5;<&&&)WeLSr   c                 
   |j                  |j                  j                  dz          |rH|j                  d       |j                         }| j	                  ||||||       |j                  d       |j                  d       y )NrT   r_   rb   rU   )rA   rV   r   most_commonrd   )r   r2   r:   r)   r;   r<   r=   r]   s           r   _pprint_counterzPrettyPrinter._pprint_counter  sn     	V%%..45LL&&(E##E669guULLSr   c                 v   t        |j                        r0t        |j                        dk(  r3t        |j                  d         s|j                  t        |             y |j                  |j                  j
                  dz          | j                  |j                  |||||       |j                  d       y )Nr$   r   rT   rU   )rg   mapsrA   rL   rV   r   rn   ro   s          r   _pprint_chain_mapzPrettyPrinter._pprint_chain_map  s     6;;C$4$9#fkkRSnBULLf&V%%..456;;	7ERSr   c                    |j                  |j                  j                  dz          |j                  |j                  d|j                  z         |j                  d       | j	                  ||||dz   ||       |j                  d       y )NrT   zmaxlen=%d, rk   r$   z]))rA   rV   r   maxlenrn   ro   s          r   _pprint_dequezPrettyPrinter._pprint_deque  st     	V%%..45==$LL67S6669q='5QTr   c           	      J    | j                  |j                  |||||dz
         y Nr$   r5   dataro   s          r   _pprint_user_dictzPrettyPrinter._pprint_user_dict*  "     	V[[&&)WeaiPr   c           	      J    | j                  |j                  |||||dz
         y r   r   ro   s          r   _pprint_user_listzPrettyPrinter._pprint_user_list7  r   r   c           	      J    | j                  |j                  |||||dz
         y r   r   ro   s          r   _pprint_user_stringz!PrettyPrinter._pprint_user_stringD  r   r   	maxlevelsc                 J   t        |      }|t        v rt        |      S t        |dd       }t	        |t
              r|t
        j                  u r|syt        |      }|r||k\  ry||v rt        |      S |j                  |       g }|j                  }	|dz  }t        |j                         t              D ]:  \  }
}| j                  |
|||      }| j                  ||||      } |	| d|        < |j                  |       ddj!                  |      z  S t	        |t"              r|t"        j                  u s"t	        |t$              r|t$        j                  u rt	        |t"              r|sy	d
}nt'        |      dk(  rd}n|syd}t        |      }|r
||k\  r|dz  S ||v rt        |      S |j                  |       g }|j                  }	|dz  }|D ]  }| j                  ||||      } |	|         |j                  |       |dj!                  |      z  S t        |      S )NrE   z{}z{...}r$   r`   r   z{%s}r   z[]z[%s]z(%s,)z()z(%s)r   )r   _builtin_scalarsrL   rY   
issubclassdictrE   r   rB   rF   r   rc   r]   r&   r   rG   joinlisttuplerg   )r   r2   r<   r   r=   ru   rrP   
componentsr   kvkreprvreprformatooreprs                    r   r   zPrettyPrinter._safe_reprQ  s    6l""<CT*c4 Q$--%7vJEUi/!&))KK$&J&&FQJEv||~;? ,17IuE7IuE%5'*+, NN5!DIIj111sD!a4==&8sE"qENN':#t$V! vJEUi/~%!&))KKJ&&FQJE 7IuEu NN5!DIIj111F|r   )r   P   N)=r   r   r   intr
   r   r   r   r9   r   r   r5   rN   rC   r   r   __annotations__re   r   rE   ri   _collectionsOrderedDictrp   r   rs   r   rw   r6   	frozensetr   r   r   r   	bytearrayr   r   MappingProxyTyper   r   r	   r   rd   rZ   rn   rO   r   defaultdictr   Counterr   ChainMapr   dequer   UserDictr   UserListr   
UserStringr   r"   r   r   r(   r(   >   s	    #	  }	
 
:c c 
"="= 3"= 	"=
 "= S"= "= 
"=H 3 	
  S  
, 	 tc/33c3s8SI4OP	R 
 3 	
  S  
  ,Idmm 3 	
  S  
" 4HIl&&//0 3 	
  S  
  ,Idmm 3 	
  S  
 !.Ienn 3 	
  S  
. *Icll$/Ii  !77 37 	7
 7 S7 7 
7r *Icll 3 	
  S  
6 !.Ienn 3 	
  S  
  %6Ii  ! 3 	
  S  
 3GIf%%../ 3 	
  S  
( 2IIf$$--.#E#s(O$# 3# 	#
 # S# # 
#0##E#s(O$## 3## 	##
 ## S## ## 
##J#Cy# 3# 	#
 # S# # 
#.KC K#c( K3 K3 K 3 	
  S  
 4HIl&&//0 3 	
  S  
& 0?Il""++, 3 	
  S  
" 1BIl##,,- 3 	
  S  
" .;Il  ))*	Q	Q 3	Q 		Q
 	Q S	Q 	Q 
	Q 1BIl##,,-	Q	Q 3	Q 		Q
 	Q S	Q 	Q 
	Q 1BIl##,,-	Q	Q 3	Q 		Q
 	Q S	Q 	Q 
	Q 3FIl%%../88$'H89A#8OR8	8r   r(   r2   r,   c                 L    dt        |       j                   dt        |        dS )Nz<Recursion on z	 with id=>)r   r   r   )r2   s    r   rB   rB     s&    DL112)BvJ<qIIr   r*   r;   c              #     K   d}t        |       dz  dz  }t        dt        |       d      D ]D  }| ||dz    }||z   }||k(  r||z  }t        t        |            |kD  r|rt        |       |}C|}F |rt        |       y y w)Nr   r   r   )rg   rangerL   )r2   r*   r;   r   lastr   r   r   s           r   r   r     s     Gv;!aD1c&k1% 
 a!a% dN	9YEtI%'7m#GG
  7m s   BB)#collectionsr   dataclassesrH   ior   r4   r   typesr   typingr   r   r   r   r   r	   r
   r   r   r   r&   r(   r   r   r   r   floatcomplexboolr   r   r   rB   r   r"   r   r   <module>r      s     # " $ 	           2,
K	 K	\ %E7D$t*cB 
Js Js JS   # r   