U
    d/e\                  	   @   s   d Z ddl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
gZ	e
d
Zejdddddefeeje eeje eeddd
ZdS )z+Pipe DOT source code through ``unflatten``.    N   )DEFAULT_ENCODING)_tools)
exceptions   )executeUNFLATTEN_BINARY	unflatten)Zsupported_numberF)sourcestaggerfanoutchainencodingreturnc                 C   sr   |r|dkrt dtg}|dk	r4|dt|g7 }|rB|d |dk	rZ|dt|g7 }tj|| |dd}|jS )a!  Return DOT ``source`` piped through ``unflatten`` preprocessor as string.

    Args:
        source: DOT source to process
            (improve layout aspect ratio).
        stagger: Stagger the minimum length of leaf edges
            between 1 and this small integer.
        fanout: Fanout nodes with indegree = outdegree = 1
            when staggering (requires ``stagger``).
        chain: Form disconnected nodes into chains of up to this many nodes.
        encoding: Encoding to encode unflatten stdin and decode its stdout.

    Returns:
        Decoded stdout of the Graphviz unflatten command.

    Raises:
        graphviz.RequiredArgumentError: If ``fanout`` is given
            but no ``stagger``.
        graphviz.ExecutableNotFound: If the Graphviz 'unflatten' executable
            is not found.
        graphviz.CalledProcessError: If the returncode (exit status)
            of the unflattening 'unflatten' subprocess is non-zero.

    See also:
        Upstream documentation:
        https://www.graphviz.org/pdf/unflatten.1.pdf
    Nzfanout given without staggerz-lz-fz-cT)inputr   capture_output)r   ZRequiredArgumentErrorr   strappendr   Z	run_checkstdout)r
   r   r   r   r   cmdproc r   A/tmp/pip-unpacked-wheel-n8ok7rre/graphviz/backend/unflattening.pyr	      s    !


)__doc__pathlibtypingr   r    r   r   r   __all__Pathr   Zdeprecate_positional_argsr   Optionalintboolr	   r   r   r   r   <module>   s(   

 