ó >é,Xc@sÉddlZddlZyddlZWnek r;nXddlmZdefd„ƒYZdefd„ƒYZdej kr£dej fd „ƒYZ ndefd „ƒYZ dd „Z dS( iÿÿÿÿN(tArgtTabifyingMixincBs;eZdZedddddddƒgZdd„ZRS( 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}djd„t||d|ƒDƒƒS(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 ddƒeddddd ddƒgZd„ZRS( s--show-headersRRRRsshow column headerss--show-empty-fieldss"show empty field values as "(nil)"cCsmtd|d|jjdƒƒ}t|_|jjdƒp?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 prettytableRcBseZed„Zd„ZRS(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||jƒƒdS(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 cBsPeZed„Zd„Zed„ƒZejd„ƒZd„Zd„Z 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|jƒkrEtdjt|ƒt|jƒƒƒ‚n|jjt||jƒƒdS(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.pyR7iscCs–g}|jr5|jdjd„|jDƒƒƒnxQt|jd|jdtj|j ƒƒD]%}|jdjt t |ƒƒƒq`Wdj|ƒS(Ns css|]}|jƒVqdS(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 |jƒS(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|tƒr@|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    )