
    5 fp                        d Z ddlmZ ddlZddlmZ ddlmZ ddlm	Z	m
Z
 e	rddlmZmZmZmZmZ  G d d	          ZdS )
zUniversal report objects and some formatting drivers.

A way to create simple reports using python objects, primarily designed to be
formatted as text and html.
    )annotationsN)Iterator)StringIO)TYPE_CHECKINGTextIO)
BaseLayoutEvaluationSection	ParagraphSectionTablec                  d    e Zd ZdZej        dfddZddZdddZddZ	ddZ
ddZd dZd!dZdS )"
BaseWriterzBase class for ureport writers.Nlayoutr   streamr   encoding
str | NonereturnNonec                    |st          |dd          }|pd| _        || _        |                                  |                    |            |                                  dS )zFormat 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
        r   zUTF-8N)getattrr   outbegin_formataccept
end_format)selfr   r   r   s       [/var/www/equiseq/venv/lib/python3.11/site-packages/pylint/reporters/ureports/base_writer.pyformatzBaseWriter.format   sj      	<vz7;;H +Gd    'EvaluationSection | Paragraph | Sectionc                X    t          |dd          D ]}|                    |            dS )zgRecurse on the layout children and call their accept method
        (see the Visitor pattern).
        children N)r   r   )r   r   childs      r   format_childrenzBaseWriter.format_children3   s>     VZ44 	 	ELL	 	r    stringstrc                6    |                      |dz              dS )z"Write a line in the output buffer.
N)writer   r&   s     r   writelnzBaseWriter.writeln:   s    

6D=!!!!!r   c                :    | j                             |           dS )z$Write a string in the output buffer.N)r   r*   r+   s     r   r*   zBaseWriter.write>   s    vr   c                    d| _         dS )zBegin to format a layout.r   N)sectionr   s    r   r   zBaseWriter.begin_formatB   s    r   c                    dS )zFinished formatting a layout.Nr"   r0   s    r   r   zBaseWriter.end_formatF   s      r   tabler   list[list[str]]c           	     "   g g}|j         }|                     |          D ]D}|dk    r|                    g            |j         }|dz  }|d                             |           E|dxx         dg|t          |d                   z
  z  z  cc<   |S )zTrick to get table content without actually writing it.

        return an aligned list of lists containing table cells values as string
        r      r%   )colscompute_contentappendlen)r   r2   resultr7   cells        r   get_table_contentzBaseWriter.get_table_contentI   s    
 $&$z((// 	$ 	$Dqyyb!!!zAID2Jd####r


rddS__455


r   Iterator[str]c              #     K   | j         }	 |j        D ]B}t                      }|| _         |                    |            |                                V  C	 || _         dS # || _         w xY w)zTrick to compute the formatting of children layout before actually
        writing it.

        return an iterator on strings (one for each child element)
        N)r   r!   r   r   getvalue)r   r   r   r#   r   s        r   r8   zBaseWriter.compute_contentZ   s       h	 ( (!!T"""oo''''''	( DHHHsDHNNNNs   A
A 	A()r   r   r   r   r   r   r   r   )r   r   r   r   )r%   )r&   r'   r   r   )r   r   )r2   r   r   r3   )r   r   r   r>   )__name__
__module____qualname____doc__sysstdoutr   r$   r,   r*   r   r   r=   r8   r"   r   r   r   r      s        ))
 #	    (   " " " " "      , , , ,   "     r   r   )rD   
__future__r   rE   collections.abcr   ior   typingr   r   pylint.reporters.ureports.nodesr   r	   r
   r   r   r   r"   r   r   <module>rL      s   
  # " " " " " 



 $ $ $ $ $ $       ( ( ( ( ( ( ( (              O O O O O O O O O Or   