Your IP : 216.73.217.88


Current Path : /opt/alt/python37/lib/python3.7/site-packages/pylint/pyreverse/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib/python3.7/site-packages/pylint/pyreverse/__pycache__/writer.cpython-37.pyc

B

A!p\�@sZdZddlmZddlmZddlmZGdd�d�ZGdd�de�ZGd	d
�d
e�Z	dS)z+Utilities for creating VCG and Dot diagrams�)�is_exception)�
VCGPrinter)�
DotBackendc@sPeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�ZdS)�
DiagramWriterz,base class for writing project diagrams
    cCs$||_|\|_|_|_|_d|_dS)N)�config�	pkg_edges�	inh_edges�	imp_edges�association_edges�printer)�selfr�styles�r�H/opt/alt/python37/lib/python3.7/site-packages/pylint/pyreverse/writer.py�__init__szDiagramWriter.__init__cCshxb|D]Z}|j���dd�}d||jjf}|�||�|jdkrN|�|�n
|�|�|�	�qWdS)z9write files for <project> according to <diadefs>
        � �_z%s.%s�classN)
�title�strip�replacerZ
output_format�set_printerZTYPE�
write_classes�write_packages�close_graph)rZdiadefs�diagram�basename�	file_namerrr�writes


zDiagramWriter.writecCsxxBtt|��dd�d��D]&\}}|jj||�|�dd�||_qWx.|�d�D] }|jj|j	j|j
jf|j�qPWdS)zwrite a package diagramcSs|jS)N)r)�xrrr�<lambda>.�z.DiagramWriter.write_packages.<locals>.<lambda>)�key�box)�label�shape�dependsN)�	enumerate�sorted�modulesr�	emit_node�	get_title�fig_id�get_relationships�	emit_edge�from_object�	to_objectr)rr�i�obj�relrrrr+s"
zDiagramWriter.write_packagescCs�x>tt|jdd�d��D]$\}}|jj|f|�|��||_qWx.|�d�D] }|jj|j	j|j
jf|j�qLWx.|�d�D] }|jj|j	j|j
jf|j�q|Wx8|�d�D]*}|jj|j	j|j
jfd|j
i|j��q�WdS)	zwrite a class diagramcSs|jS)N)r)rrrrr :r!z-DiagramWriter.write_classes.<locals>.<lambda>)r"ZspecializationZ
implementsZassociationr$N)r'r(�objectsrr*�
get_valuesr,r-r.r/r0rr	�namer
)rrr1r2r3rrrr7s 

zDiagramWriter.write_classescCst�dS)zset printerN)�NotImplementedError)rrrrrrrPszDiagramWriter.set_printercCst�dS)zget project titleN)r7)rr2rrrr+TszDiagramWriter.get_titlecCst�dS)z get label and shape for classes.N)r7)rr2rrrr5XszDiagramWriter.get_valuescCst�dS)zfinalize the graphN)r7)rrrrr\szDiagramWriter.close_graphN)�__name__�
__module__�__qualname__�__doc__rrrrrr+r5rrrrrrs
rc@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�	DotWriterz=write dot graphs from a diagram definition and a project
    c	CsDtddd�tddd�tdddd�tddd	d
d�g}t�|||�dS)N�none�open)�	arrowtail�	arrowhead�empty�nodeZdashed)r?r@�style�greenZdiamond�solid)�	fontcolorr?r@rC)�dictrr)rrr
rrrres

zDotWriter.__init__cCs"tdd�}t||d�|_||_dS)z9initialize DotWriter and add options for layout.
        ZBT)Zrankdir)Zadditional_paramN)rGrrr)rrrZlayoutrrrrps
zDotWriter.set_printercCs|jS)zget project title)r)rr2rrrr+wszDotWriter.get_titlecCs~|j}|jdkrd|}|jjsZd|d�|j�f}x|jD]}d||jf}q<Wd|}t|j	�rrt
d|dd	�St
|dd
�S)z`get label and shape for classes.

        The label contains all attributes and methods
        �	interfaceu«interface»\n%sz%s|%s\l|z\lz%s%s()\lz{%s}Zred�record)rFr$r%)r$r%)rr%r�only_classnames�join�attrs�methodsr6rrBrG)rr2r$�funcrrrr5{s

zDotWriter.get_valuescCs|j�|j�dS)z$print the dot graph into <file_name>N)rZgenerater)rrrrr�szDotWriter.close_graphN)	r8r9r:r;rrr+r5rrrrrr<asr<c@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�	VCGWriterz=write vcg graphs from a diagram definition and a project
    cCsHtdddd�tdddd�tddddd�tdddd	�g}t�|||�dS)
NrEr=r)�
arrowstyle�backarrowstyle�
backarrowsize�
Zdotted)rPrQZ	linestylerRrD)rPrQZ	textcolor)rGrr)rrr
rrrr�szVCGWriter.__init__cCsJt|d�|_t|j�|_|jj|ddddd�|jj|j_|jj|j_dS)z$initialize VCGWriter for a UML graphzw+Zdfs�yes�no)rZlayoutalgorithmZlate_edge_labelsZport_sharingZmanhattan_edgesN)	r>�
graph_filerrZ
open_graphrBr*Zedger.)rrrrrrr�szVCGWriter.set_printercCs
d|jS)zget project title in vcg formatz\fb%s\fn)r)rr2rrrr+�szVCGWriter.get_titlec
Cs�t|j�rd|j}n
d|j}|jdkr0d}nd}|jjs�|j}dd�|jD�}tdd	�|jg||D��}d
|d}d||f}x|D]}d
||f}q�W|r�d||f}x|D]}	d||	f}q�Wt	||d�S)z`get label and shape for classes.

        The label contains all attributes and methods
        z\fb\f09%s\fnz\fb%s\fnrHZellipser#cSsg|]
}|j�qSr)r6)�.0rNrrr�
<listcomp>�sz(VCGWriter.get_values.<locals>.<listcomp>css|]}t|�VqdS)N)�len)rWr6rrr�	<genexpr>�sz'VCGWriter.get_values.<locals>.<genexpr>r�z%s\n\f%sz
%s\n\f08%sz%s\n\f10%s())r$r%)
rrBrr%rrJrLrM�maxrG)
rr2r$r%rLrM�maxlen�line�attrrNrrrr5�s&




zVCGWriter.get_valuescCs|j��|j��dS)zclose graph and fileN)rrrV�close)rrrrr�s
zVCGWriter.close_graphN)	r8r9r:r;rrr+r5rrrrrrO�srON)
r;Zpylint.pyreverse.utilsrZpylint.pyreverse.vcgutilsrZpylint.graphrrr<rOrrrr�<module>sL0