Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/graphviz/backend/mixins.py: 86%

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

37 statements  

1"""Mixin classes used by Base subclasses to inherit backend functionality.""" 

2 

3import os 

4 

5from .. import parameters 

6 

7from . import piping 

8from . import rendering 

9from . import unflattening 

10from . import viewing 

11 

12__all__ = ['Render', 'Pipe', 'Unflatten', 'View'] 

13 

14 

15class Render(parameters.Parameters): 

16 """Parameters for calling and calling ``graphviz.render()``.""" 

17 

18 _get_format = staticmethod(rendering.get_format) 

19 

20 _get_filepath = staticmethod(rendering.get_filepath) 

21 

22 def _get_render_parameters(self, 

23 outfile: os.PathLike[str] | str | None = None, 

24 raise_if_result_exists: bool = False, 

25 overwrite_source: bool = False, 

26 **kwargs): 

27 kwargs = self._get_parameters(**kwargs) 

28 kwargs.update(outfile=outfile, 

29 raise_if_result_exists=raise_if_result_exists, 

30 overwrite_filepath=overwrite_source) 

31 return [kwargs.pop('engine'), kwargs.pop('format')], kwargs 

32 

33 @property 

34 def _render(_): # noqa: N805 

35 """Simplify ``._render()`` mocking.""" 

36 return rendering.render 

37 

38 

39class Pipe(parameters.Parameters): 

40 """Parameters for calling and calling ``graphviz.pipe()``.""" 

41 

42 def _get_pipe_parameters(self, **kwargs): 

43 kwargs = self._get_parameters(**kwargs) 

44 return [kwargs.pop('engine'), kwargs.pop('format')], kwargs 

45 

46 @property 

47 def _pipe_lines(_): # noqa: N805 

48 """Simplify ``._pipe_lines()`` mocking.""" 

49 return piping.pipe_lines 

50 

51 @property 

52 def _pipe_lines_string(_): # noqa: N805 

53 """Simplify ``._pipe_lines_string()`` mocking.""" 

54 return piping.pipe_lines_string 

55 

56 

57class Unflatten: 

58 

59 @property 

60 def _unflatten(_): # noqa: N805 

61 """Simplify ``._unflatten mocking.""" 

62 return unflattening.unflatten 

63 

64 

65class View: 

66 """Open filepath with its default viewing application 

67 (platform-specific).""" 

68 

69 _view_darwin = staticmethod(viewing.view_darwin) 

70 

71 _view_freebsd = staticmethod(viewing.view_unixoid) 

72 

73 _view_linux = staticmethod(viewing.view_unixoid) 

74 

75 _view_windows = staticmethod(viewing.view_windows)