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

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

15 statements  

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

2 

3import typing 

4 

5import graphviz 

6from . import _tools 

7from . import base 

8from . import backend 

9from . import encoding 

10 

11__all__ = ['Unflatten'] 

12 

13 

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

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

16 

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

18 def unflatten(self, 

19 stagger: typing.Optional[int] = None, 

20 fanout: bool = False, 

21 chain: typing.Optional[int] = None) -> 'graphviz.Source': 

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

23 piped through the Graphviz *unflatten* preprocessor. 

24 

25 Args: 

26 stagger: Stagger the minimum length 

27 of leaf edges between 1 and this small integer. 

28 fanout: Fanout nodes with indegree = outdegree = 1 

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

30 chain: Form disconnected nodes into chains 

31 of up to this many nodes. 

32 

33 Returns: 

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

35 

36 Raises: 

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

38 but ``stagger`` is None. 

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

40 is not found. 

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

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

43 

44 See also: 

45 Upstream documentation: 

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

47 """ 

48 from . import sources 

49 

50 out = self._unflatten(self.source, 

51 stagger=stagger, fanout=fanout, chain=chain, 

52 encoding=self.encoding) 

53 

54 kwargs = self._copy_kwargs() 

55 return sources.Source(out, 

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

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

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

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

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

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

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

63 loaded_from_path=None)