Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/graphviz/unflattening.py: 71%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

14 statements  

1"""Pipe source through the Graphviz *unflatten* preprocessor.""" 

2 

3import graphviz 

4from . import _tools 

5from . import base 

6from . import backend 

7from . import encoding 

8 

9__all__ = ['Unflatten'] 

10 

11 

12class Unflatten(encoding.Encoding, base.Base, backend.Unflatten): 

13 """Pipe source through the Graphviz *unflatten* preprocessor.""" 

14 

15 @_tools.deprecate_positional_args(supported_number=0, ignore_arg='self') 

16 def unflatten(self, 

17 stagger: int | None = None, 

18 fanout: bool = False, 

19 chain: int | None = None) -> 'graphviz.Source': 

20 """Return a new :class:`.Source` instance with the source 

21 piped through the Graphviz *unflatten* preprocessor. 

22 

23 Args: 

24 stagger: Stagger the minimum length 

25 of leaf edges between 1 and this small integer. 

26 fanout: Fanout nodes with indegree = outdegree = 1 

27 when staggering (requires ``stagger``). 

28 chain: Form disconnected nodes into chains 

29 of up to this many nodes. 

30 

31 Returns: 

32 Prepocessed DOT source code (improved layout aspect ratio). 

33 

34 Raises: 

35 graphviz.RequiredArgumentError: If ``fanout`` is given 

36 but ``stagger`` is None. 

37 graphviz.ExecutableNotFound: If the Graphviz ``unflatten`` executable 

38 is not found. 

39 graphviz.CalledProcessError: If the returncode (exit status) 

40 of the unflattening 'unflatten' subprocess is non-zero. 

41 

42 See also: 

43 Upstream documentation: 

44 https://www.graphviz.org/pdf/unflatten.1.pdf 

45 """ 

46 from . import sources 

47 

48 out = self._unflatten(self.source, 

49 stagger=stagger, fanout=fanout, chain=chain, 

50 encoding=self.encoding) 

51 

52 kwargs = self._copy_kwargs() 

53 return sources.Source(out, 

54 filename=kwargs.get('filename'), 

55 directory=kwargs.get('directory'), 

56 format=kwargs.get('format'), 

57 engine=kwargs.get('engine'), 

58 encoding=kwargs.get('encoding'), 

59 renderer=kwargs.get('renderer'), 

60 formatter=kwargs.get('formatter'), 

61 loaded_from_path=None)