
    c                     \   d Z dZddlmZ ddlmZ ddlmZ ddlmZ ddlm	Z	 ddlm
Z
  G d	 d
e      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d d e      Zy!)"zPMicro reports objects.

A micro report is a tree of layout and content objects.
zrestructuredtext en    )VNode)Optional)Any)List)Tuple)Unionc                   2    e Zd ZdZddee   dee   ddfdZy)BaseComponentz~base report component

    attributes
    * id : the component's optional id
    * klass : the component's optional klass
    Nidklassreturnc                 >    t        j                  | |       || _        y N)r   __init__r   )selfr   r   s      ?/usr/lib/python3/dist-packages/logilab/common/ureports/nodes.pyr   zBaseComponent.__init__,   s    tR 
    NN)__name__
__module____qualname____doc__r   strr    r   r   r
   r
   $   s*    8C=  QU r   r
   c            	            e Zd ZdZ	 ddeed   eedef   eeef   f   eedf   f   deddf fd	Z	d
eddfdZ
defdZdeddfdZ xZS )
BaseLayoutzbase container node

    attributes
    * BaseComponent attributes
    * children : components in this table (i.e. the table's cells)
    childrenText	Paragraph.kwargsr   Nc                     t        t        | 
  di | |D ]5  }t        |t              r| j                  |       %| j                  |       7 y Nr   )superr   r   
isinstancer
   appendadd_text)r   r   r    child	__class__s       r   r   zBaseLayout.__init__9   sJ     	j$(262 	%E%/E"
 e$	%r   r'   c                 X    || j                         vsJ t        j                  | |       y)z$overridden to detect problems easilyN)parentsr   r%   )r   r'   s     r   r%   zBaseLayout.appendM   s$    DLLN***T5!r   c                     | j                   | usJ | j                   g S | j                   g| j                   j                         z   S )zreturn the ancestor nodes)parentr*   )r   s    r   r*   zBaseLayout.parentsR   sA    {{$&&&;;I}t{{22444r   textc                 L    | j                   j                  t        |             y)zshortcut to add text dataN)r   r%   r   )r   r-   s     r   r&   zBaseLayout.add_textY   s    T$Z(r   )r   )r   r   r   r   r   
TypingListr   r   r   r   r%   r*   r&   __classcell__r(   s   @r   r   r   1   s     %v%S()5S+AAB#s(O
% % 
%("C "D "
5 5)S )T )r   r   c            	       6     e Zd ZdZddedededdf fdZ xZS )	r   za text portion

    attributes :
    * BaseComponent attributes
    * data : the text value as an encoded or unicode string
    dataescapedr    r   Nc                     t        t        | 
  di | t        |t              sJ |j
                         || _        || _        y r"   )r#   r   r   r$   r   r(   r4   r3   )r   r3   r4   r    r(   s       r   r   zText.__init__i   s>    dD",V, $$4dnn4$	r   )T)	r   r   r   r   r   boolr   r   r0   r1   s   @r   r   r   a   s.    S 4 # $  r   r   c                       e Zd ZdZy)VerbatimTextza verbatim text, display the raw data

    attributes :
    * BaseComponent attributes
    * data : the text value as an encoded or unicode string
    Nr   r   r   r   r   r   r   r8   r8   r   s    r   r8   c            	       6     e Zd ZdZddedededdf fdZ xZS )	Linkza labelled link

    attributes :
    * BaseComponent attributes
    * url : the link's target (REQUIRED)
    * label : the link's label as a string (use the url by default)
    Nurllabelr    r   c                 X    t        t        | 
  di | |sJ || _        |xs || _        y r"   )r#   r;   r   r<   r=   )r   r<   r=   r    r(   s       r   r   zLink.__init__   s.    dD",V,
s\c
r   r   r   r   r   r   r   r   r   r0   r1   s   @r   r;   r;   {   s.    "C " "c "d " "r   r;   c                   $     e Zd ZdZd fd	Z xZS )Imagezan embedded or a single image

    attributes :
    * BaseComponent attributes
    * filename : the image's filename (REQUIRED)
    * stream : the stream object containing the image data (REQUIRED)
    * title : the image's optional title
    c                 f    t        t        | 
  di | |sJ |sJ || _        || _        || _        y r"   )r#   rA   r   filenamestreamtitle)r   rC   rD   rE   r    r(   s        r   r   zImage.__init__   s8    eT#-f-xv 
r   r   )r   r   r   r   r   r0   r1   s   @r   rA   rA      s     r   rA   c            	       6     e Zd ZdZddedededdf fdZ xZS )	Sectionza section

    attributes :
    * BaseLayout attributes

    a title may also be given to the constructor, it'll be added
    as a first element
    a description may also be given to the constructor, it'll be added
    as a first paragraph
    NrE   descriptionr    r   c                     t        t        | 
  di | |r%| j                  dt	        t        |      g             |r| j                  dt        |f             y y )Nr   )r   r   )r#   rG   r   insertr   r   Title)r   rE   rH   r    r(   s       r   r   zSection.__init__   sP    gt%//KK9d;&7%89:KK55(34 r   r   r?   r1   s   @r   rG   rG      s/    	5c 5s 5S 5UY 5 5r   rG   c                       e Zd ZdZy)rK   zta title

    attributes :
    * BaseLayout attributes

    A title must not contains a section nor a paragraph!
    Nr9   r   r   r   rK   rK          r   rK   c                       e Zd ZdZy)Spanza title

    attributes :
    * BaseLayout attributes

    A span should only contains Text and Link nodes (in-line elements)
    Nr9   r   r   r   rO   rO      rM   r   rO   c                       e Zd ZdZy)r   zya simple text paragraph

    attributes :
    * BaseLayout attributes

    A paragraph must not contains a section !
    Nr9   r   r   r   r   r      rM   r   r   c                   V     e Zd ZdZ	 	 	 	 	 ddedee   dedededed	ed
df fdZ xZS )Tablea"  some tabular data

    attributes :
    * BaseLayout attributes
    * cols : the number of columns of the table (REQUIRED)
    * rheaders : the first row's elements are table's header
    * cheaders : the first col's elements are table's header
    * title : the table's optional title
    NcolsrE   rheaderscheaders	rrheaders	rcheadersr    r   c                     t        t        | 
  di | t        |t              sJ || _        || _        || _        || _        || _	        || _
        y r"   )r#   rR   r   r$   intrS   rE   rT   rU   rV   rW   )	r   rS   rE   rT   rU   rV   rW   r    r(   s	           r   r   zTable.__init__   sQ     	eT#-f-$$$$	
  ""r   )Nr   r   r   r   )	r   r   r   r   rY   r   r   r   r0   r1   s   @r   rR   rR      su      $## }# 	#
 # # # # 
# #r   rR   c                       e Zd ZdZy)r   zAsome list data

    attributes :
    * BaseLayout attributes
    Nr9   r   r   r   r   r      s    r   r   N)r   __docformat__logilab.common.treer   typingr   r   r   r/   r   r   r
   r   r   r8   r;   rA   rG   rK   rO   r   rR   r   r   r   <module>r^      s   $ & % 
  %  
E 
*) *)`= "4 "= " M ,5j 5(J : 
 #J #>: r   