← Back
Editing: manager.cpython-38.pyc
U ρ�fU � @ s� d dl mZmZmZ eZdgZd dlZd dlZd dl Z d dl Z d dlZd dlZd dl mZ dZeekrjeneZG dd� d�ZdS )� )�absolute_import�print_function�unicode_literals� PluginManagerN)�Plugin� c @ sF e Zd ZdZdd� Zdd� Zedd� �Zdd � Zd d� Z dd d�Z dS )r z�Find and load plugins. Plugins are stored in files named '*_plugin.py' in the list of directories given to the constructor. c C s6 || _ t|t�r"td�t|����t|�| _d | _d S )NzExpected sequence, got {}) �_app� isinstance� STR_TYPES� TypeError�format�type�list�_plugin_dirs�_plugins)�selfZappZplugin_dirs� r �</usr/lib/python3/dist-packages/janitor/plugincore/manager.py�__init__. s � zPluginManager.__init__c c s� | j D ]�}zdd� t�|�D �}W nH tk rj } z*|jtjkrB� t�d�|�� W Y �qW 5 d}~X Y nX t�d�|t � |��� t|�D ]}tj� ||�V q�qdS )z4Return all filenames in which plugins may be stored.c S s g | ]}|� d �r|�qS )z _plugin.py)�endswith)�.0�filenamer r r � <listcomp>= s �z2PluginManager.get_plugin_files.<locals>.<listcomp>zNo such plugin directory: {}NzPlugin modules in {}: {}) r �os�listdir�OSError�errnoZENOENT�logging�debugr �SPACE�join�sorted�path)r �dirnameZ basenames�errorr r r r �get_plugin_files8 s ��zPluginManager.get_plugin_filesc c s | � � D ] }|V qd S �N)r% )r r r r r �plugin_filesK s zPluginManager.plugin_filesc c sV dd� }dd� t �||�D �}t�d�|t�dd� |D ���� |D ]}|� V qDdS ) z-Find and instantiate all plugins in a module.c S s t �| �ot| t�o| tk S r&