Your IP : 216.73.216.196


Current Path : /opt/alt/python27/lib/python2.7/site-packages/logilab/common/ureports/
Upload File :
Current File : //opt/alt/python27/lib/python2.7/site-packages/logilab/common/ureports/__init__.pyo

�
�d{Tc@s�dZdZddlZddlmZddlmZd�Zd�Zdd	�Z	d
e
fd��YZddlTdd
l
mZddlmZdS(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.
srestructuredtext eni����N(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((sQ/opt/alt/python27/lib/python2.7/site-packages/logilab/common/ureports/__init__.pyRs
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
    u N(RRtTitletjoinRtTexttdata(tlayoutRR((sQ/opt/alt/python27/lib/python2.7/site-packages/logilab/common/ureports/__init__.pytlayout_title(sicCs|d8}tdd�}x�|jD]�}t|t�s>q#nt|�}|ra|jraq#n|js�|jdd�|_ntd|jd|p�|j�}|r�g|jD]}t|t�r�|^q�r�t|t	||�g�}n|j
|�q#W|S(s0make a summary for the report, including X leveliRusummaryt t-u#tlabel(tListRRtSectionRtidtreplacetLinkt	Paragrapht
build_summarytappend(R
tleveltsummaryRRRtn((sQ/opt/alt/python27/lib/python2.7/site-packages/logilab/common/ureports/__init__.pyR/s
	"1t
BaseWritercBs_eZdZd
d
d�Zd�Zdd�Zd�Zd�Zd�Z	d�Z
d	�ZRS(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(
tNonetsyststdouttgetattrRt_BaseWriter__compute_funcstouttbegin_formattacceptt
end_format(tselfR
tstreamR((sQ/opt/alt/python27/lib/python2.7/site-packages/logilab/common/ureports/__init__.pytformatMs		

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(R
R((sQ/opt/alt/python27/lib/python2.7/site-packages/logilab/common/ureports/__init__.pytformat_children_sucCs|j|t�dS(s!write a line in the output bufferN(twriteR(R(tstring((sQ/opt/alt/python27/lib/python2.7/site-packages/logilab/common/ureports/__init__.pytwritelnfscCsHy|jj|�Wn-tk
rC|jj|j|j��nXdS(s#write a string in the output bufferN(R$R,tUnicodeEncodeErrortencodeR(R(R-((sQ/opt/alt/python27/lib/python2.7/site-packages/logilab/common/ureports/__init__.pyR,js
cCs
d|_dS(sbegin to format a layoutiN(tsection(R(R
((sQ/opt/alt/python27/lib/python2.7/site-packages/logilab/common/ureports/__init__.pyR%qscCsdS(sfinished to format a layoutN((R(R
((sQ/opt/alt/python27/lib/python2.7/site-packages/logilab/common/ureports/__init__.pyR'utcCs�gg}|j}xW|j|�D]F}|dkrM|jg�|j}n|d8}|dj|�q"Wx+t|d�|kr�|djd�qoW|S(s�trick to get table content without actually writing it

        return an aligned list of lists containing table cells values as string
        iii����u(tcolstcompute_contentRtlen(R(ttabletresultR3tcell((sQ/opt/alt/python27/lib/python2.7/site-packages/logilab/common/ureports/__init__.pytget_table_contentxs		

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(R,R/R0R(R(R(R)(sQ/opt/alt/python27/lib/python2.7/site-packages/logilab/common/ureports/__init__.pyR,�s
ucsJy�j|t�Wn.tk
rE�j|j�j�t�nXdS(N(R,RR/R0R(R(R(R)(sQ/opt/alt/python27/lib/python2.7/site-packages/logilab/common/ureports/__init__.pyR.�s
i����N(
R,R.R#RRRR&tgetvaluetpopt
IndexError(R(R
R,R.R((R(R)sQ/opt/alt/python27/lib/python2.7/site-packages/logilab/common/ureports/__init__.pyR4�s			


N(t__name__t
__module__t__doc__RR*R+R.R,R%R'R9R4(((sQ/opt/alt/python27/lib/python2.7/site-packages/logilab/common/ureports/__init__.pyRJs					(t*(t
TextWriter(t
HTMLWriter(R?t
__docformat__R tlogilab.common.compatRtlogilab.common.textutilsRRRRtobjectRtlogilab.common.ureports.nodest#logilab.common.ureports.text_writerRAt#logilab.common.ureports.html_writerRB(((sQ/opt/alt/python27/lib/python2.7/site-packages/logilab/common/ureports/__init__.pyt<module>s			`