o
    g                     @   s   d Z ddlmZmZ ddlmZ ddlmZmZm	Z	 ddl
mZ ddlm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 )z2
Base class defining the interface for a printer.
    )ABCabstractmethod)Enum)List
NamedTupleOptional)nodes)get_annotation_labelc                   @   s   e Zd ZdZdZdZdS )NodeTypeclass	interfacepackageN)__name__
__module____qualname__CLASS	INTERFACEPACKAGE r   r   V/home/ubuntu/cloudmapper/venv/lib/python3.10/site-packages/pylint/pyreverse/printer.pyr
      s    r
   c                   @      e Zd ZdZdZdZdZdS )EdgeTypeinherits
implementsassociationusesN)r   r   r   INHERITS
IMPLEMENTSASSOCIATIONUSESr   r   r   r   r      
    r   c                   @   r   )LayoutLRRLTBBTN)r   r   r   LEFT_TO_RIGHTRIGHT_TO_LEFTTOP_TO_BOTTOMBOTTOM_TO_TOPr   r   r   r   r!   "   r    r!   c                   @   s`   e Zd ZU eed< dZeee  ed< dZeee	j
  ed< dZee ed< dZee ed< dS )NodePropertieslabelNattrsmethodscolor	fontcolor)r   r   r   str__annotations__r,   r   r   r-   r   FunctionDefr.   r/   r   r   r   r   r*   )   s   
 r*   c                   @   s   e Zd ZdZ		d&dedee dee fddZdd	 Z	d
d Z
ed'ddZd(dedee ddfddZe	d)dededee ddfddZe	d)dedededee ddf
ddZedejdee fdd Zd!eddfd"d#Zed'd$d%ZdS )*Printerz/Base class defining the interface for a printerNtitlelayoutuse_automatic_namespacec                 C   s*   || _ || _|| _g | _d| _|   d S )N )r4   r5   r6   lines_indent_open_graph)selfr4   r5   r6   r   r   r   __init__4   s   zPrinter.__init__c                 C   s   |  j d7  _ dS )zincrement indentationz  Nr9   r;   r   r   r   _inc_indentA   s   zPrinter._inc_indentc                 C   s   | j dd | _ dS )zdecrement indentationNr=   r>   r   r   r   _dec_indentE   s   zPrinter._dec_indentreturnc                 C      dS )zUEmit the header lines, i.e. all boilerplate code that defines things like layout etc.Nr   r>   r   r   r   r:   I       zPrinter._open_graphTlineforce_newlinec                 C   s,   |r| ds|d7 }| j| j|  d S )N
)endswithr8   appendr9   )r;   rE   rF   r   r   r   emitM   s   zPrinter.emitnametype_
propertiesc                 C   rC   )zDCreate a new node. Nodes can be classes, packages, participants etc.Nr   )r;   rK   rL   rM   r   r   r   	emit_nodeR   rD   zPrinter.emit_node	from_nodeto_noder+   c                 C   rC   )zACreate an edge from one node to another to display relationships.Nr   )r;   rO   rP   rL   r+   r   r   r   	emit_edge[   rD   zPrinter.emit_edgemethodc                 C   sx   | j j rdd | j j D }ng }tt|| j jdd  }|D ]}d}||}|r.t|}|||< qdd | D S )Nc                 S   s   g | ]	}|j d kr|qS r>   rK   ).0argr   r   r   
<listcomp>h   s    z1Printer._get_method_arguments.<locals>.<listcomp>   r7   c                 S   s,   g | ]\}}|r|j  d | n|j  qS )z: rS   )rT   rU   annr   r   r   rV   v   s    )argsdictzipannotationsgetr	   items)rR   	argumentsr\   rU   annotation_labelrX   r   r   r   _get_method_argumentse   s   

zPrinter._get_method_arguments
outputfilec                 C   sH   |    t|ddd}|| j W d   dS 1 sw   Y  dS )z'Generate and save the final outputfile.wzutf-8)encodingN)_close_graphopen
writelinesr8   )r;   rb   outfiler   r   r   generate{   s   "zPrinter.generatec                 C   rC   )z2Emit the lines needed to properly close the graph.Nr   r>   r   r   r   re      rD   zPrinter._close_graph)NN)rB   N)T)N)r   r   r   __doc__r0   r   r!   boolr<   r?   rA   r   r:   rJ   r
   r*   rN   r   rQ   staticmethodr   r2   r   ra   ri   re   r   r   r   r   r3   1   sZ    
	r3   N)rj   abcr   r   enumr   typingr   r   r   astroidr   pylint.pyreverse.utilsr	   r
   r   r!   r*   r3   r   r   r   r   <module>   s   