-
Notifications
You must be signed in to change notification settings - Fork 209
/
unflattening.py
63 lines (51 loc) · 2.4 KB
/
unflattening.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
"""Pipe source through the Graphviz *unflatten* preprocessor."""
import typing
import graphviz
from . import _tools
from . import base
from . import backend
from . import encoding
__all__ = ['Unflatten']
class Unflatten(encoding.Encoding, base.Base, backend.Unflatten):
"""Pipe source through the Graphviz *unflatten* preprocessor."""
@_tools.deprecate_positional_args(supported_number=0, ignore_arg='self')
def unflatten(self,
stagger: typing.Optional[int] = None,
fanout: bool = False,
chain: typing.Optional[int] = None) -> 'graphviz.Source':
"""Return a new :class:`.Source` instance with the source
piped through the Graphviz *unflatten* preprocessor.
Args:
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.
Returns:
Prepocessed DOT source code (improved layout aspect ratio).
Raises:
graphviz.RequiredArgumentError: If ``fanout`` is given
but ``stagger`` is None.
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
"""
from . import sources
out = self._unflatten(self.source,
stagger=stagger, fanout=fanout, chain=chain,
encoding=self.encoding)
kwargs = self._copy_kwargs()
return sources.Source(out,
filename=kwargs.get('filename'),
directory=kwargs.get('directory'),
format=kwargs.get('format'),
engine=kwargs.get('engine'),
encoding=kwargs.get('encoding'),
renderer=kwargs.get('renderer'),
formatter=kwargs.get('formatter'),
loaded_from_path=None)