3
^^L                 @   s   d Z G dd dZG dd deZG dd deZG dd deZG d	d
 d
eZG dd deZG dd deZG dd deZG dd deZ	dS )zPMicro reports objects.

A micro report is a tree of layout and content objects.
c               @   sF   e Zd ZdddZdd Zdd Zdd	 Zd
d Zdd Zdd Z	dS )VNodeNc             C   s   || _ d | _g | _d S )N)idparentchildren)selfnid r   A/tmp/pip-build-8app2_gc/pylint/pylint/reporters/ureports/nodes.py__init__   s    zVNode.__init__c             C   s
   t | jS )N)iterr   )r   r   r   r   __iter__   s    zVNode.__iter__c             C   s   | j j| | |_dS )zadd a node to childrenN)r   appendr   )r   childr   r   r   r      s    zVNode.appendc             C   s   | j j|| | |_dS )zinsert a child nodeN)r   insertr   )r   indexr   r   r   r   r      s    zVNode.insertc             C   s0   y| j jddS  tk
r*   | jjj S X dS )z
        return the visit name for the mixed class. When calling 'accept', the
        method <'visit_' + name returned by this method> will be called on the
        visitor
        -_N)ZTYPEreplace	Exception	__class____name__lower)r   r   r   r   _get_visit_name#   s    zVNode._get_visit_namec             O   s"   t |d| j  }|| f||S )Nzvisit_%s)getattrr   )r   visitorargskwargsfuncr   r   r   accept0   s    zVNode.acceptc             O   s"   t |d| j  }|| f||S )Nzleave_%s)r   r   )r   r   r   r   r   r   r   r   leave4   s    zVNode.leave)N)
r   
__module____qualname__r	   r   r   r   r   r   r   r   r   r   r   r      s   
r   c                   s<   e Zd ZdZf f fdd	Zdd Zdd Zdd	 Z  ZS )

BaseLayoutzkbase container node

    attributes
    * children : components in this table (i.e. the table's cells)
    c                sD   t t| jf | x,|D ]$}t|tr2| j| q| j| qW d S )N)superr!   r	   
isinstancer   r   add_text)r   r   r   r   )r   r   r   r	   @   s
    

zBaseLayout.__init__c             C   s    || j  ksttj| | dS )z$overridden to detect problems easilyN)parentsAssertionErrorr   r   )r   r   r   r   r   r   H   s    zBaseLayout.appendc             C   s.   | j | k	st| j dkrg S | j g| j j  S )zreturn the ancestor nodesN)r   r&   r%   )r   r   r   r   r%   M   s    
zBaseLayout.parentsc             C   s   | j jt| dS )zshortcut to add text dataN)r   r   Text)r   textr   r   r   r$   T   s    zBaseLayout.add_text)	r   r   r    __doc__r	   r   r%   r$   __classcell__r   r   )r   r   r!   9   s
   r!   c                   s"   e Zd ZdZd fdd	Z  ZS )r'   zaa text portion

    attributes :
    * data : the text value as an encoded or unicode string
    Tc                s6   t t| jf | t|ts&t|j|| _|| _d S )N)	r"   r'   r	   r#   strr&   r   escapeddata)r   r-   r,   r   )r   r   r   r	   c   s    zText.__init__)T)r   r   r    r)   r	   r*   r   r   )r   r   r'   \   s   r'   c               @   s   e Zd ZdZdS )VerbatimTextzxa verbatim text, display the raw data

    attributes :
    * data : the text value as an encoded or unicode string
    N)r   r   r    r)   r   r   r   r   r.   l   s   r.   c                   s"   e Zd ZdZd fdd	Z  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
    Nc                sH   t t| jf | |r,| jdtt|g |rD| jdt|fd d S )N    )r   )r"   r/   r	   r   	Paragraphr'   Title)r   titledescriptionr   )r   r   r   r	      s
    zSection.__init__)NN)r   r   r    r)   r	   r*   r   r   )r   r   r/   w   s   
r/   c                   s   e Zd Z fddZ  ZS )EvaluationSectionc                sZ   t t| jf | t }|jtdt|  | j| t }|jt| | j| d S )Nr   )r"   r5   r	   r1   r   r'   len)r   messager   r3   message_body)r   r   r   r	      s    
zEvaluationSection.__init__)r   r   r    r	   r*   r   r   )r   r   r5      s   r5   c               @   s   e Zd ZdZdS )r2   zta title

    attributes :
    * BaseLayout attributes

    A title must not contains a section nor a paragraph!
    N)r   r   r    r)   r   r   r   r   r2      s   r2   c               @   s   e Zd ZdZdS )r1   zya simple text paragraph

    attributes :
    * BaseLayout attributes

    A paragraph must not contains a section !
    N)r   r   r    r)   r   r   r   r   r1      s   r1   c                   s"   e Zd ZdZd fdd	Z  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
    Nr0   c                s<   t t| jf | t|ts t|| _|| _|| _|| _	d S )N)
r"   r9   r	   r#   intr&   colsr3   rheaderscheaders)r   r;   r3   r<   r=   r   )r   r   r   r	      s    zTable.__init__)Nr0   r0   )r   r   r    r)   r	   r*   r   r   )r   r   r9      s   	r9   N)
r)   r   r!   r'   r.   r/   r5   r2   r1   r9   r   r   r   r   <module>   s   *#

