SILENT KILLERPanel

Current Path: > > opt > > hc_python > lib > python3.12 > site-packages > pip > > _vendor > rich


Operation   : Linux premium131.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
Software     : Apache
Server IP    : 162.0.232.56 | Your IP: 216.73.216.111
Domains      : 1034 Domain(s)
Permission   : [ 0755 ]

Files and Folders in: //opt//hc_python/lib/python3.12/site-packages/pip//_vendor/rich

NameTypeSizeLast ModifiedActions
__pycache__ Directory - -
__init__.py File 6090 bytes May 23 2025 10:34:25.
__main__.py File 8477 bytes May 23 2025 10:34:25.
_cell_widths.py File 10209 bytes May 23 2025 10:34:25.
_emoji_codes.py File 140235 bytes May 23 2025 10:34:25.
_emoji_replace.py File 1064 bytes May 23 2025 10:34:25.
_export_format.py File 2128 bytes May 23 2025 10:34:25.
_extension.py File 265 bytes May 23 2025 10:34:25.
_fileno.py File 799 bytes May 23 2025 10:34:25.
_inspect.py File 9655 bytes May 23 2025 10:34:25.
_log_render.py File 3225 bytes May 23 2025 10:34:25.
_loop.py File 1236 bytes May 23 2025 10:34:25.
_null_file.py File 1394 bytes May 23 2025 10:34:25.
_palettes.py File 7063 bytes May 23 2025 10:34:25.
_pick.py File 423 bytes May 23 2025 10:34:25.
_ratio.py File 5471 bytes May 23 2025 10:34:25.
_spinners.py File 19919 bytes May 23 2025 10:34:25.
_stack.py File 351 bytes May 23 2025 10:34:25.
_timer.py File 417 bytes May 23 2025 10:34:25.
_win32_console.py File 22755 bytes May 23 2025 10:34:25.
_windows.py File 1925 bytes May 23 2025 10:34:25.
_windows_renderer.py File 2783 bytes May 23 2025 10:34:25.
_wrap.py File 3404 bytes May 23 2025 10:34:25.
abc.py File 890 bytes May 23 2025 10:34:25.
align.py File 10469 bytes May 23 2025 10:34:25.
ansi.py File 6921 bytes May 23 2025 10:34:25.
bar.py File 3263 bytes May 23 2025 10:34:25.
box.py File 10831 bytes May 23 2025 10:34:25.
cells.py File 5130 bytes May 23 2025 10:34:25.
color.py File 18211 bytes May 23 2025 10:34:25.
color_triplet.py File 1054 bytes May 23 2025 10:34:25.
columns.py File 7131 bytes May 23 2025 10:34:25.
console.py File 100565 bytes May 23 2025 10:34:25.
constrain.py File 1288 bytes May 23 2025 10:34:25.
containers.py File 5502 bytes May 23 2025 10:34:25.
control.py File 6630 bytes May 23 2025 10:34:25.
default_styles.py File 8257 bytes May 23 2025 10:34:25.
diagnose.py File 998 bytes May 23 2025 10:34:25.
emoji.py File 2501 bytes May 23 2025 10:34:25.
errors.py File 642 bytes May 23 2025 10:34:25.
file_proxy.py File 1683 bytes May 23 2025 10:34:25.
filesize.py File 2484 bytes May 23 2025 10:34:25.
highlighter.py File 9586 bytes May 23 2025 10:34:25.
json.py File 5031 bytes May 23 2025 10:34:25.
jupyter.py File 3252 bytes May 23 2025 10:34:25.
layout.py File 14004 bytes May 23 2025 10:34:25.
live.py File 14270 bytes May 23 2025 10:34:25.
live_render.py File 3666 bytes May 23 2025 10:34:25.
logging.py File 12458 bytes May 23 2025 10:34:25.
markup.py File 8451 bytes May 23 2025 10:34:25.
measure.py File 5305 bytes May 23 2025 10:34:25.
padding.py File 4908 bytes May 23 2025 10:34:25.
pager.py File 828 bytes May 23 2025 10:34:25.
palette.py File 3396 bytes May 23 2025 10:34:25.
panel.py File 11225 bytes May 23 2025 10:34:25.
pretty.py File 36391 bytes May 23 2025 10:34:25.
progress.py File 60357 bytes May 23 2025 10:34:25.
progress_bar.py File 8162 bytes May 23 2025 10:34:25.
prompt.py File 12447 bytes May 23 2025 10:34:25.
protocol.py File 1391 bytes May 23 2025 10:34:25.
py.typed File 0 bytes May 23 2025 10:34:25.
region.py File 166 bytes May 23 2025 10:34:25.
repr.py File 4431 bytes May 23 2025 10:34:25.
rule.py File 4602 bytes May 23 2025 10:34:25.
scope.py File 2843 bytes May 23 2025 10:34:25.
screen.py File 1591 bytes May 23 2025 10:34:25.
segment.py File 24743 bytes May 23 2025 10:34:25.
spinner.py File 4364 bytes May 23 2025 10:34:25.
status.py File 4424 bytes May 23 2025 10:34:25.
style.py File 27059 bytes May 23 2025 10:34:25.
styled.py File 1258 bytes May 23 2025 10:34:25.
syntax.py File 35763 bytes May 23 2025 10:34:25.
table.py File 40049 bytes May 23 2025 10:34:25.
terminal_theme.py File 3370 bytes May 23 2025 10:34:25.
text.py File 47552 bytes May 23 2025 10:34:25.
theme.py File 3771 bytes May 23 2025 10:34:25.
themes.py File 102 bytes May 23 2025 10:34:25.
traceback.py File 35170 bytes May 23 2025 10:34:25.
tree.py File 9451 bytes May 23 2025 10:34:25.

