%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/janitor/plugincore/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/janitor/plugincore/__pycache__/manager.cpython-312.pyc

�

QKf���r�eZdgZddlZddlZddlZddlZddlZddlZddl	m
Z
dZee
ureneZGd�d�Zy)�
PluginManager�N)�Plugin� c�@�eZdZdZd�Zd�Zed��Zd�Zd�Z	d	d�Z
y)
rz�Find and load plugins.

    Plugins are stored in files named '*_plugin.py' in the list of directories
    given to the constructor.
    c��||_t|t�r#tdj	t|����t
|�|_d|_y)NzExpected sequence, got {})	�_app�
isinstance�	STR_TYPES�	TypeError�format�type�list�_plugin_dirs�_plugins)�self�app�plugin_dirss   �</usr/lib/python3/dist-packages/janitor/plugincore/manager.py�__init__zPluginManager.__init__)sK����	��k�9�-��+�2�2�4��3D�E��
�!��-�����
�c	#�$K�|jD]�}	tj|�D�cgc]}|jd�r|��}}tjdj|tj|���t|�D]$}tjj||����&��ycc}w#t$rL}|j
t
jk7r�tjdj|��Yd}~��d}~wwxYw�w)z4Return all filenames in which plugins may be stored.z
_plugin.pyzNo such plugin directory: {}NzPlugin modules in {}: {})r�os�listdir�endswith�OSError�errno�ENOENT�logging�debugr�SPACE�join�sorted�path)r�dirname�filename�	basenames�errors     r�get_plugin_fileszPluginManager.get_plugin_files4s������(�(�	6�G�

�%'�J�J�w�$7�� ��(�(��6���	��
�M�M�*�1�1��U�Z�Z�	�2��
�#�9�-�
6���g�g�l�l�7�H�5�5�
6�%	6����
�
��;�;�%�,�,�.���
�
�<�C�C�G�L�M���	
�sA�D�B8�B3�B8�A-D�3B8�8	D
�AD�D�D
�
Dc#�>K�|j�D]}|���y�w�N)r()rr%s  r�plugin_fileszPluginManager.plugin_filesLs#�����-�-�/�	�H��N�	�s�c	#�K�d�}tj||�D��cgc]\}}|��	}}}tjdj	|t
j
d�|D����|D]}|����
ycc}}w�w)z-Find and instantiate all plugins in a module.c�d�tj|�xrt|t�xr|tuSr*)�inspect�isclass�
issubclassr)�targets r�	is_pluginz.PluginManager._find_plugins.<locals>.is_pluginTs1������'�)��v�v�.�)��&�(�
rzPlugins in {}: {}c3�2K�|]}t|����y�wr*)�str)�.0�plugins  r�	<genexpr>z.PluginManager._find_plugins.<locals>.<genexpr>as����"L�6�3�v�;�"L�s�N)r.�
getmembersrrrr r!)r�moduler2�name�member�plugin_classes�plugin_classs       r�
_find_pluginszPluginManager._find_pluginsQs�����	�(/�'9�'9�&�)�'L�
�#�t�V�F�
��
�	�
�
��&�&���
�
�"L�^�"L�L�
�	
�
+�	!�L��.� �	!��
�s�B�A>�ABc	�4�tjdj|��tjjtjj
|��\}}|tjvrtj|St|d�5}	tj|||ddtjf�}|cddd�S#t$r7}tjdj||��Yd}~ddd�yd}~wwxYw#1swYyxYw)zLoad a module from a filename.zLoading module from file {}�rz.pyNzFailed to load plugin '{}' ({}))rrrrr#�splitext�basename�sys�modules�open�imp�load_module�	PY_SOURCE�	Exception�warning)rr%�module_name�ignore�fpr9r's       r�_load_modulezPluginManager._load_modulegs����
�
�3�:�:�8�D�E�&!�g�g�.�.�r�w�w�/?�/?��/I�J���V��#�+�+�%��;�;�{�+�+�
�(�C�
 �
	�B�
������X��s�C�M�M�/J����
	�
	��
�
����5�<�<�#�U���
�
	�
	��

��
	�
	�s6�D�)C�D�	D�%D�9D�D�D�DNc�6�|�g}|j��g|_t|j�}t|�}t	|�D]n\}}|�
||||�|j|�}|j
|�D]8}|j|j�|jj|��:�p|jD�cgc]&}|j|k(s||jvs|dk(r|��(}	}tjdj||	��|	Scc}w)a�Return all plugins that have been found.

        Loaded plugins are cached, so they will only be loaded once.

        `condition` is matched against each plugin to determine whether it
        will be returned or not.  A `condition` of the string '*' matches all
        plugins.  The default condition matches all default plugins, since by
        default, plugins have a condition of the empty list.

        If `condition` matches the plugin's condition exactly, the plugin is
        returned.  The plugin's condition can also be a sequence, and if
        `condition` is in that sequence, the plugin is returned.

        Note that even though loaded plugins are cached, calling
        `get_plugin()` with different a `condition` can return a different set
        of plugins.

        If `callback` is specified, it is called after each plugin has
        been found, with the following arguments: filename, index of
        filename in list of files to be examined (starting with 0), and
        total number of files to be examined. The purpose of this is to
        allow the callback to inform the user in case things take a long
        time.
        �*z#plugins for condition '{}' are '{}')rrr+�len�	enumeraterNr>�set_applicationr�append�	conditionrrr)
rrU�callback�	filenames�total�ir%r9r6�pluginss
          r�get_pluginszPluginManager.get_plugins�s$��6���I��=�=� ��D�M��T�.�.�/�I��	�N�E�(��3�
1���8��'��X�q�%�0��*�*�8�4��"�0�0��8�1�F��*�*�4�9�9�5��M�M�(�(��0�1�	
1��-�-�
��� � �I�-��� 0� 0�0���#�
�
��
�	�
�
�1�8�8��G�L�	
����
s�+D)NN)�__name__�
__module__�__qualname__�__doc__rr(�propertyr+r>rNr[�rrrr"s5���	�6�0����!�,%�N:r)r
�
__metaclass__�__all__rrFrCrr.r�janitor.plugincore.pluginrr r4�bytesr
rrarr�<module>rfsK�� �
��
��
�
�
����,�	���%�<�C�S�	�f�fr

Zerion Mini Shell 1.0