HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib/python3/dist-packages/twisted/__pycache__/plugin.cpython-38.pyc
U

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

@author: Jp Calderone
@author: Glyph Lefkowitz
�)�absolute_import�divisionN)�	Interface�
providedBycCs4zddl}|WStk
r.ddl}|YSXdS)z5
    Determine which 'pickle' API module to use.
    rN)�cPickle�ImportError�pickle)rr�r	�0/usr/lib/python3/dist-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#rr%r	r	r
�loadAszCachedPlugin.loadNcCsH|jD]<}|�|�r |��St||d�dk	r||��|�Sq|Sr)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|_dSr)r#rr)rr#rr	r	r
rbszCachedDropin.__init__N)rrrrrr	r	r	r
r-Qsr-cCsPt|j|j�}t|j�D]2\}}t|d�}|dk	rt|||jtt|���q|Sr)	r-rrr�__dict__rr�listr)�providerr�k�v�pluginr	r	r
�_generateCacheEntryis�
r4cCsi}|D]}|||<q|Srr	)�keys�value�dr1r	r	r
�fromkeysvs
r8cCs�i}t|j�}i}|��D]0}|j��}||kr8g||<||}|�|�qt|�D�]f\}}|�d�}z,|��}	|�	d��}
t
�|
�}W5QRXWni}d}	YnXd}i}
|D]h}|j�
d�d}d|
|<||ks�|j��|	kr�d}z|��}Wnt��Yq�Xt|�}|||<q�t|���D]}||
k�r,||=d}�q,|�r�z|�t
�|��WnNtk
�r�}ztjd|j|jd	�W5d
}~XYnt�d
d�YnX|�|�qT|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�rrFr'���Tz@Unable to write to plugin cache %(path)s: error number %(errno)d)�format�path�errnoNz)Unexpected error while writing cache file)rrZiterModulesZfilePath�parentrrZchildZgetModificationTime�openrr(r�splitr�errr4r/r5Z
setContent�dumps�OSError�msgr<r=�update)�moduleZallCachesCombined�modZbucketsZplugmodZfppZbucketZpseudoPackagePathZ
dropinPathZ
lastCached�fZdropinDotCacheZ
needsWriteZexistingKeysZpluginModuleZ	pluginKeyr0�entry�er	r	r
�getCache~sd




�

�rKccsp|dkrddlm}t|�}t|�D]F\}}|jD]6}z||d�}Wnt��Yq2X|dk	r2|Vq2q$dS)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.pluginsrrKrrrA)r)�packageZ
allDropins�keyrr3Zadaptedr	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"�s �z&pluginPackagePaths.<locals>.<listcomp>)r@�sysr<)rr	rSr
�pluginPackagePaths�s


�rU)N)N)"rZ
__future__rrrOrTZzope.interfacerrrrZtwisted.python.componentsrZtwisted.python.reflectr
Ztwisted.pythonrZtwisted.python.modulesrZtwisted.python.compatrr�objectrr-r4�dictr8�AttributeErrorrKrNZ
getPlugInsrU�__all__r	r	r	r
�<module>s0

I