__init__.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. """
  2. prompt_toolkit
  3. ==============
  4. Author: Jonathan Slenders
  5. Description: prompt_toolkit is a Library for building powerful interactive
  6. command lines in Python. It can be a replacement for GNU
  7. Readline, but it can be much more than that.
  8. See the examples directory to learn about the usage.
  9. Probably, to get started, you might also want to have a look at
  10. `prompt_toolkit.shortcuts.prompt`.
  11. """
  12. from __future__ import annotations
  13. import re
  14. from importlib import metadata
  15. # note: this is a bit more lax than the actual pep 440 to allow for a/b/rc/dev without a number
  16. pep440 = re.compile(
  17. r"^([1-9]\d*!)?(0|[1-9]\d*)(\.(0|[1-9]\d*))*((a|b|rc)(0|[1-9]\d*)?)?(\.post(0|[1-9]\d*))?(\.dev(0|[1-9]\d*)?)?$",
  18. re.UNICODE,
  19. )
  20. from .application import Application
  21. from .formatted_text import ANSI, HTML
  22. from .shortcuts import PromptSession, choice, print_formatted_text, prompt
  23. # Don't forget to update in `docs/conf.py`!
  24. __version__ = metadata.version("prompt_toolkit")
  25. assert pep440.match(__version__)
  26. # Version tuple.
  27. VERSION = tuple(int(v.rstrip("abrc")) for v in __version__.split(".")[:3])
  28. __all__ = [
  29. # Application.
  30. "Application",
  31. # Shortcuts.
  32. "prompt",
  33. "choice",
  34. "PromptSession",
  35. "print_formatted_text",
  36. # Formatted text.
  37. "HTML",
  38. "ANSI",
  39. # Version info.
  40. "__version__",
  41. "VERSION",
  42. ]