o
    j                     @   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 dedefddZdedef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   SC:\Users\bbmin\dev\vps-for-web\.venv\Lib\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	dedee ded	ed
ededededededdfddZdede	fddZ
defddZdededee	 fddZdee f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 || _|p%|| _|| _	|| _
|
| _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__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_titlec                 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__namec           	      C   s   z
t t|d }W n ty   d}Y n
 ty   Y dS w d}zt|}W n	 ty0   Y nw t|dd}|rA|d|  | |}|pMt|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   dt ttf dt ttf fdd}dtdt ttf f fdd| j t }t|}| js6dd	 |D }| js@d
d	 |D }|t| }fdd	|D }| j	rX|j	|d t
jddd}|jdd |j}| j}t r| d }	|	dur|	V  dV  | jrt }
|
dur| jst|
}
tt|
dd}||}|V  dV  | jrt st st stt ddddddV  dV  |D ]\}\}}t||drdndfd}|dur| }|d  |||t | qt|rI| j!sq| ||}|du r||t||d! q| jrCt|}|durCtt|}
| js)t|
}
|"d"|
v r2d"nd# ||
}|d$ |"| ||| q||t||d! q|j#r\|V  dS 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_namec              
      s>   zdt  | fW S  ty } z
|dfW  Y d}~S d}~ww )zGet attribute or any exception.N)rA   	Exception)rK   error)r*   r   r   safe_getattrz   s   z%Inspect._render.<locals>.safe_getattrc                 S      g | ]	}| d s|qS )__
startswith.0rH   r   r   r   
<listcomp>       z#Inspect._render.<locals>.<listcomp>c                 S   rO   )r   rQ   rS   r   r   r   rU      rV   c                    s   g | ]}| |fqS r   r   rS   )rN   r   r   rU      s    )rH   r3   F)r5   expandright)justify Nzinspect.helpr;   T
   <   )indent_guides
max_length
max_stringzinspect.value.border)r4   rP   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   rR   copyr@   reprr#   append	row_countfrom_markup)r-   rJ   keysZtotal_itemsZnot_shown_countitemsitems_tablerg   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   rb   r.   r   r,   r   r8   r0   rE   r
   r   r7   r   r   r   r   r       sL    	


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     