您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

35 行
828 B

  1. from abc import ABC, abstractmethod
  2. from typing import Any
  3. class Pager(ABC):
  4. """Base class for a pager."""
  5. @abstractmethod
  6. def show(self, content: str) -> None:
  7. """Show content in pager.
  8. Args:
  9. content (str): Content to be displayed.
  10. """
  11. class SystemPager(Pager):
  12. """Uses the pager installed on the system."""
  13. def _pager(self, content: str) -> Any: #  pragma: no cover
  14. return __import__("pydoc").pager(content)
  15. def show(self, content: str) -> None:
  16. """Use the same pager used by pydoc."""
  17. self._pager(content)
  18. if __name__ == "__main__": # pragma: no cover
  19. from .__main__ import make_test_card
  20. from .console import Console
  21. console = Console()
  22. with console.pager(styles=True):
  23. console.print(make_test_card())