U cf@sDddlmZddlmZddlmZddlmZmZm Z m Z m Z ddl m Z mZddlmZmZmZmZddlmZdd lmZdd lmZmZdd lmZdd lmZdd lm Z Gddde Z!e"dkr@ddl#Z#eZdde$e%e#&DZ'e!e'ddddZ(e)e(e*de(_+e)e(de(_,e*e)e(dS)) defaultdict)chain) itemgetter)DictIterableListOptionalTuple)Align AlignMethod)ConsoleConsoleOptionsRenderableType RenderResult Constrain) Measurement)PaddingPaddingDimensions)Table)TextType) JupyterMixinc @szeZdZdZdddddddddeeeeeee e e e ee ee dd ddZ edd d d Z eeed d dZdS)ColumnsaDisplay renderables in neat columns. Args: renderables (Iterable[RenderableType]): Any number of Rich renderables (including str). width (int, optional): The desired width of the columns, or None to auto detect. Defaults to None. padding (PaddingDimensions, optional): Optional padding around cells. Defaults to (0, 1). expand (bool, optional): Expand columns to full width. Defaults to False. equal (bool, optional): Arrange in to equal sized columns. Defaults to False. column_first (bool, optional): Align items from top to bottom (rather than left to right). Defaults to False. right_to_left (bool, optional): Start column from right hand side. Defaults to False. align (str, optional): Align value ("left", "right", or "center") or None for default. Defaults to None. title (TextType, optional): Optional title for Columns. Nrr F)widthexpandequal column_first right_to_leftaligntitle) renderablespaddingrrrrrr r!returnc CsBt|pg|_||_||_||_||_||_||_||_| |_ dSN) listr"rr#rrrrr r!) selfr"r#rrrrrr r!r(F/opt/hc_python/lib/python3.8/site-packages/pip/_vendor/rich/columns.py__init__s zColumns.__init__) renderabler$cCs|j|dS)zxAdd a renderable to the columns. Args: renderable (RenderableType): Any renderable object. N)r"append)r'r+r(r(r)add_renderable6szColumns.add_renderable)consoleoptionsr$c#sNjfdd jDs"dSt j\}}}}t||}j}tt} t } t j fddD j rtgt tt ttttfd fdd } tj jddd } j| _ j| _ jdk r | j|} t| D]} | j jd qn| d kr| d }| | D]b\}} t| ||| |<t| |t | d }||kr~t | d } q n |d | }q*qq td fd d| | D} j r·fdd|D} jr jtfdd|D} j}| j}td t || D]2}|||| }|r8|ddd}||q| VdS)Ncs"g|]}t|tr|n|qSr() isinstancestr.0r+) render_strr(r) Bsz,Columns.__rich_console__..csg|]}|jqSr()maximumr2)r.get_measurementr/r(r)r5Os) column_countr$c 3s&t}jrtt}|g}t|D]}||d7<q6|d}fddt|D}d}}t|D]>} | |||<||d8<||r|d7}q|d7}d}qt|D]} | dkrq|| VqntEdH|r"t|D] } dVqdS)Nr csg|]}dgqS)r()r3_r8r(r)r5bszFColumns.__rich_console__..iter_renderables..rr9)rN)lenrr&zipranger from_iterable) r8 item_countwidth_renderablescolumn_lengthscol_no row_countcellsrowcolindexr:)renderable_widthsr"r'r;r)iter_renderablesVs0    z2Columns.__rich_console__..iter_renderablesTF)r#collapse_paddingpad_edge)rr rcsg|] }|qSr(r()r3 _renderable)get_renderabler(r)r5scs&g|]}|dkrdn t|dqS)Nrrr2)rIr(r)r5scs"g|]}|dkrdn|qSr%r(r2)_Alignr r(r)r5sr9) r4r"runpackr#max max_widthrintr<rgetrrr rrrgridrr!rr> add_columnclearsumvaluesrr r radd_row)r'r.r/_topright_bottomleft width_paddingrRwidthsr8rJtabler: column_norenderable_width total_width _renderablesrrZstartrFr() rOr r.r7rNr/r4rIr"r'r)__rich_console__>s|  !           zColumns.__rich_console__)Nr)__name__ __module__ __qualname____doc__rrrrrSboolr rr*r-r rrrgr(r(r(r)rs8   r__main__NcCsg|]\}}|d|qS) r()r3isr(r(r)r5sr5rF)r#rrT)- collectionsr itertoolsroperatorrtypingrrrrr r r r r.r rrr constrainrmeasurerr#rrrartextrjupyterrrrhos enumeratesortedlistdirfilescolumnsprintrulerrr(r(r(r)s2