§
    Ètºf!  ã                   ó–  — d Z ddlZddlZddlZddlZddlmZmZmZm	Z	 ddl
mZmZ ddlmZ ddlmZ ddlmZ ddlmZ  G d	„ d
e¦  «        Z G d„ d¦  «        Z G d„ d¦  «        Zd„ Z	 ej        Zn# e$ r dd„ZY nw xY wd„ Zdej        fd„Z e	de¬¦  «        Z	 ddee         deej                 dee         fd„Z e Z!d„ Z"ddgZ#dS )zL
Plugin system for Twisted.

@author: Jp Calderone
@author: Glyph Lefkowitz
é    N)ÚIterableÚOptionalÚTypeÚTypeVar)Ú	InterfaceÚ
providedBy)Úlog)ÚgetAdapterFactory)Ú	getModule)ÚnamedAnyc                   ó   — e Zd ZdZdS )Ú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__© ó    úM/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/twisted/plugin.pyr   r      s   € € € € € ðð ð ð r   r   c                   ó2   — e Zd Zd„ Zdefd„Zd„ Zdd„ZeZdS )ÚCachedPluginc                 ó|   — || _         || _        || _        || _        | j         j                             | ¦  «         d S ©N)ÚdropinÚnameÚdescriptionÚprovidedÚpluginsÚappend)Úselfr   r   r   r   s        r   Ú__init__zCachedPlugin.__init__'   s>   € ØˆŒØˆŒ	Ø&ˆÔØ ˆŒØŒÔ×"Ò" 4Ñ(Ô(Ð(Ð(Ð(r   Úreturnc                 ó’   — d                      | j        | j        j        d                     d„ | j        D ¦   «         ¦  «        ¦  «        S )Nz(<CachedPlugin {!r}/{!r} (provides {!r})>z, c                 ó   — g | ]	}|j         ‘Œ
S r   )r   )Ú.0Úis     r   ú
<listcomp>z)CachedPlugin.__repr__.<locals>.<listcomp>2   s   € Ð9Ð9Ð9 a�q”zÐ9Ð9Ð9r   )Úformatr   r   Ú
moduleNameÚjoinr   ©r    s    r   Ú__repr__zCachedPlugin.__repr__.   sG   € Ø9×@Ò@ØŒIØŒKÔ"Ø�IŠIÐ9Ð9¨4¬=Ð9Ñ9Ô9Ñ:Ô:ñ
ô 
ð 	
r   c                 óJ   — t          | j        j        dz   | j        z   ¦  «        S )Nú.)r   r   r)   r   r+   s    r   ÚloadzCachedPlugin.load5   s!   € Ý˜œÔ.°Ñ4°t´yÑ@ÑAÔAÐAr   Nc                 óÒ   — | j         D ]^}|                     |¦  «        r|                      ¦   «         c S t          ||d ¦  «        �  ||                      ¦   «         |¦  «        c S Œ_|S r   )r   ÚisOrExtendsr/   r
   )r    Ú	interfaceÚregistryÚdefaultÚprovidedInterfaces        r   Ú__conform__zCachedPlugin.__conform__8   s|   € Ø!%¤ð 	7ð 	7ÐØ ×,Ò,¨YÑ7Ô7ð #Ø—y’y‘{”{Ð"Ð"Ð"Ý Ð!2°I¸tÑDÔDÐPØ �y §¢¡¤¨gÑ6Ô6Ð6Ð6Ð6ð Qàˆr   )NN)	r   r   r   r!   Ústrr,   r/   r6   ÚgetComponentr   r   r   r   r   &   se   € € € € € ð)ð )ð )ð
