Create a parser with a specified color table and output channel. Call format() to process code.
(self, out: Any = sys.stdout, *, theme_name: str | None = None)
| 400 | raw: str |
| 401 | |
| 402 | def __init__(self, out: Any = sys.stdout, *, theme_name: str | None = None) -> None: |
| 403 | """Create a parser with a specified color table and output channel. |
| 404 | |
| 405 | Call format() to process code. |
| 406 | """ |
| 407 | |
| 408 | assert theme_name is not None |
| 409 | |
| 410 | self.out = out |
| 411 | self.pos = 0 |
| 412 | self.lines = [] |
| 413 | self.raw = "" |
| 414 | if theme_name is not None: |
| 415 | if theme_name in ["Linux", "LightBG", "Neutral", "NoColor"]: |
| 416 | warnings.warn( |
| 417 | f"Theme names and color schemes are lowercase in IPython 9.0 use {theme_name.lower()} instead", |
| 418 | DeprecationWarning, |
| 419 | stacklevel=2, |
| 420 | ) |
| 421 | theme_name = theme_name.lower() |
| 422 | if not theme_name: |
| 423 | self.theme_name = "nocolor" |
| 424 | else: |
| 425 | self.theme_name = theme_name |
| 426 | |
| 427 | @property |
| 428 | def theme_name(self) -> str: |