B
    A!p\  ã               @   s,  d Z ddddddddœZd	d	ed
 ed
 ed
 ddded ed dded dddded ed ed ed ed ed ed ed ed ed ed dœZd	d	ed
 ed
 ed
 ddded ed dddddœZd	d	d	ed dd	ed
 ed
 ed
 ed
 dded ed ed ddddœZG dd„ dƒZdS )aG  Functions to generate files readable with Georg Sander's vcg
(Visualization of Compiler Graphs).

You can download vcg at http://rw4.cs.uni-sb.de/~sander/html/gshome.html
Note that vcg exists as a debian package.

See vcg's documentation for explanation about the different values that
maybe used for the functions parameters.
)ZdfsZtreeZminbackwardZleft_to_rightZright_to_leftZtop_to_bottomZbottom_to_topZmaxdepthZmaxdepthslowZmindepthZmindepthslowZ	mindegreeZminindegreeZminoutdegreeZ	maxdegreeZmaxindegreeZmaxoutdegree)ZyesZno) ZblackZwhiteZblueZredZgreenZyellowZmagentaZ	lightgreyZcyanZdarkgreyZdarkblueZdarkredZ	darkgreenZ
darkyellowZdarkmagentaZdarkcyanZgoldZ	lightblueZlightredZ
lightgreenZlightyellowZlightmagentaZ	lightcyanZlilacZ	turquoiseZ
aquamarineZkhakiZpurpleZyellowgreenZpinkZorangeZorchid)ZboxZellipseZrhombZtriangle)ÚcenterZleft_justifyZright_justify)ZsolidÚlineZnone)Z
continuousZdashedZdottedZ	invisible)ÚalgosÚbooleansÚcolorsÚshapesÚ	textmodesÚarrowstylesÚ
linestylesé    r   é   r   r   r   r   )ÚtitleÚlabelÚcolorÚ	textcolorÚbordercolorÚwidthÚheightÚborderwidthÚtextmodeÚshapeÚshrinkÚstretchZorientationÚvertical_orderÚhorizontal_orderZxspaceZyspaceZlayoutalgorithmZlate_edge_labelsZdisplay_edge_labelsZdirty_edge_labelsZ
finetuningZmanhattan_edgesZsmanhattan_edgesZport_sharingZedgesZnodesZsplines)r   r   r   r   r   r   r   r   r   r   r   r   r   r   r	   r   )Z
sourcenameZ
targetnamer   Z	linestyleÚclassZ	thicknessr   r   Z
arrowcolorZbackarrowcolorZ	arrowsizeZbackarrowsizeZ
arrowstyleZbackarrowstyler   ZpriorityZanchorr   c               @   sR   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zddd„Zdd„ Z	dd„ Z
dd„ ZdS )Ú
VCGPrinterzA vcg graph writer.
    c             C   s   || _ d| _d S )NÚ )Ú_streamÚ_indent)ÚselfZoutput_stream© r    ú8lib/python3.7/site-packages/pylint/pyreverse/vcgutils.pyÚ__init__Ÿ   s    zVCGPrinter.__init__c             K   s,   | j  d| j ¡ |  ¡  | jtf|Ž dS )zopen a vcg graph
        z
%sgraph:{
N)r   Úwriter   Ú_inc_indentÚ_write_attributesÚGRAPH_ATTRS)r   Úargsr    r    r!   Ú
open_graph£   s    zVCGPrinter.open_graphc             C   s   |   ¡  | j d| j ¡ dS )zclose a vcg graph
        z%s}
N)Ú_dec_indentr   r#   r   )r   r    r    r!   Úclose_graphª   s    zVCGPrinter.close_graphc             K   s4   | j  d| j|f ¡ | jtf|Ž | j  d¡ dS )zdraw a node
        z%snode: {title:"%s"z}
N)r   r#   r   r%   Ú
NODE_ATTRS)r   r   r'   r    r    r!   Únode°   s    zVCGPrinter.noder   c             K   s8   | j  d| j|||f ¡ | jtf|Ž | j  d¡ dS )z-draw an edge from a node to another.
        z*%s%sedge: {sourcename:"%s" targetname:"%s"z}
N)r   r#   r   r%   Ú
EDGE_ATTRS)r   Z	from_nodeZto_nodeZ	edge_typer'   r    r    r!   Úedge·   s
    zVCGPrinter.edgec          	   K   sÈ   xÂ|  ¡ D ]¶\}}y|| }W n( tk
rF   td|| ¡ f ƒ‚Y nX |sf| j d| j||f ¡ q
|dkrŒ| j d| j|t|ƒf ¡ q
||kr®| j d| j||f ¡ q
td|||f ƒ‚q
W dS )z-write graph, node or edge attributes
        z/no such attribute %s
possible attributes are %sz
%s%s:"%s"
r   z%s%s:%s
z=value %s isn't correct for attribute %s
correct values are %sN)ÚitemsÚKeyErrorÚ	ExceptionÚkeysr   r#   r   Úint)r   Zattributes_dictr'   ÚkeyÚvalueZ_typer    r    r!   r%   Ã   s     zVCGPrinter._write_attributesc             C   s   d| j  | _ dS )zincrement indentation
        z  %sN)r   )r   r    r    r!   r$   Ý   s    zVCGPrinter._inc_indentc             C   s   | j dd… | _ dS )zdecrement indentation
        Néþÿÿÿ)r   )r   r    r    r!   r)   â   s    zVCGPrinter._dec_indentN)r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r"   r(   r*   r,   r.   r%   r$   r)   r    r    r    r!   r   ›   s   
r   N)r:   Z	ATTRS_VALr&   r+   r-   r   r    r    r    r!   Ú<module>   sˆ   !