˜#ð 
ð 
ð 
ð 
ðBð Bð Bðð ð ð ð €L€L€Lr   r   c                   ó   — e Zd ZdZd„ ZdS )Ú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.
    c                 ó0   — || _         || _        g | _        d S r   )r)   r   r   )r    r)   r   s      r   r!   zCachedDropin.__init__V   s   € Ø$ˆŒØ&ˆÔØˆŒˆˆr   N)r   r   r   r   r!   r   r   r   r:   r:   D   s-   € € € € € ðð ð"ð ð ð ð r   r:   c                 óþ   — t          | j        | j        ¦  «        }| j                             ¦   «         D ]H\  }}t          |d ¦  «        }|�1t          |||j        t          t          |¦  «        ¦  «        ¦  «         ŒI|S r   )	r:   r   r   Ú__dict__Úitemsr   r   Úlistr   )Úproviderr   ÚkÚvÚplugins        r   Ú_generateCacheEntryrD   \   s|   € Ý˜(Ô+¨XÔ-=Ñ>Ô>€FØÔ!×'Ò'Ñ)Ô)ð Ið I‰ˆˆ1Ý˜˜DÑ!Ô!ˆØÐå˜  A¤I­tµJ¸vÑ4FÔ4FÑ/GÔ/GÑHÔHÐHøØ€Mr   c                 ó   — i }| D ]}|||<   Œ|S r   r   )ÚkeysÚvalueÚdrA   s       r   ÚfromkeysrI   j   s&   € ØˆØð 	ð 	ˆAØˆAˆa‰DˆDØˆr   c                 óà  — i }t          | j        ¦  «        }i }|                     ¦   «         D ]A}|j                             ¦   «         }||vrg ||<   ||         }|                     |¦  «         ŒB|                     ¦   «         D �]é\  }}|                     d¦  «        }	 |                     ¦   «         }	| 	                    d¦  «        5 }
t          j        |
¦  «        }ddd¦  «         n# 1 swxY w Y   n# t          $ r i }d}	Y nw xY wd}i }|D ]—}|j                             d¦  «        d         }d||<   ||vs|j                             ¦   «         |	k    rOd}	 |                     ¦   «         }t          |¦  «        }|||<   Œt# t          $ r t!          j        ¦   «          Y Œ“w xY wŒ˜t%          |                     ¦   «         ¦  «        D ]}||vr||= d}Œ|r�	 |                     t          j        |¦  «        ¦  «         nX# t,          $ r+}t!          j        d	|j        |j        ¬
¦  «         Y d}~n(d}~wt          $ r t!          j        dd¦  «         Y nw xY 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ÚrNr   Fr.   éÿÿÿÿTz@Unable to write to plugin cache %(path)s: error number %(errno)d)r(   ÚpathÚerrnoz)Unexpected error while writing cache file)r   r   ÚiterModulesÚfilePathÚparentr   r>   ÚchildÚgetModificationTimeÚopenÚpickler/   ÚBaseExceptionr   ÚsplitrD   r	   Úerrr?   rF   Ú
setContentÚdumpsÚOSErrorÚmsgrM   rN   Úupdate)ÚmoduleÚallCachesCombinedÚmodÚbucketsÚplugmodÚfppÚbucketÚpseudoPackagePathÚ
dropinPathÚ
lastCachedÚfÚdropinDotCacheÚ
needsWriteÚexistingKeysÚpluginModuleÚ	pluginKeyr@   ÚentryÚes                      r   ÚgetCacherp   q   sL  € ð ÐÝ
�F”OÑ
$Ô
$€Cà€Gð —?’?Ñ$Ô$ð ð ˆØÔ×%Ò%Ñ'Ô'ˆØ�gÐÐØˆG�C‰LØ˜”ˆØ�Š�gÑÔÐÐØ%,§]¢]¡_¤_ð .1ñ .1Ñ!Ð˜6Ø&×,Ò,¨^Ñ<Ô<ˆ
ð	Ø#×7Ò7Ñ9Ô9ˆJØ—’ Ñ%Ô%ð 0¨Ý!'¤¨Q¡¤�ð0ð 0ð 0ñ 0ô 0ð 0ð 0ð 0ð 0ð 0ð 0øøøð 0ð 0ð 0ð 0øøåð 	ð 	ð 	ØˆNØˆJˆJˆJð	øøøð ˆ
ØˆØ"ð 	6ð 	6ˆLØ$Ô)×/Ò/°Ñ4Ô4°RÔ8ˆIØ&*ˆL˜Ñ#Ø Ð/Ð/ØÔ%×9Ò9Ñ;Ô;¸zÒIÐIà!�
ð6Ø+×0Ò0Ñ2Ô2�Hõ
 0°Ñ9Ô9�EØ05�N 9Ñ-Ð-øõ %ð ð ð å”G‘I”I�I�I�Iðøøøð Jõ ˜n×1Ò1Ñ3Ô3Ñ4Ô4ð 	"ð 	"ˆIØ Ð,Ð,Ø" 9Ð-Ø!�
