
    i                         d dl Z ddlmZmZmZmZmZ  G d d      Zd ZddZ	d Z
d	 Zd
 Zg dddfdZedk(  rd dlZ ej                           yy)    N   )colorizeget_short_namesjoin
text_width
wrap_alignc                   T    e Zd Zg dZdddddddddZed        Zd Zd Zd Z	d	 Z
y)
_Node)alignformatwrapmissingshortenN)groupsdisplayr   r   r   r   r   c                    || _         || _        ||n|| _        t        j                  D ]  }	t        | |	t               |	           y N)keyr   r   r
   _propertiessetattrlocals)
selfr   r   r   r   r   r   r   r   props
             I/var/www/stems/demucs_env/lib/python3.12/site-packages/treetable/table.py__init__z_Node.__init__	   sF     %os7%% 	0DD$/	0    c                 ^    | j                   ydt        d | j                   D        d      z   S )Nr   r   c              3   4   K   | ]  }|j                     y wr   )depth).0childs     r   	<genexpr>z_Node.depth.<locals>.<genexpr>   s     AEEKKAs   default)r   maxr   s    r   r   z_Node.depth   s+    ;;sAT[[A1MMMr   c                 ,    t        | j                        S r   )iterr   r&   s    r   __iter__z_Node.__iter__    s    DKK  r   c                     i }t         j                  D ]   }t        | |      }|t        ||      ||<   "  | j                  di |S )N )r
   r   getattrupdate)r   parentupdatesr   my_values        r   inheritz_Node.inherit#   sT    %% 	6DtT*H ' 5	6 t{{%W%%r   c                     | j                   | j                  | j                  d}t        j                  D ]  }t        | |      ||<    |j                  |       t        di |S )N)r   r   r   r+   )r   r   r   r
   r   r,   r-   )r   r/   kwargsr   s       r   r-   z_Node.update+   s_    88kk||

 %% 	/D"4.F4L	/ 	gvr   c                    g }| j                   |j                  | j                          | j                  | j                   k7  r|j                  d| j                          t        j                  D ]'  }t        | |      }||j                  | d|        ) | j                  d}n| j                  d}nd}| }|r|ddj                  |       dz  }| j                  Zg }| j                  D ]0  }|j                  t        j                  t        |      d	             2 d
j                  |      }|d| z  }|S )Nzkey==tableleafgroup(z, )  
z:
)r   appendr   r
   r   r,   r   r   textwrapindentrepr)	r   
repr_partsr   valuenamemy_reprchild_reprsr!   
child_reprs	            r   __repr__z_Node.__repr__7   s=   
<<#dll+88t||#TXXJ/0%% 	5DD$'E !!TF!E7"34	5 88D[[ DDF499Z0133G;;"K G""8??4;#EFG;/JZL))Gr   )__name__
__module____qualname__r   r   propertyr   r)   r1   r-   rG   r+   r   r   r
   r
      sM    CK
 0  N N!&
r   r
   c                     t        d| |d|S N)r   r   r+   r
   )r   r   r3   s      r   r8   r8   T       2S2622r   c                     t        d| |d|S )N)r   r   r+   rN   )r   r   r3   s      r   r7   r7   X   rO   r   c                     t        dd | d|S rM   rN   )r   r3   s     r   r6   r6   \   s    3T&3F33r   c                     g }| D ]@  }||j                   xs d}nt        ||j                  xs d      }|j                  |       B |S )N )r   r   r=   )linesr7   	formattedlinecontents        r   _treetable_terminalrX   `   sT    I "<ll(bGT4;;#4"5G!" r   c           
      `   |j                   }|t        | |      S |j                  }|dz
  t        |      k\  rt	        d| dt        |       d      |D cg c]  }|j
                   }}|j                  rt        |      }n|}g }t        ||      D ]v  \  }}	|j                  |      }|j                   t        |j                         dk(  r=|j                  }
||
z
  }|j                   d u }| D cg c]"  }|j                  |j                  |rd ni       $ }}|rt        ||      }nt        |||      }t        d |D        d      }t        |t        |	            }|j                   "|j                  t        |j                  |      }|r|j
                  d | }n|j
                  d | j!                  |      }d	g|dz
  z  |gz   |z   }|D cg c]  }t#        |||j$                  xs d
        }}|j'                  |       y t)        |||dz
           S c c}w c c}w c c}w )Nr   z2Not enough separators for depth of tree (depth is z	 but got z separators)r   )r8   
separatorsc              3   2   K   | ]  }t        |        y wr   )r   )r    rV   s     r   r"   z_treetable.<locals>.<genexpr>   s     B$Z%Bs   r#   rS   <)width	alignment)	separator)r   rX   r   len
ValueErrorr   r   r   zipr1   getr   
_treetabler%   r   mincenterr   r   r=   r   )rT   r8   rZ   r   r   r!   displaysshort_namescolumns
short_namechild_depthdelta_depthterminalrV   child_lineschild_formattedr]   display_names                     r   rd   rd   k   sM   \\F~"5%00KKEqyC
O#yZ(9GH 	H ,22%2H2}}%h/G 5 (ze$<<#ELL(9Q(>kkk)<<4'FK
>BDHHUYYb9
 
 1+uEO(5ZAOB/BANE3z?+<<EJJ$:

E*E ==%0L ==%077>L$+/2l 68 8:IJ (
 t5EKK4F3G
 
 	'?(@ :eai#899O 3
(
s   H!4'H&#H+)r;   z | z  ||  Fc                 >   t        | ||      } |rt        |       D cg c]   \  }}t        |||t        |      z           " } }}|j                  }| d| }|D cg c]  }t        |d       }}|| d| |r| |ddd   z  } dj                  |       S c c}}w c c}w )a"  
    Pretty-print `lines` using the `table` structure.

    `separators` give the list of sub-tables separators. It needs to be
    as long as the maximum depth of `groups`. Deepest separators comes first.
    If longer than the maximum depth of `groups`, the first ones will be used.

    )rT   r8   rZ   N1r<   )rd   	enumerater   r`   r   r   )	rT   r6   rZ   colorsheader_downindexrV   r   headers	            r   	treetablery      s     U%JGE  )/
t T6%#f+"567
 
 v289$(4%99fuVDbD\!E99U
 :s   %BB__main__)rS   )r>   textr   r   r   r   r   r
   r8   r7   r6   rX   rd   ry   rH   doctesttestmodr+   r   r   <module>r~      sb     I IK K\3342:j (?tY^ 0 zGOO r   