o 7]h@sFddlmZddlmZddlmZddlmZmZm Z m Z m Z ddl m Z mZddlmZmZmZmZddlmZdd lmZdd lmZmZdd lmZdd lmZdd lm Z Gddde Z!e"dkrddl#Z#eZdde$e%e#&DZ'e!e'ddddZ(e)e(e*de(_+e)e(de(_,e*e)e(dSdS)) defaultdict)chain) itemgetter)DictIterableListOptionalTuple)Align AlignMethod)ConsoleConsoleOptionsRenderableType RenderResult Constrain) Measurement)PaddingPaddingDimensions)Table)TextType) JupyterMixinc@seZdZdZ  ddddddddddeeededeed e d e d e d e d ee dee ddfddZ deddfddZ dededefddZdS)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(:/usr/lib/python3/dist-packages/pip/_vendor/rich/columns.py__init__s  zColumns.__init__ renderablecCs|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_renderableconsoleoptionsc#sDjfdd jDsdSt j\}}}}t||}j}tt} t } t j fddD j rFtgt dtdt ttttff fdd } tj jdd d } j| _ j| _ jdur| j|} t| D] } | j jd q|nA| d kr| d }| | D]-\}} t| ||| |<t| |t | d }||krt | d } n|d | }qn| d kstd fdd| | D} j rfdd|D} jr jtfdd|D} j}| j}td t || D]}|||| }|r|ddd}||q| VdS)Ncs"g|] }t|tr |n|qSr() isinstancestr.0r+) render_strr(r) Bz,Columns.__rich_console__..csg|] }|jqSr()maximumr2)r.get_measurementr/r(r)r5Os  column_countr$c 3s(t}jrvtt}|g}t|D] }||d7<q|d}fddt|D}d}}t|D]} | |||<||d8<||r[|d7}qB|d7}d}qBt|D] } | dkron|| VqgntEdH|rt|D]} dVqdSdS)Nr csg|]}dgqS)r()r3_r9r(r)r5bszFColumns.__rich_console__..iter_renderables..rr:)rN)lenrr&zipranger from_iterable) r9 item_countwidth_renderablescolumn_lengthscol_no row_countcellsrowcolindexr;)renderable_widthsr"r'r<r)iter_renderablesVs8    z2Columns.__rich_console__..iter_renderablesTF)r#collapse_paddingpad_edge)rr rcsg|]}|qSr(r()r3 _renderable)get_renderabler(r)r5scs&g|]}|dur dnt|dqS)Nrrr2)rJr(r)r5s  cs"g|] }|dur dn|qSr%r(r2)_Alignr r(r)r5r6r:) r4r"runpackr#max max_widthrintr=rgetrrr rrrgridrr!rr? add_columnclearsumvaluesrr r radd_row)r'r.r/_topright_bottomleft width_paddingrSwidthsr9rKtabler; column_norenderable_width total_width _renderablesrr[startrGr() rPr r.r8rOr/r4rJr"r'r)__rich_console__>s  !          zColumns.__rich_console__)Nr)__name__ __module__ __qualname____doc__rrrrrTboolr rr*r-r rrrhr(r(r(r)rsR     r__main__NcCsg|] \}}|d|qS) r()r3isr(r(r)r5sr5rF)r#rrT)- collectionsr itertoolsroperatorrtypingrrrrr r r r r.r rrr constrainrmeasurerr#rrrbrtextrjupyterrrrios enumeratesortedlistdirfilescolumnsprintrulerrr(r(r(r)s6