Your IP : 216.73.216.190


Current Path : /lib/python3/dist-packages/certbot/plugins/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/certbot/plugins/__pycache__/disco.cpython-38.pyc

U

�]�'�@s�dZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
ddlmZddlm
Z
ddlmZe�e�ZGdd�de�ZGd	d
�d
ej�ZdS)z.Utilities for plugins discovery and selection.�N)�Dict)�	constants)�errors)�
interfacesc@s�eZdZdZdddddddd	d
ddd
dddddgZdZdd�Zedd��Ze	dd��Z
e	dd��Ze	dd��Ze	dd��Z
d d!�Ze	d"d#��Zd6d$d%�Zd&d'�Ze	d(d)��Zd*d+�Ze	d,d-��Ze	d.d/��Ze	d0d1��Zd2d3�Zd4d5�ZdS)7�PluginEntryPointzPlugin entry point.�certbotzcertbot-apachezcertbot-dns-cloudflarezcertbot-dns-cloudxnszcertbot-dns-digitaloceanzcertbot-dns-dnsimplezcertbot-dns-dnsmadeeasyzcertbot-dns-gehirnzcertbot-dns-googlezcertbot-dns-linodezcertbot-dns-luadnszcertbot-dns-nsonezcertbot-dns-ovhzcertbot-dns-rfc2136zcertbot-dns-route53zcertbot-dns-sakuracloudz
certbot-nginxNcCs,|�|�|_|��|_||_d|_d|_dS�N)�entry_point_to_plugin_name�name�load�
plugin_cls�entry_point�_initialized�	_prepared)�selfr
�r�7/usr/lib/python3/dist-packages/certbot/plugins/disco.py�__init__0s

zPluginEntryPoint.__init__cCs&|jj|jkr|jS|jjd|jS)z)Unique plugin name for an ``entry_point``�:)Zdist�key�PREFIX_FREE_DISTRIBUTIONSr
)�clsr
rrrr	7sz+PluginEntryPoint.entry_point_to_plugin_namecCs|jjS)zDescription of the plugin.)r�description�rrrrr>szPluginEntryPoint.descriptioncCsd�|j|j�S)z$Description with name. Handy for UI.z	{0} ({1}))�formatrr
rrrr�description_with_nameCsz&PluginEntryPoint.description_with_namecCs*z
|jjWStk
r$|jYSXdS)zLong description of the plugin.N)r�long_description�AttributeErrorrrrrrrHs
z!PluginEntryPoint.long_descriptioncCst|jdd�S)z%Should this plugin be hidden from UI?�hiddenF)�getattrrrrrrrPszPluginEntryPoint.hiddencs|pt�fdd�|D��S)z2Does plugin implements specified interface groups?c3s$|]}t�fdd�|D��VqdS)c3s|]}|��j�VqdSr)�
implementedByr��.0�ifacerrr�	<genexpr>Xs�z4PluginEntryPoint.ifaces.<locals>.<genexpr>.<genexpr>N)�all)r"�ifacesrrrr$Ws��z*PluginEntryPoint.ifaces.<locals>.<genexpr>)�any�r�
ifaces_groupsrrrr&Us�zPluginEntryPoint.ifacescCs
|jdk	S)z(Has the plugin been initialized already?N)rrrrr�initialized\szPluginEntryPoint.initializedcCs&|js |j��|�||j�|_|jS)zMemoized plugin initialization.)r*r
Zrequirerr
r�r�configrrr�initas
zPluginEntryPoint.initcCs�|js
t�|D]r}ztjj�||���Wqtjjjk
r~}z0|�	|j
�rftjd|j
|j
|dd�WY�dSd}~XYqXqdS)z<Verify that the plugin conforms to the specified interfaces.z/%s implements %s but object does not verify: %sT��exc_infoFN)r*�AssertionError�zope�	interface�verifyZverifyObjectr-�
exceptionsZBrokenImplementationr r�logger�debug�__name__)rr&r#�errorrrrr3hs
�zPluginEntryPoint.verifycCs|jst�d|�|jdk	S)z%Has the plugin been prepared already?z$.prepared called on uninitialized %rN)r*r5r6rrrrr�preparedvszPluginEntryPoint.preparedc
Cs�|js
t�|jdkr�z|j��Wn�tjk
r^}ztjd||dd�||_W5d}~XYn|tj	k
r�}ztjd||dd�||_W5d}~XYnBtj
k
r�}ztjd||dd�||_W5d}~XYnXd|_|jS)zMemoized plugin preparation.NzMisconfigured %r: %sTr.zNo installation (%r): %szOther error:(%r): %s)r*r0rr�preparer�MisconfigurationErrorr5r6ZNoInstallationErrorZPluginError)rr8rrrr:}s(

�zPluginEntryPoint.preparecCst|jtj�S)zIs plugin misconfigured?)�
isinstancerrr;rrrr�
misconfigured�szPluginEntryPoint.misconfiguredcCst|jt�r|jSdS)zGReturn the Exception raised during plugin setup, or None if all is wellN)r<r�	Exceptionrrrr�problem�szPluginEntryPoint.problemcCs|jdkp|jS)z4Is plugin available, i.e. prepared or misconfigured?T)rr=rrrr�	available�szPluginEntryPoint.availablecCsd�|j�S)NzPluginEntryPoint#{0})rr
rrrr�__repr__�szPluginEntryPoint.__repr__c
Cs�d�|j�d�|jj�d�d�dd�tj�|j�D���d�|j�g}|j	rz|�
d�|����|jrz|�
d	�|�
���d
�|�S)Nz* {0}zDescription: {0}zInterfaces: {0}z, css|]}|jVqdSr)r7r!rrrr$�sz+PluginEntryPoint.__str__.<locals>.<genexpr>zEntry point: {0}zInitialized: {0}z	Prep: {0}�
)rr
rr�joinr1r2r r
r*�appendr-r9r:)r�linesrrr�__str__�s
��
�	zPluginEntryPoint.__str__)N)r7�
__module__�__qualname__�__doc__r�__hash__r�classmethodr	�propertyrrrrr&r*r-r3r9r:r=r?r@rArFrrrrrs^�










