o
    �õ±j¶  ã                   @  sn   d Z ddlmZ ddlmZ ddlmZ er"ddlmZ ddl	m
Z
 g d¢Zddd„Zddd„Zddd„ZdS )zË
Adaptor for building prompt_toolkit styles, starting from a Pygments style.

Usage::

    from pygments.styles.tango import TangoStyle
    style = style_from_pygments_cls(pygments_style_cls=TangoStyle)
é    )Úannotations)ÚTYPE_CHECKINGé   ©ÚStyle)ÚToken)Ústyle_from_pygments_clsÚstyle_from_pygments_dictÚpygments_token_to_classnameÚpygments_style_clsútype[PygmentsStyle]Úreturnr   c                 C  s$   ddl m} t| |ƒsJ ‚t| jƒS )a�  
    Shortcut to create a :class:`.Style` instance from a Pygments style class
    and a style dictionary.

    Example::

        from prompt_toolkit.styles.from_pygments import style_from_pygments_cls
        from pygments.styles import get_style_by_name
        style = style_from_pygments_cls(get_style_by_name('monokai'))

    :param pygments_style_cls: Pygments style class to start from.
    r   r   )Úpygments.styler   Ú
issubclassr	   Ústyles)r   ÚPygmentsStyle© r   ú‘/root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/prompt_toolkit/styles/pygments.pyr      s   
r   Úpygments_dictúdict[Token, str]c                 C  s0   g }|   ¡ D ]\}}| t|ƒ|f¡ qt|ƒS )z�
    Create a :class:`.Style` instance from a Pygments style dictionary.
    (One that maps Token objects to style strings.)
    )ÚitemsÚappendr
   r   )r   Úpygments_styleÚtokenÚstyler   r   r   r	   1   s   r	   r   r   Ústrc                 C  s   d|  }d  |¡ ¡ S )zá
    Turn e.g. `Token.Name.Exception` into `'pygments.name.exception'`.

    (Our Pygments lexer will also turn the tokens that pygments produces in a
    prompt_toolkit list of fragments that match these styling rules.)
    )ÚpygmentsÚ.)ÚjoinÚlower)r   Úpartsr   r   r   r
   >   s   r
   N)r   r   r   r   )r   r   r   r   )r   r   r   r   )Ú__doc__Ú
__future__r   Útypingr   r   r   r   r   Úpygments.tokenr   Ú__all__r   r	   r
   r   r   r   r   Ú<module>   s    	

