a
    hbòf  ã                   @   sÔ   d dl mZ d dlmZmZmZmZmZmZ d dl	m
Z
mZmZmZ ddlmZmZ ddlmZ ddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZmZ eedœdd„Zeedœdd„Z G dd„ deƒZ!dS )é    )Úabsolute_import)ÚcleandocÚgetdocÚgetfileÚisclassÚismoduleÚ	signature)ÚAnyÚIterableÚOptionalÚTupleé   )ÚRenderableTypeÚGroup)ÚReprHighlighter)ÚJupyterMixin)ÚPanel)ÚPretty)ÚTable)ÚTextÚTextType)ÚdocÚreturnc                 C   s   |   d¡\}}}|S )z)Get the first paragraph from a docstring.z

)Ú	partition)r   Z	paragraphÚ_© r   úV/home/httpd/docs/test/DocsMgr/lib/python3.9/site-packages/pip/_vendor/rich/_inspect.pyÚ_first_paragraph   s    r   c                 C   s   t | ƒ ¡ } | S )zReformat docstring.)r   Ústrip)r   r   r   r   Ú_reformat_doc   s    r   c                   @   s’   e Zd ZdZddddddddddœ	eee eeeeeeeeddœdd„Zee	d	œd
d„Z
edœdd„Zeeee	 dœdd„Zee dœdd„ZdS )ÚInspecta‰  A renderable to inspect any Python Object.

    Args:
        obj (Any): An object to inspect.
        title (str, optional): Title to display over inspect result, or None use type. Defaults to None.
        help (bool, optional): Show full help text rather than just first paragraph. Defaults to False.
        methods (bool, optional): Enable inspection of callables. Defaults to False.
        docs (bool, optional): Also render doc strings. Defaults to True.
        private (bool, optional): Show private attributes (beginning with underscore). Defaults to False.
        dunder (bool, optional): Show attributes starting with double underscore. Defaults to False.
        sort (bool, optional): Sort attributes alphabetically. Defaults to True.
        all (bool, optional): Show all attributes. Defaults to False.
        value (bool, optional): Pretty print value of object. Defaults to True.
    NFT)	ÚtitleÚhelpÚmethodsÚdocsÚprivateÚdunderÚsortÚallÚvalue)Úobjr!   r"   r#   r$   r%   r&   r'   r(   r)   r   c       	         C   sd   t ƒ | _|| _|p|  |¡| _|	r.d } }}|| _|| _|p@|| _|pJ|| _|| _	|| _
|
| _d S )NT)r   Úhighlighterr*   Ú_make_titler!   r"   r#   r$   r%   r&   r'   r)   )Úselfr*   r!   r"   r#   r$   r%   r&   r'   r(   r)   r   r   r   Ú__init__+   s    

zInspect.__init__)r*   r   c                 C   s:   t |ƒst|ƒst|ƒr t|ƒn
tt|ƒƒ}|  |¡}|S )zMake a default title.)r   Úcallabler   ÚstrÚtyper+   )r-   r*   Z	title_strÚ
title_textr   r   r   r,   F   s    ÿÿÿ