øØð 	KðKØ×%Ò%¥f¤l°>Ñ&BÔ&BÑCÔCÐCÐCøÝð ð ð Ý”ð+ð $œØœ'ðñ ô ð ð ð ð ð ð øøøøõ !ð Kð Kð KÝ”˜ÐIÑJÔJÐJÐJÐJðKøøøà× Ò  Ñ0Ô0Ð0Ñ0ØÐsf   Â)C5ÃC)ÃC5Ã)C-	Ã-C5Ã0C-	Ã1C5Ã5DÄDÅFÆF#Æ"F#Ç'G?Ç?
IÈ	!H/È/"IÉIr"   c                  ó   — dd l m}  | S )Nr   )Útwisted.pluginsr   )Úpackages    r   Ú_pluginsPackagert   ½   s   € Ø%Ð%Ð%Ð%Ð%Ð%à€Nr   Ú_TInterface)Úboundr2   rs   c              #   óü   K  — |€t          ¦   «         }t          |¦  «        }|                     ¦   «         D ]E\  }}|j        D ]8}	  | |d¦  «        }|�|V — Œ# t          $ r t          j        ¦   «          Y Œ5w xY wŒFdS )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.
    N)rt   rp   r>   r   rV   r	   rX   )r2   rs   Ú
allDropinsÚkeyr   rC   Úadapteds          r   Ú
getPluginsr{   Æ   s¸   è è € ð €Ý!Ñ#Ô#ˆÝ˜'Ñ"Ô"€JØ!×'Ò'Ñ)Ô)ð "ð "‰ˆˆVØ”nð 	"ð 	"ˆFð"Ø#˜) F¨DÑ1Ô1�ð Ð&Ø!�M�M�Møøõ	 !ð ð ð Ý”‘	”	�	�	�	ðøøøð	"ð"ð "s   ÁAÁA8Á7A8c                 ó^   ‡— |                       d¦  «        Šˆfd„t          j        D ¦   «         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.   c           	      óè   •— g | ]n}t           j                             t          j        j        |g‰d gz   ¢R Ž ¦  «        °:t           j                             t          j        j        |g‰¢R Ž ¦  «        ‘ŒoS )z__init__.py)ÚosrM   Úexistsr*   Úabspath)r%   Úxrs   s     €r   r'   z&pluginPackagePaths.<locals>.<listcomp>ý   sz   ø€ ð ð ð àÝŒw�~Š~�bœgœl¨1ÐI¨w¸-¸Ñ/HÐIÐIÐIÑJÔJðÝ
Œ�Š�œœ QÐ1¨Ð1Ð1Ð1Ñ2Ô2ðð ð r   )rW   ÚsysrM   )r   rs   s    @r   ÚpluginPackagePathsrƒ   æ   sA   ø€ ð �jŠj˜‰oŒo€Gðð ð ð å”ðñ ô ð r   r{   rƒ   r   )$r   r~   rU   r‚   ÚtypesÚtypingr   r   r   r   Úzope.interfacer   r   Útwisted.pythonr	   Útwisted.python.componentsr
   Útwisted.python.modulesr   Útwisted.python.reflectr   r   r   r:   rD   ÚdictrI   ÚAttributeErrorrp   Ú
ModuleTypert   ru   r{   Ú
getPlugInsrƒ   Ú__all__r   r   r   ú<module>r�      sA  ððð ð 
€	€	€	Ø €€€Ø 
€
€
€
Ø €€€Ø 4Ð 4Ð 4Ð 4Ð 4Ð 4Ð 4Ð 4Ð 4Ð 4Ð 4Ð 4à 0Ð 0Ð 0Ð 0Ð 0Ð 0Ð 0Ð 0à Ð Ð Ð Ð Ð Ø 7Ð 7Ð 7Ð 7Ð 7Ð 7Ø ,Ð ,Ð ,Ð ,Ð ,Ð ,Ø +Ð +Ð +Ð +Ð +Ð +ðð ð ð ð ˆiñ ô ð ðð ð ð ð ñ ô ð ð<ð ð ð ð ñ ô ð ð0ð ð ðØŒ}€H€HøØð ð ð ðð ð ð ð ð ðøøøðIð Ið IðX˜Ô)ð ð ð ð ð ˆg�m¨9Ð5Ñ5Ô5€ð IMð"ð "Ø�KÔ ð"Ø+3°EÔ4DÔ+Eð"àˆkÔð"ð "ð "ð "ð: €
ðð ð ð< Ð-Ð
.€€€s   Á+A3 Á3	A?Á>A?