
    G@d                     Z    d Z ddlZddlmZ  ej        e          Z G d de          ZdS )a  
This module contains the editor extensions controller.

Adapted from pyqode/core/managers/modes.py of the
`PyQode project <https://github.com/pyQode/pyQode>`_.
Original file:
<https://github.com/pyQode/pyqode.core/raw/master/pyqode/core/managers/modes.py>
    N)Managerc                   R     e Zd ZdZ fdZd Zd Zd Zd Zd Z	d Z
d	 Zd
 Z xZS )EditorExtensionsManagerz=Manages the list of editor extensions of the CodeEdit widget.c                 f    t          t          |                               |           i | _        dS )z-Initialize and add a reference to the editor.N)superr   __init___extensions)selfeditor	__class__s     Hlib/python3.11/site-packages/spyder/plugins/editor/extensions/manager.pyr   z EditorExtensionsManager.__init__    s0    %t,,55f===    c                     t                               d                    |j                             || j        |j        <   |                    | j                   |S )zk
        Add a extension to the editor.

        :param extension: The extension instance to add.

        zadding extension {})loggerdebugformatnamer	   
on_installr   )r
   	extensions     r   addzEditorExtensionsManager.add%   sR     	*11).AABBB+4(T[)))r   c                     t                               d                    |                     |                     |          }|                                 | j                            |j                   |S )z
        Remove a extension from the editor.

        :param name_or_klass: The name (or class) of the extension to remove.
        :returns: The removed extension.
        zremoving extension {})r   r   r   geton_uninstallr	   popr   )r
   name_or_klassr   s      r   removezEditorExtensionsManager.remove1   sg     	,33MBBCCCHH]++	   Y^,,,r   c                     t          | j                  rdt          t          | j                                                            d         }|                     |           t          | j                  bdS dS )zr
        Remove all extensions from the editor.

        All extensions are removed fromlist and deleted.
        r   N)lenr	   sortedlistkeysr   )r
   keys     r   clearzEditorExtensionsManager.clear>   s{     $"## 	d.33556677:CKK $"## 	 	 	 	 	r   c                 T    t          |t                    s|j        }| j        |         S )z
        Get a extension by name (or class).

        :param name_or_klass: The name or the class of the extension to get
        :type name_or_klass: str or type
        :rtype: spyder.api.mode.EditorExtension
        )
isinstancestr__name__r	   )r
   r   s     r   r   zEditorExtensionsManager.getH   s,     --- 	3)2M..r   c                 4    | j                                         S )zK
        Return the list of the names of the installed extensions.
        )r	   r!   r
   s    r   r!   zEditorExtensionsManager.keysT   s     $$&&&r   c                 4    | j                                         S )z:
        Return the list of installed extensions.
        )r	   valuesr)   s    r   r+   zEditorExtensionsManager.valuesZ   s     &&(((r   c                 h    t          t          | j                                                            S )z*Return the amount of installed extensions.)r   r    r	   r+   r)   s    r   __len__zEditorExtensionsManager.__len__`   s'    4(//1122333r   c                 |    t          d t          | j                                                  D                       S )zB
        Return the list of extensions.

        :return:
        c                     g | ]\  }}|S  r0   ).0kvs      r   
<listcomp>z4EditorExtensionsManager.__iter__.<locals>.<listcomp>j   s    DDD41aQDDDr   )iterr   r	   itemsr)   s    r   __iter__z EditorExtensionsManager.__iter__d   s8     DD6$*:*@*@*B*B#C#CDDDEEEr   )r'   
__module____qualname____doc__r   r   r   r#   r   r!   r+   r-   r7   __classcell__)r   s   @r   r   r      s        GG    

 
 
    
/ 
/ 
/' ' ') ) )4 4 4F F F F F F Fr   r   )r:   loggingspyder.api.managerr   	getLoggerr'   r   r   r0   r   r   <module>r?      s      ' & & & & & 
	8	$	$MF MF MF MF MFg MF MF MF MF MFr   