U C^@sPddlmZmZddlmZmZmZddddZdd dZdddZ ddZ dS))unicode_literalsprint_function) to_string zip_longest basestring_<>^)lrcNFautoc Cs:t|trt|}|r~g} t|D]R\} } dd| D} | tt| ddi| t|dkr&| dd| Dq&| }|dkrt ||||}|||d} t d d|Df| }g}|r|t |f| |r||t|D]\} } |t | f| q|r*|r|||t |f| d d |S) awFormat 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. RETURNS (unicode): The formatted table. cSs$g|]}t|ttfr|n|gqS) isinstancelisttuple).0vrr1/tmp/pip-install-6_kvzl1k/wasabi/wasabi/tables.py ,sztable.. fillvaluercSsg|]}dqS)rr)rirrrr/sr)widthsspacingalignscSsg|] }d|qS)-r)rwidthrrrr4sz {}  ) rdictritems enumerateextendrlenappend_get_max_widthsrowformatjoin)dataheaderfooterdividerrmax_colrr multilineZ zipped_dataritemvalssettingsZ divider_rowZrowsrrrtable s4     r5c sg}ttr fdd|DtdsDfddtt|Dt|D]b\}}trp|tkrp|nd}dkrt|n|}d||f} || t |qLd| |S) a5Format 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. RETURNS (unicode): The formatted row. csg|]}qSrrr_)rrrrRszrow..__iter__csg|]}qSrrr6)rrrrTsr rz{:%s%d} ) rrhasattrranger&r$ ALIGN_MAPgetr'r*rr+) r,rrrcolsrcolZalignZ col_widthtplr)rrrr)Cs   " r)csLt|}|r|||r$||dd|D}fddtt|DS)NcSsg|]}dd|DqS)cSsg|]}tt|qSr)r&r)rr?rrrrcsz._get_max_widths...r)rr2rrrrcsz#_get_max_widths..csg|]}tt|qSr)minmax)rwr0rrrds)rr'zip)r,r-r.r0Zall_datarrrDrr(]s  r()NNFrrrNF)rrN) __future__rrutilrrrr<r5r)r(rrrrs  9