
    c                        d Z ddlmZ ddlmZ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dS )0Base class defining the interface for a printer.    )annotations)ABCabstractmethod)Enum)
NamedTuple)nodes)get_annotation_labelc                      e Zd ZdZdZdZdS )NodeTypeclass	interfacepackageN)__name__
__module____qualname__CLASS	INTERFACEPACKAGE     8lib/python3.11/site-packages/pylint/pyreverse/printer.pyr   r      s        EIGGGr   r   c                  "    e Zd ZdZdZdZdZdZdS )EdgeTypeinherits
implementsassociationaggregationusesN)r   r   r   INHERITS
IMPLEMENTSASSOCIATIONAGGREGATIONUSESr   r   r   r   r      s'        HJKKDDDr   r   c                      e Zd ZdZdZdZdZdS )LayoutLRRLTBBTN)r   r   r   LEFT_TO_RIGHTRIGHT_TO_LEFTTOP_TO_BOTTOMBOTTOM_TO_TOPr   r   r   r&   r&       s"        MMMMMMr   r&   c                  R    e Zd ZU ded<   dZded<   dZded<   dZded	<   dZded
<   dS )NodePropertiesstrlabelNzlist[str] | Noneattrszlist[nodes.FunctionDef] | Nonemethods
str | Nonecolor	fontcolor)r   r   r   __annotations__r3   r4   r6   r7   r   r   r   r0   r0   '   s_         JJJ"E"""".2G2222E I      r   r0   c                      e Zd ZdZ	 	 d&d'dZd(dZd(dZed(d            Zd)d*dZ	e	 d+d,d            Z
e	 d+d-d            Zed.d"            Zd/d$Zed(d%            ZdS )0Printerr   Ntitler1   layoutLayout | Noneuse_automatic_namespacebool | NonereturnNonec                t    || _         || _        || _        g | _        d| _        |                                  d S )N )r;   r<   r>   lines_indent_open_graph)selfr;   r<   r>   s       r   __init__zPrinter.__init__2   s@      
'>$ "
r   c                &    | xj         dz  c_         dS )zIncrement indentation.z  NrE   rG   s    r   _inc_indentzPrinter._inc_indent?   s    r   c                .    | j         dd         | _         dS )zDecrement indentation.NrJ   rK   s    r   _dec_indentzPrinter._dec_indentC   s    |CRC(r   c                    dS )zfEmit the header lines, i.e. all boilerplate code that defines things like
        layout etc.
        Nr   rK   s    r   rF   zPrinter._open_graphG         r   Tlineforce_newlinec                    |r|                     d          s|dz  }| j                            | j        |z              d S )N
)endswithrD   appendrE   )rG   rR   rS   s      r   emitzPrinter.emitM   sI     	t!4!4 	DLD
$,-.....r   nametype_r   
propertiesNodeProperties | Nonec                    dS )zVCreate a new node.

        Nodes can be classes, packages, participants etc.
        Nr   )rG   rY   rZ   r[   s       r   	emit_nodezPrinter.emit_nodeR   rQ   r   	from_nodeto_noder   r2   r5   c                    dS )zACreate an edge from one node to another to display relationships.Nr   )rG   r_   r`   rZ   r2   s        r   	emit_edgezPrinter.emit_edge^   rQ   r   methodnodes.FunctionDef	list[str]c                J   | j         j         g S | j        dv rdnd}| j         j         |d          }t          t          || j         j        |d                              }|D ]*}d} |j        |          }|rt          |          }|||<   +d  |j                    D             S )N>   functionstaticmethodr      rC   c                @    g | ]\  }}|r|j          d | n|j          S )z: )rY   ).0arganns      r   
<listcomp>z1Printer._get_method_arguments.<locals>.<listcomp>x   sJ     
 
 
S %(:sx  3   ]
 
 
r   )argstypedictzipr   getr
   items)rc   	first_arg	argumentsr   rl   annotation_labelrm   s          r   _get_method_argumentszPrinter._get_method_argumentsh   s    ; 	I(DDKAA!	,2K,<YZZ,H	3y&+*A)***MNNOO 	0 	0C!!+/#&&C =#7#<#< /K
 
-K-//
 
 
 	
r   
outputfilec                    |                                   t          |dd          5 }|                    | j                   ddd           dS # 1 swxY w Y   dS )z'Generate and save the final outputfile.wzutf-8)encodingN)_close_graphopen
writelinesrD   )rG   ry   outfiles      r   generatezPrinter.generate}   s    *cG444 	+tz***	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+s   AAAc                    dS )z2Emit the lines needed to properly close the graph.Nr   rK   s    r   r}   zPrinter._close_graph   rQ   r   )NN)r;   r1   r<   r=   r>   r?   r@   rA   )r@   rA   )T)rR   r1   rS   r?   r@   rA   )N)rY   r1   rZ   r   r[   r\   r@   rA   )
r_   r1   r`   r1   rZ   r   r2   r5   r@   rA   )rc   rd   r@   re   )ry   r1   r@   rA   )r   r   r   __doc__rH   rL   rO   r   rF   rX   r^   rb   rh   rx   r   r}   r   r   r   r:   r:   /   sO       ::
 !%/3	       ) ) ) )    ^
/ / / / /
 
 -1		 	 	 	 ^	  !P P P P ^P 
 
 
 \
(+ + + + A A A ^A A Ar   r:   N)r   
__future__r   abcr   r   enumr   typingr   astroidr	   pylint.pyreverse.utilsr
   r   r   r&   r0   r:   r   r   r   <module>r      so  
 7 6 " " " " " " # # # # # # # #                   7 7 7 7 7 7    t       t       T   ! ! ! ! !Z ! ! !VA VA VA VA VAc VA VA VA VA VAr   