o
    ooi\                     @   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dedeje dedeje dedefdd
ZdS )z+Pipe DOT source code through ``unflatten``.    N   )DEFAULT_ENCODING)_tools)
exceptions   )executeUNFLATTEN_BINARY	unflatten)supported_numberFsourcestaggerfanoutchainencodingreturnc                 C   sr   |r|du rt dtg}|dur|dt|g7 }|r!|d |dur-|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   RequiredArgumentErrorr   strappendr   	run_checkstdout)r   r   r   r   r   cmdproc r   Q/home/ubuntu/.local/lib/python3.10/site-packages/graphviz/backend/unflattening.pyr	      s   !


)__doc__pathlibtypingr   r    r   r   r   __all__Pathr   deprecate_positional_argsr   Optionalintboolr	   r   r   r   r   <module>   s2    

