python (3.12.0)
1 from abc import ABC, abstractmethod
2 from typing import Any
3
4
5 class ESC[4;38;5;81mPager(ESC[4;38;5;149mABC):
6 """Base class for a pager."""
7
8 @abstractmethod
9 def show(self, content: str) -> None:
10 """Show content in pager.
11
12 Args:
13 content (str): Content to be displayed.
14 """
15
16
17 class ESC[4;38;5;81mSystemPager(ESC[4;38;5;149mPager):
18 """Uses the pager installed on the system."""
19
20 def _pager(self, content: str) -> Any: # pragma: no cover
21 return __import__("pydoc").pager(content)
22
23 def show(self, content: str) -> None:
24 """Use the same pager used by pydoc."""
25 self._pager(content)
26
27
28 if __name__ == "__main__": # pragma: no cover
29 from .__main__ import make_test_card
30 from .console import Console
31
32 console = Console()
33 with console.pager(styles=True):
34 console.print(make_test_card())