U
    &%e                     @   s   d dl mZ ddlmZ ddlmZmZ ddlmZm	Z	m
Z
 ddlmZ ddlmZ ddlmZ dd	lmZ G d
d deZedkrd dlZd dlmZ zejd ZW n ek
r   dZY nX e Zeeed e Zejeddd dS )    )Union   )AlignMethod)cell_lenset_cell_size)ConsoleConsoleOptionsRenderResult)JupyterMixinMeasurement)Style)Textc                	   @   s   e Zd ZdZddddddeeef eeeef eedd	d
dZ	edddZ
eeedddZeeedddZeeedddZdS )Ruleu  A console renderable to draw a horizontal rule (line).

    Args:
        title (Union[str, Text], optional): Text to render in the rule. Defaults to "".
        characters (str, optional): Character(s) used to draw the line. Defaults to "─".
        style (StyleType, optional): Style of Rule. Defaults to "rule.line".
        end (str, optional): Character at end of Rule. defaults to "\\n"
        align (str, optional): How to align the title, one of "left", "center", or "right". Defaults to "center".
     u   ─z	rule.line
center)
charactersstyleendalignN)titler   r   r   r   returnc                C   sN   t |dk rtd|dkr,td|d|| _|| _|| _|| _|| _d S )Nr   z:'characters' argument must have a cell width of at least 1)leftr   rightzAinvalid value for align, expected "left", "center", "right" (not ))r   
ValueErrorr   r   r   r   r   )selfr   r   r   r   r    r   T/var/www/html/Darija-Ai-API/env/lib/python3.8/site-packages/pip/_vendor/rich/rule.py__init__   s    	
zRule.__init__)r   c                 C   s   d| j d| jdS )NzRule(z, r   )r   r   )r   r   r   r   __repr__.   s    zRule.__repr__)consoleoptionsr   c                 c   s   |j }|jr| j sdn| j}t|}| js@| ||V  d S t| jtrT| j}n|j	| jdd}|j
dd|_
|  | jdkrdnd}td	|| }|s| ||V  d S t| jd
}	| jdkrv|j|dd |t|j
 d }
t||
| d  }||
d  |t|j
 t|j
 }t||
| d  }|| |	|j
d | j |	| |	d|j
 | j n| jdkr|j|dd |	| |	d |	|||	j  | j nJ| jdkr|j|dd |	|||j d  | j |	d |	| t|	j
||	_
|	V  d S )N-z	rule.text)r   r    r         r   )r   ellipsis)overflowr   r   r   )	max_width
ascii_onlyr   isasciir   r   
_rule_line
isinstancer   
render_strplainreplaceexpand_tabsr   maxr   truncateappendr   r   )r   r"   r#   widthr   	chars_len
title_textZrequired_spaceZtruncate_width	rule_textZ
side_widthr   Zright_lengthr   r   r   r   __rich_console__1   sZ    





zRule.__rich_console__)r7   r6   r   c                 C   s6   t | j|| d  | j}|| t|j||_|S Nr   )r   r   r   r4   r   r0   )r   r7   r6   r9   r   r   r   r-   i   s    
zRule._rule_linec                 C   s
   t ddS r;   r   )r   r"   r#   r   r   r   __rich_measure__o   s    zRule.__rich_measure__)r   )__name__
__module____qualname____doc__r   strr   r   r   r    r!   r   r   r	   r:   intr-   r   r<   r   r   r   r   r      s2    

 8 r   __main__N)r   zHello, World)r   Zfoor&   )r6   )typingr   r   r   cellsr   r   r"   r   r   r	   jupyterr
   measurer   r   r   textr   r   r=   syspip._vendor.rich.consoleargv
IndexErrorprintr   r   r   r   <module>   s&   i