Reading File: //opt//hc_python/lib/python3.12/site-packages/pip//_vendor/rich/align.py

import sys
from itertools import chain
from typing import TYPE_CHECKING, Iterable, Optional

if sys.version_info >= (3, 8):
    from typing import Literal
else:
    from pip._vendor.typing_extensions import Literal  # pragma: no cover

from .constrain import Constrain
from .jupyter import JupyterMixin
from .measure import Measurement
from .segment import Segment
from .style import StyleType

if TYPE_CHECKING:
    from .console import Console, ConsoleOptions, RenderableType, RenderResult

AlignMethod = Literal["left", "center", "right"]
VerticalAlignMethod = Literal["top", "middle", "bottom"]


class Align(JupyterMixin):
    """Align a renderable by adding spaces if necessary.

    Args:
        renderable (RenderableType): A console renderable.
        align (AlignMethod): One of "left", "center", or "right""
        style (StyleType, optional): An optional style to apply to the background.
        vertical (Optional[VerticalAlignMethod], optional): Optional vertical align, one of "top", "middle", or "bottom". Defaults to None.
        pad (bool, optional): Pad the right with spaces. Defaults to True.
        width (int, optional): Restrict contents to given width, or None to use default width. Defaults to None.
        height (int, optional): Set height of align renderable, or None to fit to contents. Defaults to None.

    Raises:
        ValueError: if ``align`` is not one of the expected values.
    """

    def __init__(
        self,
        renderable: "RenderableType",
        align: AlignMethod = "left",
        style: Optional[StyleType] = None,
        *,
        vertical: Optional[VerticalAlignMethod] = None,
        pad: bool = True,
        width: Optional[int] = None,
        height: Optional[int] = None,
    ) -> None:
        if align not in ("left", "center", "right"):
            raise ValueError(
                f'invalid value for align, expected "left", "center", or "right" (not {align!r})'
            )
        if vertical is not None and vertical not in ("top", "middle", "bottom"):
            raise ValueError(
                f'invalid value for vertical, expected "top", "middle", or "bottom" (not {vertical!r})'
            )
        self.renderable = renderable
        self.align = align
        self.style = style
        self.vertical = vertical
        self.pad = pad
        self.width = width
        self.height = height

    def __repr__(self) -> str:
        return f"Align({self.renderable!r}, {self.align!r})"

    @classmethod
    def left(
        cls,
        renderable: "RenderableType",
        style: Optional[StyleType] = None,
        *,
        vertical: Optional[VerticalAlignMethod] = None,
        pad: bool = True,
        width: Optional[int] = None,
        height: Optional[int] = None,
    ) -> "Align":
        """Align a renderable to the left."""
        return cls(
            renderable,
            "left",
            style=style,
            vertical=vertical,
            pad=pad,
            width=width,
            height=height,
        )

    @classmethod
    def center(
        cls,
        renderable: "RenderableType",
        style: Optional[StyleType] = None,
        *,
        vertical: Optional[VerticalAlignMethod] = None,
        pad: bool = True,
        width: Optional[int] = None,
        height: Optional[int] = None,
    ) -> "Align":
        """Align a renderable to the center."""
        return cls(
            renderable,
            "center",
            style=style,
            vertical=vertical,
            pad=pad,
            width=width,
            height=height,
        )

    @classmethod
    def right(
        cls,
        renderable: "RenderableType",
        style: Optional[StyleType] = None,
        *,
        vertical: Optional[VerticalAlignMethod] = None,
        pad: bool = True,
        width: Optional[int] = None,
        height: Optional[int] = None,
    ) -> "Align":
        """Align a renderable to the right."""
        return cls(
            renderable,
            "right",
            style=style,
            vertical=vertical,
            pad=pad,
            width=width,
            height=height,
        )

    def __rich_console__(
        self, console: "Console", options: "ConsoleOptions"
    ) -> "RenderResult":
        align = self.align
        width = console.measure(self.renderable, options=options).maximum
        rendered = console.render(
            Constrain(
                self.renderable, width if self.width is None else min(width, self.width)
            ),
            options.update(height=None),
        )
        lines = list(Segment.split_lines(rendered))
        width, height = Segment.get_shape(lines)
        lines = Segment.set_shape(lines, width, height)
        new_line = Segment.line()
        excess_space = options.max_width - width
        style = console.get_style(self.style) if self.style is not None else None

        def generate_segments() -> Iterable[Segment]:
            if excess_space <= 0:
                # Exact fit
                for line in lines:
                    yield from line
                    yield new_line

            elif align == "left":
                # Pad on the right
                pad = Segment(" " * excess_space, style) if self.pad else None
                for line in lines:
                    yield from line
                    if pad:
                        yield pad
                    yield new_line

            elif align == "center":
                # Pad left and right
                left = excess_space // 2
                pad = Segment(" " * left, style)
                pad_right = (
                    Segment(" " * (excess_space - left), style) if self.pad else None
                )
                for line in lines:
                    if left:
                        yield pad
                    yield from line
                    if pad_right:
                        yield pad_right
                    yield new_line

            elif align == "right":
                # Padding on left
                pad = Segment(" " * excess_space, style)
                for line in lines:
                    yield pad
                    yield from line
                    yield new_line

        blank_line = (
            Segment(f"{' ' * (self.width or options.max_width)}\n", style)
            if self.pad
            else Segment("\n")
        )

        def blank_lines(count: int) -> Iterable[Segment]:
            if count > 0:
                for _ in range(count):
                    yield blank_line

        vertical_height = self.height or options.height
        iter_segments: Iterable[Segment]
        if self.vertical and vertical_height is not None:
            if self.vertical == "top":
                bottom_space = vertical_height - height
                iter_segments = chain(generate_segments(), blank_lines(bottom_space))
            elif self.vertical == "middle":
                top_space = (vertical_height - height) // 2
                bottom_space = vertical_height - top_space - height
                iter_segments = chain(
                    blank_lines(top_space),
                    generate_segments(),
                    blank_lines(bottom_space),
                )
            else:  #  self.vertical == "bottom":
                top_space = vertical_height - height
                iter_segments = chain(blank_lines(top_space), generate_segments())
        else:
            iter_segments = generate_segments()
        if self.style:
            style = console.get_style(self.style)
            iter_segments = Segment.apply_style(iter_segments, style)
        yield from iter_segments

    def __rich_measure__(
        self, console: "Console", options: "ConsoleOptions"
    ) -> Measurement:
        measurement = Measurement.get(console, options, self.renderable)
        return measurement


