
    e                        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y)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y)NodeTypeclasspackageN)__name__
__module____qualname__CLASSPACKAGE     :/usr/lib/python3/dist-packages/pylint/pyreverse/printer.pyr   r      s    EGr   r   c                       e Zd ZdZdZdZdZdZy)EdgeTypeinheritsassociationaggregationusestype_dependencyN)r   r   r   INHERITSASSOCIATIONAGGREGATIONUSESTYPE_DEPENDENCYr   r   r   r   r      s    HKKD'Or   r   c                      e Zd ZdZdZdZdZy)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Mr   r$   c                  P    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
<   y)NodePropertiesstrlabelNzlist[str] | Noneattrszlist[nodes.FunctionDef] | Nonemethods
str | Nonecolor	fontcolor)r   r   r   __annotations__r1   r2   r4   r5   r   r   r   r.   r.   &   s1    J"E".2G+2E: Iz r   r.   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y)Printerr   Nc                j    || _         || _        || _        g | _        d| _        | j                          y )N )titlelayoutuse_automatic_namespacelines_indent_open_graph)selfr;   r<   r=   s       r   __init__zPrinter.__init__1   s4      
'>$ "
r   c                .    | xj                   dz  c_         y)zIncrement indentation.z  Nr?   rA   s    r   _inc_indentzPrinter._inc_indent>   s    r   c                ,    | j                   dd | _         y)zDecrement indentation.NrD   rE   s    r   _dec_indentzPrinter._dec_indentB   s    ||CR(r   c                     y)zfEmit the header lines, i.e. all boilerplate code that defines things like
        layout etc.
        Nr   rE   s    r   r@   zPrinter._open_graphF       r   c                    |r|j                  d      s|dz  }| j                  j                  | j                  |z          y )N
)endswithr>   appendr?   )rA   lineforce_newlines      r   emitzPrinter.emitL   s4    t!4DLD

$,,-.r   c                     y)zVCreate a new node.

        Nodes can be classes, packages, participants etc.
        Nr   )rA   nametype_
propertiess       r   	emit_nodezPrinter.emit_nodeQ   rK   r   c                     y)zACreate an edge from one node to another to display relationships.Nr   )rA   	from_nodeto_noderU   r0   s        r   	emit_edgezPrinter.emit_edge]   rK   r   c                   | j                   j                   g S | j                  dv rdnd}| j                   j                   |d  }t        t        || j                   j                  |d              }|D ](  }d} |j
                  |      }|rt        |      }|||<   *  |j                         D cg c]%  \  }}|r|j                   d| n|j                   ' c}}S c c}}w )N>   functionstaticmethodr      r:   z: )	argstypedictzipr   getr
   itemsrT   )method	first_arg	argumentsr   argannotation_labelanns          r   _get_method_argumentszPrinter._get_method_argumentsg   s    ;;#I(DDA!	,2KK,<,<YZ,H	3y&++*A*A)**MNO 	0C!!+//#&C#7#< /K	0 .K--/
S %(sxxj3% z:
 	
 
s   1*Cc                    | j                          t        |dd      5 }|j                  | j                         ddd       y# 1 sw Y   yxY w)z'Generate and save the final outputfile.wzutf-8)encodingN)_close_graphopen
writelinesr>   )rA   
outputfileoutfiles      r   generatezPrinter.generate|   sC    *cG4 	+tzz*	+ 	+ 	+s   AAc                     y)z2Emit the lines needed to properly close the graph.Nr   rE   s    r   rp   zPrinter._close_graph   rK   r   )NN)r;   r/   r<   zLayout | Noner=   bool | NonereturnNone)rx   ry   )T)rP   r/   rQ   rw   rx   ry   )N)rT   r/   rU   r   rV   zNodeProperties | Nonerx   ry   )
rY   r/   rZ   r/   rU   r   r0   r3   rx   ry   )rf   znodes.FunctionDefrx   z	list[str])rs   r/   rx   ry   )r   r   r   __doc__rB   rF   rI   r   r@   rR   rW   r[   r^   rl   ru   rp   r   r   r   r8   r8   .   s   :
 !%/3	  "-	
 
)  
/
 
 -1			 	 *		
 
	 	  !PP P 	P
 P 
P P 
 
(+ A Ar   r8   N)rz   
__future__r   abcr   r   enumr   typingr   astroidr	   pylint.pyreverse.utilsr
   r   r   r$   r.   r8   r   r   r   <module>r      s\   
 7 " #    7t 
(t (T !Z !VAc VAr   