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

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

9 statements  

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