o
    g                     @   s   d Z ddlmZmZmZmZmZmZ ddlm	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.
    )AnyIterableIteratorListOptionalUnion)
TextWriterc                   @   sJ   e Zd ZdddZded  fddZdeded	eddfd
dZdd Z	dS )VNodereturnNc                 C   s   d | _ g | _| jj | _d S N)parentchildren	__class____name__lowervisitor_nameself r   ]/home/ubuntu/cloudmapper/venv/lib/python3.10/site-packages/pylint/reporters/ureports/nodes.py__init__   s   zVNode.__init__c                 C   s
   t | jS r   )iterr   r   r   r   r   __iter__   s   
zVNode.__iter__visitorargskwargsc                 O   (   t |d| j }|| g|R i |S )Nvisit_getattrr   r   r   r   r   funcr   r   r   accept       zVNode.acceptc                 O   r   )Nleave_r   r    r   r   r   leave$   r#   zVNode.leave)r
   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ddeedef  ddf fddZd	eddfd
dZ	de
d	eddfddZded  fddZdeddfddZ  ZS )
BaseLayoutzkbase container node

    attributes
    * children : components in this table (i.e. the table's cells)
    r   r   Textr
   Nc                    s8   t    |D ]}t|tr| | q| | qd S r   )superr   
isinstancer	   appendadd_text)r   r   childr   r   r   r   0   s   

zBaseLayout.__init__r.   c                 C   s&   ||   vsJ | j| | |_dS )zadd a node to childrenN)parentsr   r,   r   )r   r.   r   r   r   r,   8   s   
zBaseLayout.appendindexc                 C   s   | j || | |_dS )zinsert a child nodeN)r   insertr   )r   r1   r.   r   r   r   r2   >   s   
zBaseLayout.insertc                 C   s.   | j | usJ | j du rg S | j g| j   S )zreturn the ancestor nodesN)r   r0   r   r   r   r   r0   C   s   
zBaseLayout.parentstextc                 C   s   | j t| dS )zshortcut to add text dataN)r   r,   r)   )r   r3   r   r   r   r-   J   s   zBaseLayout.add_textr   )r   r&   r'   __doc__r   r   strr   r	   r,   intr2   r   r0   r-   __classcell__r   r   r/   r   r(   )   s    $r(   c                       s0   e Zd ZdZd	dededdf fddZ  ZS )
r)   zaa text portion

    attributes :
    * data : the text value as an encoded or unicode string
    Tdataescapedr
   Nc                    s   t    || _|| _d S r   )r*   r   r:   r9   )r   r9   r:   r/   r   r   r   Y   s   

zText.__init__)T)r   r&   r'   r5   r6   boolr   r8   r   r   r/   r   r)   R   s    $r)   c                   @      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'   r5   r   r   r   r   r=   _       r=   c                
       sN   e Zd ZdZ			ddee dee deedef  ddf 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
    Nr   titledescriptionr   r)   r
   c                    sJ   t  j|d |r| dtt|g |r | dt|fd d| _d S )Nr   r    )r*   r   r2   	Paragraphr)   Title	report_id)r   rA   rB   r   r/   r   r   r   v   s   
zSection.__init__)NNr   )
r   r&   r'   r5   r   r6   r   r   r   r8   r   r   r/   r   r@   j   s    r@   c                       s:   e Zd Z	d	dedeedef  ddf fddZ  ZS )
EvaluationSectionr   messager   r)   r
   Nc                    sV   t  j|d t }|tdt|  | | t }|t| | | d S )NrC   -)r*   r   rE   r,   r)   len)r   rI   r   rA   message_bodyr/   r   r   r      s   
zEvaluationSection.__init__r4   )r   r&   r'   r6   r   r   r   r8   r   r   r/   r   rH      s    rH   c                   @   r<   )rF   zta title

    attributes :
    * BaseLayout attributes

    A title must not contains a section nor a paragraph!
    Nr>   r   r   r   r   rF      r?   rF   c                   @   r<   )rE   zya simple text paragraph

    attributes :
    * BaseLayout attributes

    A paragraph must not contains a section !
    Nr>   r   r   r   r   rE      r?   rE   c                       sT   e Zd ZdZ				ddedee deded	eed
ef  ddf 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
    Nr   r   colsrA   rheaderscheadersr   r)   r
   c                    s8   t  j|d t|tsJ || _|| _|| _|| _d S )NrC   )r*   r   r+   r7   rN   rA   rO   rP   )r   rN   rA   rO   rP   r   r/   r   r   r      s   
zTable.__init__)Nr   r   r   )r   r&   r'   r5   r7   r   r6   r   r   r   r8   r   r   r/   r   rM      s&    rM   N)r5   typingr   r   r   r   r   r   %pylint.reporters.ureports.text_writerr   r	   r(   r)   r=   r@   rH   rF   rE   rM   r   r   r   r   <module>   s    )

