U
    d/eI                     @   s   d Z ddlZddlmZ ddlmZ ddlmZ ddlmZ ddlmZ dd	lm	Z	 dd
lm
Z
 ddgZG dd deje	jejeje
jZG dd dejeZG dd dejeZdS )u\  Assemble DOT source code objects.

Example:
    >>> doctest_mark_exe()

    >>> import graphviz
    >>> dot = graphviz.Graph(comment='Mønti Pythøn ik den Hølie Grailen')

    >>> dot.node('Møøse')
    >>> dot.node('trained_by', 'trained by')
    >>> dot.node('tutte', 'TUTTE HERMSGERVORDENBROTBORDA')

    >>> dot.edge('Møøse', 'trained_by')
    >>> dot.edge('trained_by', 'tutte')

    >>> dot.node_attr['shape'] = 'rectangle'

    >>> print(dot.source)  #doctest: +NORMALIZE_WHITESPACE
    // Mønti Pythøn ik den Hølie Grailen
    graph {
        node [shape=rectangle]
        "Møøse"
        trained_by [label="trained by"]
        tutte [label="TUTTE HERMSGERVORDENBROTBORDA"]
        "Møøse" -- trained_by
        trained_by -- tutte
    }

    >>> dot.render('doctest-output/m00se.gv').replace('\\', '/')
    'doctest-output/m00se.gv.pdf'
    N   )DEFAULT_ENCODING)_tools)dot)jupyter_integration)piping)	rendering)unflatteningGraphDigraphc                       s   e Zd ZdZejddddddddedddddfdddeje	 eje	 eje	 eje	 eje	 e
eje	 eje	 dd	 fdd	Zee	d
ddZ  ZS )	BaseGraphz0Dot language creation and source code rendering.   )Zsupported_numberNF)renderer	formatter)	namecommentformatengineencodingstrictr   r   returnc                   sL   |d kr |d k	r | d| j  }t j||||	|
|||||||||d d S )N.)r   r   
graph_attr	node_attr	edge_attrbodyr   filename	directoryr   r   r   r   r   )Z_default_extensionsuper__init__)selfr   r   r   r   r   r   r   r   r   r   r   r   r   r   	__class__ 3/tmp/pip-unpacked-wheel-n8ok7rre/graphviz/graphs.pyr   4   s     
     zBaseGraph.__init__r   c                 C   s
   d | S )z(The generated DOT source code as string. )joinr    r#   r#   r$   sourceL   s    zBaseGraph.source)__name__
__module____qualname____doc__r   Zdeprecate_positional_argsr   typingOptionalstrboolr   propertyr)   __classcell__r#   r#   r!   r$   r   .   s:   
   	 r   c                   @   s"   e Zd ZdZeedddZdS )r
   a  Graph source code in the DOT language.

    Args:
        name: Graph name used in the source code.
        comment: Comment added to the first line of the source.
        filename: Filename for saving the source
            (defaults to ``name`` + ``'.gv'``).
        directory: (Sub)directory for source saving and rendering.
        format: Rendering output format (``'pdf'``, ``'png'``, ...).
        engine: Layout command used (``'dot'``, ``'neato'``, ...).
        renderer: Output renderer used (``'cairo'``, ``'gd'``, ...).
        formatter: Output formatter used (``'cairo'``, ``'gd'``, ...).
        encoding: Encoding for saving the source.
        graph_attr: Mapping of ``(attribute, value)`` pairs for the graph.
        node_attr: Mapping of ``(attribute, value)`` pairs set for all nodes.
        edge_attr: Mapping of ``(attribute, value)`` pairs set for all edges.
        body: Iterable of verbatim lines (including their final newline)
            to add to the graph ``body``.
        strict (bool): Rendering should merge multi-edges.

    Note:
        All parameters are `optional` and can be changed under their
        corresponding attribute name after instance creation.
    r%   c                 C   s   dS )z	``False``Fr#   r(   r#   r#   r$   directedl   s    zGraph.directedN)r*   r+   r,   r-   r2   r1   r4   r#   r#   r#   r$   r
   R   s   c                   @   s@   e Zd ZdZejdk	r*eejdd 7 ZeedddZdS )r   z/Directed graph source code in the DOT language.Nr   r   r%   c                 C   s   dS )z``True``Tr#   r(   r#   r#   r$   r4   x   s    zDigraph.directed)	r*   r+   r,   r-   r
   	partitionr2   r1   r4   r#   r#   r#   r$   r   r   s
   
)r-   r.   r   r   r&   r   r   r   r   r   r	   __all__ZDotZRenderZJupyterIntegrationZPipeZ	Unflattenr   ZGraphSyntaxr
   ZDigraphSyntaxr   r#   r#   r#   r$   <module>   s"     $ 