ý
zInspect._make_title)r   c                 C   s   t jt|  ¡ Ž | jddd�S )Nzscope.border©r   r   )r!   Úborder_styleÚpadding)r   Úfitr   Ú_renderr!   )r-   r   r   r   Ú__rich__P   s    
üzInspect.__rich__)Únamer*   r   c           	      C   s²   zt t|ƒƒd }W n( ty*   d}Y n ty<   Y dS 0 d}zt|ƒ}W n ty`   Y n0 t|dd�}|r‚| d|› �¡ |  |¡}|pšt|d|ƒ}t 	d|df|¡}|S )	zGet a signature for a callable.ú:z(...)Nzinspect.callable©Ústylezlink file://Ú__qualname__)zdef zinspect.def)
r0   r   Ú
ValueErrorÚ	TypeErrorr   r   Ústylizer+   ÚgetattrÚassemble)	r-   r9   r*   Ú
_signatureZsource_filenameZcallable_nameZsignature_textÚqualnameZqual_signaturer   r   r   Ú_get_signatureX   s(    

ÿzInspect._get_signaturec                 #   sä  t ttf t ttf dœdd„}tt ttf dœ‡ fdd„‰| j‰ tˆ ƒ}t|ƒ}| jsfdd„ |D ƒ}| jszd	d„ |D ƒ}|t|ƒ }‡fd
d„|D ƒ}| j	rª|j	|d� t
jddd�}|jdd� |j}| j}tˆ ƒrø|  dˆ ¡}	|	durø|	V  dV  | j�rFtˆ ƒ}
|
du�rF| j�s"t|
ƒ}
tt|
ƒdd�}||ƒ}|V  dV  | j�rŒtˆ ƒ�sŒtˆ ƒ�sŒtˆ ƒ�sŒttˆ dddd�dd�V  dV  |D �](\}\}}t || d¡�r´dndfd¡}|du�rð| ¡ }| d¡ |||t |ƒƒƒ �q�t|ƒ�r¦| j!�s�q�|  ||¡}|du �r0||t||d �ƒ nt| j�ršt|ƒ}|du�rštt|ƒƒ}
| j�sft|
ƒ}
| "d!|
v �rxd!nd"¡ ||
ƒ}| d#¡ | "|¡ |||ƒ n||t||d �ƒ �q�|j#�rÌ|V  nt $d$|› d%�¡V  dS )&zRender object.)Úitemr   c                 S   s"   | \}\}}t |ƒ| d¡ ¡ fS )Nr   )r/   r   Úlower)rF   ÚkeyÚ_errorr)   r   r   r   Ú
sort_itemsv   s    z#Inspect._render.<locals>.sort_items)Ú	attr_namer   c              
      sB   zdt ˆ | ƒfW S  ty< } z|dfW  Y d}~S d}~0 0 dS )zGet attribute or any exception.N)rA   Ú	Exception)rK   Úerror)r*   r   r   Úsafe_getattrz   s    z%Inspect._render.<locals>.safe_getattrc                 S   s   g | ]}|  d ¡s|‘qS )Ú__©Ú
startswith©Ú.0rH   r   r   r   Ú
<listcomp>…   ó    z#Inspect._render.<locals>.<listcomp>c                 S   s   g | ]}|  d ¡s|‘qS )r   rP   rR   r   r   r   rT   ‡   rU   c                    s   g | ]}|ˆ |ƒf‘qS r   r   rR   )rN   r   r   rT   ‰   rU   )rH   r3   F)r5   ÚexpandÚright)ÚjustifyÚ Nzinspect.helpr;   Té
   é<   )Úindent_guidesÚ
max_lengthÚ
max_stringzinspect.value.border)r4   rO   zinspect.attr.dunderzinspect.attr)z =zinspect.equalszinspect.error)r+   Ú
ú zinspect.docz[b cyan]za[/][i] attribute(s) not shown.[/i] Run [b][magenta]inspect[/]([not b]inspect[/])[/b] for options.)%r   r0   r	   Úboolr*   ÚdirÚlenr&   r%   r'   r   ÚgridÚ
add_columnÚadd_rowr+   r/   rE   r$   r   r"   r   r   r   r)   r   r   r   r   rB   rQ   Úcopyr@   Úreprr#   ÚappendÚ	row_countÚfrom_markup)r-   rJ   ÚkeysZtotal_itemsZnot_shown_countÚitemsÚitems_tablerf   r+   r   Z_docZdoc_textrH   rM   r)   Úkey_textÚwarningZ_signature_textr$   r   r   )r*   rN   r   r7   s   s�     
&þþû







ÿzInspect._render)Ú__name__Ú
__module__r=   Ú__doc__r	   r   r   ra   r.   r   r,   r   r8   r0   rE   r
   r   r7   r   r   r   r   r       s6   ôó
r    N)"Ú
__future__r   Úinspectr   r   r   r   r   r   Útypingr	   r
   r   r   Úconsoler   r   r+   r   Újupyterr   Úpanelr   Úprettyr   Útabler   Útextr   r   r0   r   r   r    r   r   r   r   Ú<module>   s    