Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/graphviz/base.py: 88%

8 statements  

« prev     ^ index     » next       coverage.py v7.2.2, created at 2023-03-26 06:43 +0000

1"""Iterables of DOT source code lines (including final newline).""" 

2 

3import typing 

4 

5from . import copying 

6 

7__all__ = ['Base'] 

8 

9 

10class LineIterable: 

11 """Iterable of DOT Source code lines 

12 (mimics ``file`` objects in text mode).""" 

13 

14 def __iter__(self) -> typing.Iterator[str]: # pragma: no cover 

15 r"""Yield the generated DOT source line by line. 

16 

17 Yields: Line ending with a newline (``'\n'``). 

18 """ 

19 raise NotImplementedError('to be implemented by concrete subclasses') 

20 

21 

22# Common base interface for all exposed classes 

23class Base(LineIterable, copying.CopyBase): 

24 """LineIterator with ``.source`` attribute, that it returns for ``str()``.""" 

25 

26 @property 

27 def source(self) -> str: # pragma: no cover 

28 raise NotImplementedError('to be implemented by concrete subclasses') 

29 

30 def __str__(self) -> str: 

31 """The DOT source code as string.""" 

32 return self.source