diff options
| author | robot-piglet <[email protected]> | 2026-05-06 08:55:28 +0300 |
|---|---|---|
| committer | robot-piglet <[email protected]> | 2026-05-06 09:12:53 +0300 |
| commit | 8b93efb6bf36b36758242ddee7d809fdd7912019 (patch) | |
| tree | cf48ec2e35122fa24668481185b02dc648e0b08a /contrib/python | |
| parent | 045762a5597f989909267236889e32ff7c60e69d (diff) | |
Intermediate changes
commit_hash:05084c5422c1f89cf16c70f1fc0570da9abad6a0
Diffstat (limited to 'contrib/python')
| -rw-r--r-- | contrib/python/rich/.dist-info/METADATA | 5 | ||||
| -rw-r--r-- | contrib/python/rich/rich/ansi.py | 6 | ||||
| -rw-r--r-- | contrib/python/rich/rich/console.py | 24 | ||||
| -rw-r--r-- | contrib/python/rich/rich/default_styles.py | 1 | ||||
| -rw-r--r-- | contrib/python/rich/rich/file_proxy.py | 3 | ||||
| -rw-r--r-- | contrib/python/rich/rich/markdown.py | 15 | ||||
| -rw-r--r-- | contrib/python/rich/ya.make | 2 |
7 files changed, 39 insertions, 17 deletions
diff --git a/contrib/python/rich/.dist-info/METADATA b/contrib/python/rich/.dist-info/METADATA index 844790c217f..574ddfb0ed7 100644 --- a/contrib/python/rich/.dist-info/METADATA +++ b/contrib/python/rich/.dist-info/METADATA @@ -1,12 +1,12 @@ Metadata-Version: 2.4 Name: rich -Version: 14.3.4 +Version: 15.0.0 Summary: Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal License: MIT License-File: LICENSE Author: Will McGugan Author-email: [email protected] -Requires-Python: >=3.8.0 +Requires-Python: >=3.9.0 Classifier: Development Status :: 5 - Production/Stable Classifier: Environment :: Console Classifier: Framework :: IPython @@ -16,7 +16,6 @@ Classifier: Operating System :: MacOS Classifier: Operating System :: Microsoft :: Windows Classifier: Operating System :: POSIX :: Linux Classifier: Programming Language :: Python :: 3 -Classifier: Programming Language :: Python :: 3.8 Classifier: Programming Language :: Python :: 3.9 Classifier: Programming Language :: Python :: 3.10 Classifier: Programming Language :: Python :: 3.11 diff --git a/contrib/python/rich/rich/ansi.py b/contrib/python/rich/rich/ansi.py index 7de86ce5043..7bbcb0bfcc6 100644 --- a/contrib/python/rich/rich/ansi.py +++ b/contrib/python/rich/rich/ansi.py @@ -127,13 +127,13 @@ class AnsiDecoder: """Decode ANSI codes in an iterable of lines. Args: - lines (Iterable[str]): An iterable of lines of terminal output. + terminal_text: Output potentially containing ANSI escape sequences. Yields: Text: Marked up Text. """ - for line in terminal_text.splitlines(): - yield self.decode_line(line) + for line in re.split(r"(?<=\n)", terminal_text): + yield self.decode_line(line.rstrip("\n")) def decode_line(self, line: str) -> Text: """Decode a line containing ansi codes. diff --git a/contrib/python/rich/rich/console.py b/contrib/python/rich/rich/console.py index 6786980746f..0bdce769874 100644 --- a/contrib/python/rich/rich/console.py +++ b/contrib/python/rich/rich/console.py @@ -7,6 +7,7 @@ from datetime import datetime from functools import wraps from itertools import islice from math import ceil +from os import PathLike from time import monotonic from types import FrameType, ModuleType, TracebackType from typing import ( @@ -1686,7 +1687,10 @@ class Console: new_line_start (bool, False): Insert a new line at the start if the output contains more than one line. Defaults to ``False``. """ if not objects: - objects = (NewLine(),) + if end == "\n": + objects = (NewLine(),) + else: + objects = ("",) if soft_wrap is None: soft_wrap = self.soft_wrap @@ -2217,11 +2221,17 @@ class Console: del self._record_buffer[:] return text - def save_text(self, path: str, *, clear: bool = True, styles: bool = False) -> None: + def save_text( + self, + path: Union[str, PathLike[str]], + *, + clear: bool = True, + styles: bool = False, + ) -> None: """Generate text from console and save to a given location (requires record=True argument in constructor). Args: - path (str): Path to write text files. + path (Union[str, PathLike[str]]): Path to write text files. clear (bool, optional): Clear record buffer after exporting. Defaults to ``True``. styles (bool, optional): If ``True``, ansi style codes will be included. ``False`` for plain text. Defaults to ``False``. @@ -2310,7 +2320,7 @@ class Console: def save_html( self, - path: str, + path: Union[str, PathLike[str]], *, theme: Optional[TerminalTheme] = None, clear: bool = True, @@ -2320,7 +2330,7 @@ class Console: """Generate HTML from console contents and write to a file (requires record=True argument in constructor). Args: - path (str): Path to write html file. + path (Union[str, PathLike[str]]): Path to write html file. theme (TerminalTheme, optional): TerminalTheme object containing console colors. clear (bool, optional): Clear record buffer after exporting. Defaults to ``True``. code_format (str, optional): Format string to render HTML. In addition to '{foreground}', @@ -2595,7 +2605,7 @@ class Console: def save_svg( self, - path: str, + path: Union[str, PathLike[str]], *, title: str = "Rich", theme: Optional[TerminalTheme] = None, @@ -2607,7 +2617,7 @@ class Console: """Generate an SVG file from the console contents (requires record=True in Console constructor). Args: - path (str): The path to write the SVG to. + path (Union[str, PathLike[str]]): The path to write the SVG to. title (str, optional): The title of the tab in the output image theme (TerminalTheme, optional): The ``TerminalTheme`` object to use to style the terminal clear (bool, optional): Clear record buffer after exporting. Defaults to ``True`` diff --git a/contrib/python/rich/rich/default_styles.py b/contrib/python/rich/rich/default_styles.py index c18b6095e48..f2e4cd1b9a1 100644 --- a/contrib/python/rich/rich/default_styles.py +++ b/contrib/python/rich/rich/default_styles.py @@ -165,6 +165,7 @@ DEFAULT_STYLES: Dict[str, Style] = { "markdown.s": Style(strike=True), "markdown.table.border": Style(color="cyan"), "markdown.table.header": Style(color="cyan", bold=False), + "markdown.kbd": Style(bold=True, color="bright_yellow"), "iso8601.date": Style(color="blue"), "iso8601.time": Style(color="magenta"), "iso8601.timezone": Style(color="yellow"), diff --git a/contrib/python/rich/rich/file_proxy.py b/contrib/python/rich/rich/file_proxy.py index 4b0b0da6c2a..e32523bd6ba 100644 --- a/contrib/python/rich/rich/file_proxy.py +++ b/contrib/python/rich/rich/file_proxy.py @@ -55,3 +55,6 @@ class FileProxy(io.TextIOBase): def fileno(self) -> int: return self.__file.fileno() + + def isatty(self) -> bool: + return self.__file.isatty() diff --git a/contrib/python/rich/rich/markdown.py b/contrib/python/rich/rich/markdown.py index 5db183b0a3b..abbbb07d64e 100644 --- a/contrib/python/rich/rich/markdown.py +++ b/contrib/python/rich/rich/markdown.py @@ -331,9 +331,10 @@ class TableDataElement(MarkdownElement): self.justify = justify def on_text(self, context: MarkdownContext, text: TextType) -> None: - text = Text(text) if isinstance(text, str) else text - text.stylize(context.current_style) - self.content.append_text(text) + if isinstance(text, str): + self.content.append(text, context.current_style) + else: + self.content.append_text(text) class ListElement(MarkdownElement): @@ -615,6 +616,14 @@ class Markdown(JupyterMixin): context.enter_style(link_style) else: context.stack.push(Link.create(self, token)) + elif node_type == "html_inline": + if token.content == "<kbd>": + kbd_style = console.get_style("markdown.kbd", default="bold") + context.enter_style(kbd_style) + elif token.content == "</kbd>": + context.leave_style() + else: + continue elif node_type == "link_close": if self.hyperlinks: context.leave_style() diff --git a/contrib/python/rich/ya.make b/contrib/python/rich/ya.make index ec26046baef..15b91eaa189 100644 --- a/contrib/python/rich/ya.make +++ b/contrib/python/rich/ya.make @@ -2,7 +2,7 @@ PY3_LIBRARY() -VERSION(14.3.4) +VERSION(15.0.0) LICENSE(MIT) |
