U
    祡c                  	   @   s   d dl mZ d dlmZ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 ddlmZmZ ertdd	lmZ d
ddd
d
ddee eeee ee ddddZedkrd dlmZ e  eed
dddZedd e  d
S )    )Mapping)TYPE_CHECKINGAnyOptionalTuple   )ReprHighlighter)Panel)Pretty)Table)TextTextType)ConsoleRenderableNTF)title	sort_keysindent_guides
max_length
max_stringzMapping[str, Any]r   )scoper   r   r   r   r   returnc                C   s   t  }tjddd}|jdd tttf tttf ddd}|rTt| 	 |d	n| 	 }	|	D ]@\}
}t
|
|
d
r|dndfd}||t|||||d q`tj||dddS )a  Render python variables in a given scope.

    Args:
        scope (Mapping): A mapping containing variable names and values.
        title (str, optional): Optional title. Defaults to None.
        sort_keys (bool, optional): Enable sorting of items. Defaults to True.
        indent_guides (bool, optional): Enable indentation guides. Defaults to False.
        max_length (int, optional): Maximum length of containers before abbreviating, or None for no abbreviation.
            Defaults to None.
        max_string (int, optional): Maximum length of string before truncating, or None to disable. Defaults to None.

    Returns:
        ConsoleRenderable: A renderable object.
    )r   r   F)paddingexpandright)Zjustify)itemr   c                 S   s   | \}}| d | fS )z2Sort special variables first, then alphabetically.__)
startswithlower)r   key_ r   ./tmp/pip-unpacked-wheel-qkhzhrww/rich/scope.py
sort_items)   s    z render_scope.<locals>.sort_items)r   r   zscope.key.specialz	scope.key)z =zscope.equals)highlighterr   r   r   zscope.border)r   Zborder_styler   )r   r   ZgridZ
add_columnr   strr   boolsorteditemsr   Zassembler   Zadd_rowr
   r	   Zfit)r   r   r   r   r   r   r"   Zitems_tabler!   r&   r   valueZkey_textr   r   r    render_scope   s4     
r(   __main__)print)foobarr   c                 C   sF   dddd ddddg}dd	d
dddgdgdd}t tt ddd d S )Nr            TFzHello Worldz1.1ZconfirmFruitPurchaseZappleZorangeZmangoesZpomelog+?Z	194521489)versionmethodparamsidz	[i]locals)r   r   )r*   r(   locals)r+   r,   Zlist_of_thingsZdict_of_thingsr   r   r    testK   s    r5   gk	W4@g?$	@)collections.abcr   typingr   r   r   r   r"   r   Zpanelr	   prettyr
   tabler   textr   r   consoler   r$   intr(   __name__Zrichr*   floatr5   r   r   r   r    <module>   s8   8

