Let us walk on the 3-isogeny graph
Loading...
Searching...
No Matches
constrain.py
Go to the documentation of this file.
1
from
typing
import
Optional, TYPE_CHECKING
2
3
from
.jupyter
import
JupyterMixin
4
from
.measure
import
Measurement
5
6
if
TYPE_CHECKING:
7
from
.console
import
Console, ConsoleOptions, RenderableType, RenderResult
8
9
10
class
Constrain
(
JupyterMixin
):
11
"""Constrain the width of a renderable to a given number of characters.
12
13
Args:
14
renderable (RenderableType): A renderable object.
15
width (int, optional): The maximum width (in characters) to render. Defaults to 80.
16
"""
17
18
def
__init__
(self, renderable:
"RenderableType"
, width: Optional[int] = 80) ->
None
:
19
self.
renderable
= renderable
20
self.
width
= width
21
22
def
__rich_console__
(
23
self, console:
"Console"
, options:
"ConsoleOptions"
24
) ->
"RenderResult"
:
25
if
self.
width
is
None
:
26
yield
self.
renderable
27
else
:
28
child_options =
options.update_width
(min(self.
width
,
options.max_width
))
29
yield
from
console.render
(self.
renderable
, child_options)
30
31
def
__rich_measure__
(
32
self, console:
"Console"
, options:
"ConsoleOptions"
33
) ->
"Measurement"
:
34
if
self.
width
is
not
None
:
35
options =
options.update_width
(self.
width
)
36
measurement =
Measurement.get
(console, options, self.
renderable
)
37
return
measurement
pip._vendor.rich.constrain.Constrain
Definition
constrain.py:10
pip._vendor.rich.constrain.Constrain.__rich_measure__
"Measurement" __rich_measure__(self, "Console" console, "ConsoleOptions" options)
Definition
constrain.py:33
pip._vendor.rich.constrain.Constrain.width
width
Definition
constrain.py:20
pip._vendor.rich.constrain.Constrain.renderable
renderable
Definition
constrain.py:19
pip._vendor.rich.constrain.Constrain.__rich_console__
"RenderResult" __rich_console__(self, "Console" console, "ConsoleOptions" options)
Definition
constrain.py:24
pip._vendor.rich.constrain.Constrain.__init__
None __init__(self, "RenderableType" renderable, Optional[int] width=80)
Definition
constrain.py:18
pip._vendor.rich.jupyter.JupyterMixin
Definition
jupyter.py:36
i
for i
Definition
prime_search.m:10
venv
lib
python3.12
site-packages
pip
_vendor
rich
constrain.py
Generated by
1.9.8