관리-도구
편집 파일: cells.cpython-38.pyc
U ʗRe� � @ s8 d dl Z d dlmZ d dlmZmZ ddlmZ e �d�j Z ed�eed�d d ��Z e feeegef ed�dd �Zedd�eed�dd��Zedd�eed�dd��Zeeed�dd�Zd#eeeee d�dd�Zedk�r4eed�� edd�D ]Zee� q�eddd �D ]$Zeede�d! � ed"e � �qdS )$� N)� lru_cache)�Callable�List� )�CELL_WIDTHSu ^[ -o ˿Ͱ-҂]*$i )�text�returnc s t � t� fdd�| D ��}|S )a/ Get the number of cells required to display text. This method always caches, which may use up a lot of memory. It is recommended to use `cell_len` over this method. Args: text (str): Text to display. Returns: int: Get the number of cells required to display text. c 3 s | ]}� |�V qd S �N� ��.0� character�� _get_sizer ��/builddir/build/BUILDROOT/alt-python38-pip-22.2.1-2.el8.x86_64/opt/alt/python38/lib/python3.8/site-packages/pip/_vendor/rich/cells.py� <genexpr> s z"cached_cell_len.<locals>.<genexpr>)�get_character_cell_size�sum)r � total_sizer r r �cached_cell_len s r )r � _cell_lenr c s2 t | �dk r|| �S t� t� fdd�| D ��}|S )z�Get the number of cells required to display text. Args: text (str): Text to display. Returns: int: Get the number of cells required to display text. i c 3 s | ]}� |�V qd S r r r r r r r ) s zcell_len.<locals>.<genexpr>)�lenr r )r r r r r r �cell_len s r )�maxsize)r r c C s t t| ��S )��Get the cell size of a character. Args: character (str): A single character. Returns: int: Number of cells (0, 1 or 2) occupied by that character. )�_get_codepoint_cell_size�ord)r r r r r - s r )� codepointr c C s~ t }d}t|�d }|| d }|| \}}}| |k r@|d }n"| |krR|d }n|dkr^dS |S ||k rlqz|| d }q dS )r r r � ���)r r )r �_table�lower_bound�upper_bound�index�start�end�widthr r r r : s r )r �totalr c C s� t | �r4t| �}||k r(| d|| S | d|� S |dkr@dS t| �}||krT| S ||k rl| d|| S d}t| �}|| d }| d|d � }t|�}||d kr�t|d �dkr�|dd� d S ||kr�|S ||kr�|}qx|}qxdS )z?Set the length of a string to fit within given number of cells.� Nr � r r r )�_is_single_cell_widthsr r ) r r'