Your IP : 216.73.216.213


Current Path : /opt/alt/python37/lib64/python3.7/site-packages/twisted/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/site-packages/twisted/__pycache__/plugin.cpython-37.pyc

B

:��]� �@s
dZddlmZmZddlZddlZddlmZmZdd�Z	e	�Z
ddlmZddl
mZdd	lmZdd
lmZddlmZGdd
�d
e�ZGdd�de�ZGdd�de�Zdd�Zy
ejZWnek
r�ddd�ZYnXdd�Zddd�ZeZdd�Z ddgZ!dS)zL
Plugin system for Twisted.

@author: Jp Calderone
@author: Glyph Lefkowitz
�)�absolute_import�divisionN)�	Interface�
providedBycCs.yddl}|Stk
r(ddl}|SXdS)z5
    Determine which 'pickle' API module to use.
    rN)�cPickle�ImportError�pickle)rr�r	�A/opt/alt/python37/lib64/python3.7/site-packages/twisted/plugin.py�_determinePickleModulesr)�getAdapterFactory)�namedAny)�log)�	getModule)�	iteritemsc@seZdZdZdS)�IPluginz�
    Interface that must be implemented by all plugins.

    Only objects which implement this interface will be considered for return
    by C{getPlugins}.  To be useful, plugins should also implement some other
    application-specific interface.
    N)�__name__�
__module__�__qualname__�__doc__r	r	r	r
r)src@s2eZdZdd�Zdd�Zdd�Zd
dd	�ZeZdS)�CachedPlugincCs*||_||_||_||_|jj�|�dS)N)�dropin�name�description�provided�plugins�append)�selfrrrrr	r	r
�__init__5s
zCachedPlugin.__init__cCs&d|j|jjd�dd�|jD��fS)Nz"<CachedPlugin %r/%r (provides %r)>z, cSsg|]
}|j�qSr	)r)�.0�ir	r	r
�
<listcomp>?sz)CachedPlugin.__repr__.<locals>.<listcomp>)rr�
moduleName�joinr)rr	r	r
�__repr__<s
zCachedPlugin.__repr__cCst|jjd|j�S)N�.)r
rr"r)rr	r	r
�loadAszCachedPlugin.loadNcCsDx>|jD]4}|�|�r|��St||d�dk	r||��|�SqW|S)N)rZisOrExtendsr&r)r�	interface�registry�defaultZprovidedInterfacer	r	r
�__conform__Ds
zCachedPlugin.__conform__)NN)rrrrr$r&r*ZgetComponentr	r	r	r
r4s

	rc@seZdZdZdd�ZdS)�CachedDropina�
    A collection of L{CachedPlugin} instances from a particular module in a
    plugin package.

    @type moduleName: C{str}
    @ivar moduleName: The fully qualified name of the plugin module this
        represents.

    @type description: C{str} or L{None}
    @ivar description: A brief explanation of this collection of plugins
        (probably the plugin module's docstring).

    @type plugins: C{list}
    @ivar plugins: The L{CachedPlugin} instances which were loaded from this
        dropin.
    cCs||_||_g|_dS)N)r"rr)rr"rr	r	r
rbszCachedDropin.__init__N)rrrrrr	r	r	r
r+Qsr+cCsTt|j|j�}x@t|j�D]2\}}t|d�}|dk	rt|||jtt|���qW|S)N)	r+rrr�__dict__rr�listr)�providerr�k�v�pluginr	r	r
�_generateCacheEntryis
r2cCsi}x|D]}|||<q
W|S)Nr	)�keys�value�dr/r	r	r
�fromkeysvs
r6cCs�i}t|j�}i}x<|��D]0}|j��}||kr:g||<||}|�|�qW�x|t|�D�]n\}}|�d�}y,|��}	|�	d��}
t
�|
�}WdQRXWni}d}	YnXd}i}
xp|D]h}|j�
d�d}d|
|<||ks�|j��|	kr�d}y|��}Wnt��Yq�Xt|�}|||<q�Wx*t|���D]}||
k�r:||=d}�q:W|�r�y|�t
�|��WnNtk
�r�}ztjd	|j|jd
�Wdd}~XYnt�dd�YnX|�|�q\W|S)a;
    Compute all the possible loadable plugins, while loading as few as
    possible and hitting the filesystem as little as possible.

    @param module: a Python module object.  This represents a package to search
    for plugins.

    @return: a dictionary mapping module names to L{CachedDropin} instances.
    zdropin.cache�rNrFr%���Tz@Unable to write to plugin cache %(path)s: error number %(errno)d)�format�path�errnoz)Unexpected error while writing cache file)rrZiterModulesZfilePath�parentrr�childZgetModificationTime�openrr&r�splitr�errr2r-r3Z
setContent�dumps�OSError�msgr:r;�update)�moduleZallCachesCombined�modZbucketsZplugmodZfpp�bucketZpseudoPackagePathZ
dropinPathZ
lastCached�fZdropinDotCacheZ
needsWriteZexistingKeysZpluginModuleZ	pluginKeyr.�entry�er	r	r
�getCache~s^







rKccsx|dkrddlm}t|�}xVt|�D]J\}}x@|jD]6}y||d�}Wnt��Yq6X|dk	r6|Vq6Wq&WdS)ac
    Retrieve all plugins implementing the given interface beneath the given module.

    @param interface: An interface class.  Only plugins which implement this
    interface will be returned.

    @param package: A package beneath which plugins are installed.  For
    most uses, the default value is correct.

    @return: An iterator of plugins.
    Nr)Ztwisted.pluginsrrKrrr@)r'�packageZ
allDropins�keyrr1Zadaptedr	r	r
�
getPlugins�srNcs|�d���fdd�tjD�S)a�
    Return a list of additional directories which should be searched for
    modules to be included as part of the named plugin package.

    @type name: C{str}
    @param name: The fully-qualified Python name of a plugin package, eg
        C{'twisted.plugins'}.

    @rtype: C{list} of C{str}
    @return: The absolute paths to other directories which may contain plugin
        modules for the named plugin package.
    r%csFg|]>}tj�tjj|f�dg���stj�tjj|f�����qS)z__init__.py)�osr:�existsr#�abspath)r�x)rLr	r
r!�sz&pluginPackagePaths.<locals>.<listcomp>)r?�sysr:)rr	)rLr
�pluginPackagePaths�s

rT)N)N)"r�
__future__rrrOrSZzope.interfacerrrrZtwisted.python.componentsrZtwisted.python.reflectr
Ztwisted.pythonrZtwisted.python.modulesrZtwisted.python.compatrr�objectrr+r2�dictr6�AttributeErrorrKrNZ
getPlugInsrT�__all__r	r	r	r
�<module>s0

I