rc@s�eZdZdZdd�Zedd��Zdd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd S)!�PluginsRegistryzPlugins registry.cCst�tt�|���|_dSr)�collections�OrderedDict�sorted�six�	iteritems�_plugins)r�pluginsrrrr�s	zPluginsRegistry.__init__cCsri}t�t�tj�t�tj��}|D]D}t|�}|j|ksBt	d��t
j�|j
�r\|||j<q$t�d|�q$||�S)z+Find plugins using setuptools entry points.z#PREFIX_FREE_DISTRIBUTIONS messed upz,%r does not provide IPluginFactory, skipping)�	itertools�chain�
pkg_resourcesZiter_entry_pointsrZSETUPTOOLS_PLUGINS_ENTRY_POINTZ"OLD_SETUPTOOLS_PLUGINS_ENTRY_POINTrr
r0rZIPluginFactoryZ
providedByrr5Zwarning)rrTZentry_pointsr
�	plugin_eprrr�find_all�s*�����zPluginsRegistry.find_allcCs
|j|Sr)rS)rr
rrr�__getitem__�szPluginsRegistry.__getitem__cCs
t|j�Sr)�iterrSrrrr�__iter__�szPluginsRegistry.__iter__cCs
t|j�Sr)�lenrSrrrr�__len__�szPluginsRegistry.__len__cs�fdd�t�|j�D�S)z'Initialize all plugins in the registry.csg|]}|����qSr)r-�r"rX�r,rr�
<listcomp>�sz(PluginsRegistry.init.<locals>.<listcomp>�rQ�
itervaluesrSr+rr`rr-�s

�zPluginsRegistry.initcs&t|�t�fdd�t�|j�D���S)z"Filter plugins based on predicate.c3s"|]\}}�|�r||fVqdSrr)r"r
rX��predrrr$�s�z)PluginsRegistry.filter.<locals>.<genexpr>)�type�dictrQrRrS)rrerrdr�filter�s
�zPluginsRegistry.filtercCs|�dd��S)z#Filter plugins based on visibility.cSs|jSr)r)rXrrr�<lambda>��z)PluginsRegistry.visible.<locals>.<lambda>�rhrrrr�visible�szPluginsRegistry.visiblecs|��fdd��S)z#Filter plugins based on interfaces.cs
|j��Sr�r&��p_ep�r)rrri�rjz(PluginsRegistry.ifaces.<locals>.<lambda>rkr(rrprr&�szPluginsRegistry.ifacescs|��fdd��S)z%Filter plugins based on verification.cs
|���Sr)r3rnrmrrri�rjz(PluginsRegistry.verify.<locals>.<lambda>rk)rr&rrmrr3�szPluginsRegistry.verifycCsdd�t�|j�D�S)z$Prepare all plugins in the registry.cSsg|]}|���qSr)r:r_rrrra�sz+PluginsRegistry.prepare.<locals>.<listcomp>rbrrrrr:�szPluginsRegistry.preparecCs|�dd��S)z%Filter plugins based on availability.cSs|jSr)r@rnrrrrirjz+PluginsRegistry.available.<locals>.<lambda>rkrrrrr@�szPluginsRegistry.availablecs:�fdd�t�|j�D�}t|�dks*t�|r6|dSdS)a�Find an initialized plugin.

        This is particularly useful for finding a name for the plugin
        (although `.IPluginFactory.__call__` takes ``name`` as one of
        the arguments, ``IPlugin.name`` is not part of the interface)::

          # plugin is an instance providing IPlugin, initialized
          # somewhere else in the code
          plugin_registry.find_init(plugin).name

        Returns ``None`` if ``plugin`` is not found in the registry.

        cs"g|]}|jr|���kr|�qSr)r*r-r_��pluginrrras�z-PluginsRegistry.find_init.<locals>.<listcomp>�rN)rQrcrSr]r0)rrrZ
candidatesrrqr�	find_inits
zPluginsRegistry.find_initc	Cs(d�|jjd�dd�t�|j�D���S)Nz{0}({1})�,css|]}t|�VqdSr)�repr�r"rorrrr$sz+PluginsRegistry.__repr__.<locals>.<genexpr>)r�	__class__r7rCrQrcrSrrrrrAs

��zPluginsRegistry.__repr__cCs&|js
dSd�dd�t�|j�D��S)Nz
No pluginsz

css|]}t|�VqdSr)�strrwrrrr$!sz*PluginsRegistry.__str__.<locals>.<genexpr>)rSrCrQrcrrrrrFszPluginsRegistry.__str__N)r7rGrHrIrrKrYrZr\r^r-rhrlr&r3r:r@rtrArFrrrrrM�s"
rM)rIrNrUZloggingrWrQZzope.interfacer1Zzope.interface.verifyZacme.magic_typingrrrrrZ	getLoggerr7r5�objectr�MappingrMrrrr�<module>s
#