B e]e @sPddlmZmZddlmZmZmZddddZdd dZdddZ ddZ dS))unicode_literalsprint_function) to_string zip_longest basestring_<>^)lrcNFautoc CsDt|trt|}|rg} x^t|D]R\} } dd| D} | tt| ddi| t|dkr(| dd| Dq(W| }|dkrt ||||}|||| d}t d d|Df|}g}|r|t |f||r||x&t|D]\} } |t | f|qW|r4|r"|||t |f|d d |S) aFormat tabular data. data (iterable / dict): The data to render. Either a list of lists (one per row) or a dict for two-column tables. header (iterable): The header columns. footer (iterable): The footer columns. divider (bool): Show a divider line between header/footer and body. widths (iterable or 'auto'): Column widths in order. If "auto", widths will be calculated automatically based on the largest value. max_col (int): Maximum column width. spacing (int): Spacing between columns, in spaces. aligns (iterable / unicode): Column alignments in order. 'l' (left, default), 'r' (right) or 'c' (center). If a string, value is used for all columns. multiline (bool): If a cell value is a list of a tuple, render it on multiple lines, with one value per line. indent (int): Number of spaces to use for indentation. RETURNS (unicode): The formatted table. cSs$g|]}t|ttfr|n|gqS) isinstancelisttuple).0vrr1/tmp/pip-install-b8evvk6i/wasabi/wasabi/tables.py .sztable.. fillvaluercSsg|]}dqS)rr)rirrrr1sr)widthsspacingalignsindentcSsg|] }d|qS)-r)rwidthrrrr;sz {}  ) rdictritems enumerateextendrlenappend_get_max_widthsrowformatjoin)dataheaderfooterdividerrmax_colrr multilinerZ zipped_dataritemvalssettingsZ divider_rowZrowsrrrtable s:    r6c sg}ttr fdd|DtdsDfddtt|Dxnt|D]b\}}trr|tkrr|nd}dkrt|n|} d|| f} || t |qNW|dd| |S) apFormat data as a table row. data (iterable): The individual columns to format. widths (iterable, int or 'auto'): Column widths, either one integer for all columns or an iterable of values. If "auto", widths will be calculated automatically based on the largest value. spacing (int): Spacing between columns, in spaces. aligns (iterable / unicode): Column alignments in order. 'l' (left, default), 'r' (right) or 'c' (center). If a string, value is used for all columns. indent (int): Number of spaces to use for indentation. RETURNS (unicode): The formatted row. csg|]}qSrr)r_)rrrrZszrow..__iter__csg|]}qSrr)rr7)rrrr\sr rz{:%s%d} ) rrhasattrranger'r% ALIGN_MAPgetr(r+rr,) r-rrrrcolsrcolZalignZ col_widthtplr)rrrr*Js  " r*csLt|}|r|||r$||dd|D}fddtt|DS)NcSsg|]}dd|DqS)cSsg|]}tt|qSr)r'r)rr?rrrrksz._get_max_widths...r)rr3rrrrksz#_get_max_widths..csg|]}tt|qSr)minmax)rw)r1rrrls)rr(zip)r-r.r/r1Zall_datarr)r1rr)es  r)) NNFrrrNFr)rrNr) __future__rrutilrrrr<r6r*r)rrrrs  6