ó Û@ŸSc@sºdZddlmZdZddlZddlmZddlmZddlm Z d„Z d„Z d d „Z d e fd „ƒYZdd lTddlmZddlmZdS(s¡Universal report objects and some formatting drivers. A way to create simple reports using python objects, primarily designed to be formatted as text and html. iÿÿÿÿ(t generatorssrestructuredtext enN(tStringIO(tlinesepccsNxG|jD]<}t||ƒr'|Vnxt||ƒD] }|Vq7Wq WdS(s:return an iterator on all children node of the given klassN(tchildrent isinstancet get_nodes(tnodetklasstchildt grandchild((sZ/Users/jacob/code/ruby/exercism-analysis/vendor/python/logilab/common/ureports/__init__.pyR!s cCsSxL|jD]A}t|tƒr djgt|tƒD]}|j^q5ƒSq WdS(sItry to return the layout's title as string, return None if not found t N(RRtTitletjoinRtTexttdata(tlayoutRR((sZ/Users/jacob/code/ruby/exercism-analysis/vendor/python/logilab/common/ureports/__init__.pyt layout_title*sic Cs|dkst‚|d8}tddƒ}xè|jD]Ý}t|tƒsPq5nt|ƒ}| rs|j rsq5n|js”|jddƒ|_ntd|jd|p°|jƒ}|rg|jD]}t|tƒrÆ|^qÆrt |t ||ƒgƒ}n|j |ƒq5W|S( s0make a summary for the report, including X leveliiRtsummaryR t-t#tlabel( tAssertionErrortListRRtSectionRtidtreplacetLinkt Paragrapht build_summarytappend(RtlevelRRRRtn((sZ/Users/jacob/code/ruby/exercism-analysis/vendor/python/logilab/common/ureports/__init__.pyR1s    "1t BaseWritercBs_eZdZd d d„Zd„Zdd„Zd„Zd„Zd„Z d„Z d „Z RS( sbase class for ureport writerscCs|dkrtj}n|s3t|ddƒ}n|p<d|_g|_||_|j|ƒ|j|ƒ|j |ƒdS(söformat and write the given layout into the stream object unicode policy: unicode strings may be found in the layout; try to call stream.write with it, but give it back encoded using the given encoding if it fails tencodingsUTF-8N( tNonetsyststdouttgetattrR!t_BaseWriter__compute_funcstoutt begin_formattacceptt end_format(tselfRtstreamR!((sZ/Users/jacob/code/ruby/exercism-analysis/vendor/python/logilab/common/ureports/__init__.pytformatOs      cCs.x't|ddƒD]}|j|ƒqWdS(sfrecurse on the layout children and call their accept method (see the Visitor pattern) RN((R%R)(R+RR((sZ/Users/jacob/code/ruby/exercism-analysis/vendor/python/logilab/common/ureports/__init__.pytformat_childrenastcCs|j|tƒdS(s!write a line in the output bufferN(twriteR(R+tstring((sZ/Users/jacob/code/ruby/exercism-analysis/vendor/python/logilab/common/ureports/__init__.pytwritelnhscCsHy|jj|ƒWn-tk rC|jj|j|jƒƒnXdS(s#write a string in the output bufferN(R'R0tUnicodeEncodeErrortencodeR!(R+R1((sZ/Users/jacob/code/ruby/exercism-analysis/vendor/python/logilab/common/ureports/__init__.pyR0ls cCs d|_dS(sbegin to format a layoutiN(tsection(R+R((sZ/Users/jacob/code/ruby/exercism-analysis/vendor/python/logilab/common/ureports/__init__.pyR(sscCsdS(sfinished to format a layoutN((R+R((sZ/Users/jacob/code/ruby/exercism-analysis/vendor/python/logilab/common/ureports/__init__.pyR*wscCsžgg}|j}xW|j|ƒD]F}|dkrM|jgƒ|j}n|d8}|dj|ƒq"Wx+t|dƒ|kr™|djdƒqoW|S(strick to get table content without actually writing it return an aligned list of lists containing table cells values as string iiiÿÿÿÿR/(tcolstcompute_contentRtlen(R+ttabletresultR6tcell((sZ/Users/jacob/code/ruby/exercism-analysis/vendor/python/logilab/common/ureports/__init__.pytget_table_contentzs      c#sÒ‡‡fd†}d‡‡fd†}|ˆ_|ˆ_ˆjj||fƒx2|jD]'}tƒ‰|jˆƒˆjƒVqYWˆjjƒyˆjd\ˆ_ˆ_Wnt k r͈`ˆ`nXdS(s¢trick to compute the formatting of children layout before actually writing it return an iterator on strings (one for each child element) csByˆj|ƒWn*tk r=ˆj|jˆjƒƒnXdS(N(R0R3R4R!(R(R+R,(sZ/Users/jacob/code/ruby/exercism-analysis/vendor/python/logilab/common/ureports/__init__.pyR0“s R/csJyˆj|tƒWn.tk rEˆj|jˆjƒtƒnXdS(N(R0RR3R4R!(R(R+R,(sZ/Users/jacob/code/ruby/exercism-analysis/vendor/python/logilab/common/ureports/__init__.pyR2˜s iÿÿÿÿN( R0R2R&RRt UStringIOR)tgetvaluetpopt IndexError(R+RR0R2R((R,R+sZ/Users/jacob/code/ruby/exercism-analysis/vendor/python/logilab/common/ureports/__init__.pyR7Œs      N( t__name__t __module__t__doc__R"R-R.R2R0R(R*R<R7(((sZ/Users/jacob/code/ruby/exercism-analysis/vendor/python/logilab/common/ureports/__init__.pyR Ls      (t*(t TextWriter(t HTMLWriter(RCt __future__Rt __docformat__R#t cStringIORR=tlogilab.common.textutilsRRRRtobjectR tlogilab.common.ureports.nodest#logilab.common.ureports.text_writerREt#logilab.common.ureports.html_writerRF(((sZ/Users/jacob/code/ruby/exercism-analysis/vendor/python/logilab/common/ureports/__init__.pyts   `