>,Xc@sddlZddlZyddlZWnek r;nXddlmZdefdYZdefdYZdej krdej fd YZ ndefd YZ dd Z dS( iN(tArgtTabifyingMixincBs;eZdZedddddddgZddZRS( s A command mixin that provides the tabify() function along with its associated --show-empty-fields command line arg. s--show-empty-fieldstactiont store_truetroute_tothelpsshow empty values as "(nil)"cCsB|jdrd}nd}djdt||d|DS(s Join a list of strings with tabs. Nonzero items that Python considers false are printed as-is if they appear in the include list, replaced with '(nil)' if the user specifies --show-empty-fields at the command line, and omitted otherwise. tshow_empty_fieldss(nil)ts css|]}t|VqdS(N(tstr(t.0ts((sD/usr/lib/python2.7/site-packages/requestbuilder/mixins/formatting.pys .stinclude(targstjoint_filter_row_values(tselftfieldsR tfstr((sD/usr/lib/python2.7/site-packages/requestbuilder/mixins/formatting.pyttabify#s    N(t__name__t __module__t__doc__RtNonetARGSR(((sD/usr/lib/python2.7/site-packages/requestbuilder/mixins/formatting.pyRs tTableOutputMixinc BsMeZeddddd ddeddddd ddgZdZRS( s--show-headersRRRRsshow column headerss--show-empty-fieldss"show empty field values as "(nil)"cCsmtd|d|jjd}t|_|jjdp?t|_d|_d|_d|_d|_ |S( Nt field_namest show_emptyRt show_headerstuppertlii( t_FilteredTableR tgettFalsetbordertheadert header_styletaligntleft_padding_widthtright_padding_width(RRttable((sD/usr/lib/python2.7/site-packages/requestbuilder/mixins/formatting.pyt get_table8s      N(RRRRRR((((sD/usr/lib/python2.7/site-packages/requestbuilder/mixins/formatting.pyR2s  t prettytableRcBseZedZdZRS(cKs2|rd|_n d|_tjj||dS(Ns(nil)R(t_FilteredTable__emptyR)t PrettyTablet__init__(RRtkwargs((sD/usr/lib/python2.7/site-packages/requestbuilder/mixins/formatting.pyR,Fs  cCs#tjj|t||jdS(N(R)R+tadd_rowRR*(Rtrow((sD/usr/lib/python2.7/site-packages/requestbuilder/mixins/formatting.pyR.Ms (RRR R,R.(((sD/usr/lib/python2.7/site-packages/requestbuilder/mixins/formatting.pyREs cBsPeZedZdZedZejdZdZdZ RS(cCsL||_t|_t|_g|_d|_|r?d|_n d|_dS(Nis(nil)R(RR R"t reversesortt_rowst _sortindexR*(RRR((sD/usr/lib/python2.7/site-packages/requestbuilder/mixins/formatting.pyR,Ss      cCset|t|jkrEtdjt|t|jn|jjt||jdS(Ns<row has incorrect number of values ({0} given, {1} expected)(tlenRt ValueErrortformatR1tappendRR*(RR/((sD/usr/lib/python2.7/site-packages/requestbuilder/mixins/formatting.pyR.^s !cCs|j|jS(N(RR2(R((sD/usr/lib/python2.7/site-packages/requestbuilder/mixins/formatting.pytsortbyescCs|jj||_dS(N(RtindexR2(Rtfield((sD/usr/lib/python2.7/site-packages/requestbuilder/mixins/formatting.pyR7iscCsg}|jr5|jdjd|jDnxQt|jd|jdtj|j D]%}|jdjt t |q`Wdj|S(Ns css|]}|jVqdS(N(R(R tname((sD/usr/lib/python2.7/site-packages/requestbuilder/mixins/formatting.pys pstreversetkeys ( R"R6R RtsortedR1R0toperatort itemgetterR2tmapR(RtlinesR/((sD/usr/lib/python2.7/site-packages/requestbuilder/mixins/formatting.pyt get_stringms #cCs |jS(N(RB(R((sD/usr/lib/python2.7/site-packages/requestbuilder/mixins/formatting.pyt__str__ws( RRR R,R.tpropertyR7tsetterRBRC(((sD/usr/lib/python2.7/site-packages/requestbuilder/mixins/formatting.pyRRs   cCswg}xj|D]b}|sR|dksRt|tr@|dksR||pLgkrb|j|q |j|q W|S(Ni(t isinstancetfloatR6(R/t empty_strR tfilteredR9((sD/usr/lib/python2.7/site-packages/requestbuilder/mixins/formatting.pyR{s -(R>tsysR)t ImportErrortrequestbuilderRtobjectRRtmodulesR+RRR(((sD/usr/lib/python2.7/site-packages/requestbuilder/mixins/formatting.pyts    )