class VerticalCenter(JupyterMixin):
    """Vertically aligns a renderable.

    Warn:
        This class is deprecated and may be removed in a future version. Use Align class with
        `vertical="middle"`.

    Args:
        renderable (RenderableType): A renderable object.
        style (StyleType, optional): An optional style to apply to the background. Defaults to None.
    """

    def __init__(
        self,
        renderable: "RenderableType",
        style: Optional[StyleType] = None,
    ) -> None:
        self.renderable = renderable
        self.style = style

    def __repr__(self) -> str:
        return f"VerticalCenter({self.renderable!r})"

    def __rich_console__(
        self, console: "Console", options: "ConsoleOptions"
    ) -> "RenderResult":
        style = console.get_style(self.style) if self.style is not None else None
        lines = console.render_lines(
            self.renderable, options.update(height=None), pad=False
        )
        width, _height = Segment.get_shape(lines)
        new_line = Segment.line()
        height = options.height or options.size.height
        top_space = (height - len(lines)) // 2
        bottom_space = height - top_space - len(lines)
        blank_line = Segment(f"{' ' * width}", style)

        def blank_lines(count: int) -> Iterable[Segment]:
            for _ in range(count):
                yield blank_line
                yield new_line

        if top_space > 0:
            yield from blank_lines(top_space)
        for line in lines:
            yield from line
            yield new_line
        if bottom_space > 0:
            yield from blank_lines(bottom_space)

    def __rich_measure__(
        self, console: "Console", options: "ConsoleOptions"
    ) -> Measurement:
        measurement = Measurement.get(console, options, self.renderable)
        return measurement


if __name__ == "__main__":  # pragma: no cover
    from pip._vendor.rich.console import Console, Group
    from pip._vendor.rich.highlighter import ReprHighlighter
    from pip._vendor.rich.panel import Panel

    highlighter = ReprHighlighter()
    console = Console()

    panel = Panel(
        Group(
            Align.left(highlighter("align='left'")),
            Align.center(highlighter("align='center'")),
            Align.right(highlighter("align='right'")),
        ),
        width=60,
        style="on dark_blue",
        title="Align",
    )

    console.print(
        Align.center(panel, vertical="middle", style="on red", height=console.height)
    )

SILENT KILLER Tool