Your IP : 216.73.216.213
B
�d{T� � @ s@ d Z dZddlZdddddd d
d�Zdded ed ed d
d
d
ed ed d
d
ed d
d
d
d
ed ed ed ed ed ed ed ed ed ed ed d�Zdded ed ed d
d
d
ed ed d
d
d
d
d�Zddded d
ded ed ed ed d
d
ed ed ed d
d
d
d�Zdd� ZG dd� d�ZdS )aK 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.
zrestructuredtext en� N)�dfs�treeZminbackwardZ
left_to_rightZ
right_to_leftZ
top_to_bottomZ
bottom_to_topZmaxdepthZmaxdepthslowZmindepthZmindepthslowZ mindegreeZminindegreeZminoutdegreeZ maxdegreeZmaxindegreeZmaxoutdegree)�yes�no) ZblackZwhiteZblueZredZgreenZyellowZmagentaZ lightgreyZcyanZdarkgreyZdarkblueZdarkredZ darkgreenZ
darkyellowZdarkmagentaZdarkcyanZgoldZ lightblueZlightredZ
lightgreenZlightyellowZlightmagentaZ lightcyanZlilacZ turquoiseZ
aquamarineZkhakiZpurpleZyellowgreenZpinkZorangeZorchid)ZboxZellipseZrhombZtriangle)�centerZleft_justifyZ
right_justify)Zsolid�lineZnone)Z
continuousZdashedZdottedZ invisible)�algos�booleans�colors�shapes� textmodes�arrowstyles�
linestylesr
� r r r r )�title�label�color� textcolor�bordercolor�width�height�borderwidth�textmode�shape�shrink�stretchZorientation�vertical_order�horizontal_orderZxspaceZyspaceZlayoutalgorithmZlate_edge_labelsZdisplay_edge_labelsZdirty_edge_labelsZ
finetuningZmanhattan_edgesZsmanhattan_edgesZport_sharingZedgesZnodesZsplines)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
arrowcolorZbackarrowcolorZ arrowsizeZ
backarrowsizeZ
arrowstyleZbackarrowstyler �priority�anchorr c C sR xL| D ]D}|t jkry(t|�}|dkr:| �|dt|� �} W q Y qX qW | S )z8Convert latin characters using vcg escape sequence.
� z\fi%d)�string�
ascii_letters�ord�replace)�st�char�num� r) �H/opt/alt/python37/lib/python3.7/site-packages/logilab/common/vcgutils.py�latin_to_vcg� s
r+ c @ sR e Zd ZdZdd� Zdd� Zdd� Zdd � Zddd�Zd
d� Z dd� Z
dd� ZdS )�
VCGPrinterzA vcg graph writer.
c C s || _ d| _d S )N� )�_stream�_indent)�selfZ
output_streamr) r) r* �__init__� s zVCGPrinter.__init__c K s, | j �d| j � | �� | jtf|� dS )zopen a vcg graph
z
%sgraph:{
N)r. �writer/ �_inc_indent�_write_attributes�GRAPH_ATTRS)r0 �argsr) r) r* �
open_graph� s zVCGPrinter.open_graphc C s | � � | j�d| j � dS )zclose a vcg graph
z%s}
N)�_dec_indentr. r2 r/ )r0 r) r) r* �close_graph� s zVCGPrinter.close_graphc K s4 | j �d| j|f � | jtf|� | j �d� dS )zdraw a node
z%snode: {title:"%s"z}
N)r. r2 r/ r4 �
NODE_ATTRS)r0 r r6 r) r) r* �node� s zVCGPrinter.noder- c K s8 | j �d| j|||f � | jtf|� | j �d� dS )z-draw an edge from a node to another.
z*%s%sedge: {sourcename:"%s" targetname:"%s"z}
N)r. r2 r/ r4 �
EDGE_ATTRS)r0 Z from_nodeZto_nodeZ edge_typer6 r) r) r* �edge� s
zVCGPrinter.edgec K s� x�|� � D ]�\}}y|| }W n( tk
rF td||�� f ��Y nX |sf| j�d| j||f � q
|dkr�| j�d| j|t|�f � q
||kr�| j�d| j||f � q
td|||f ��q
W dS )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. r2 r/ �int)r0 Zattributes_dictr6 �key�valueZ_typer) r) r* r4 � s zVCGPrinter._write_attributesc C s d| j | _ dS )zincrement indentation
z %sN)r/ )r0 r) r) r* r3 � s zVCGPrinter._inc_indentc C s | j dd� | _ dS )zdecrement indentation
N���)r/ )r0 r) r) r* r8 � s zVCGPrinter._dec_indentN)r- )�__name__�
__module__�__qualname__�__doc__r1 r7 r9 r; r= r4 r3 r8 r) r) r) r* r, � s
r, ) rI �
__docformat__r"