gh!dZddlZddlZddlZddlZddlmZmZmZm Z ddl m Z m Z ddl mZddlmZddlmZddlmZGd d e ZGd d ZGd dZdZ ejZn#e$rddZYnwxYwdZdejfdZe de Z ddeedeejdeefdZ e Z!dZ"ddgZ#dS)zL Plugin system for Twisted. @author: Jp Calderone @author: Glyph Lefkowitz N)IterableOptionalTypeTypeVar) Interface providedBy)log)getAdapterFactory) getModule)namedAnyceZdZdZdS)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__^/home/jenkins/workspace/simtester-sanitize/venv/lib/python3.11/site-packages/twisted/plugin.pyrrsrrc2eZdZdZdefdZdZddZeZdS) CachedPluginc|||_||_||_||_|jj|dSN)dropinname descriptionprovidedpluginsappend)selfrrrrs r__init__zCachedPlugin.__init__'s>  &   ""4(((((rreturncd|j|jjdd|jDS)Nz(z, cg|] }|j Sr)r).0is r z)CachedPlugin.__repr__..2s999aqz999r)formatrr moduleNamejoinrr s r__repr__zCachedPlugin.__repr__.sG9@@ I K " II994=999 : :   rcJt|jjdz|jzS)N.)r rr)rr+s rloadzCachedPlugin.load5s! .4ty@AAArNc|jD]^}||r|cSt||d |||cS_|Sr)r isOrExtendsr/r )r interfaceregistrydefaultprovidedInterfaces r __conform__zCachedPlugin.__conform__8s|!% 7 7  ,,Y77 #yy{{""" !2ItDDP yg66666Qr)NN) rrrr!strr,r/r6 getComponentrrrrr&se))) #    BBBLLLrrceZdZdZdZdS) 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. c0||_||_g|_dSr)r)rr)r r)rs rr!zCachedDropin.__init__Vs$& rN)rrrrr!rrrr:r:Ds-"rr:c t|j|j}|jD]H\}}t |d}|1t |||jtt|I|Sr) r:rr__dict__itemsrrlistr)providerrkvplugins r_generateCacheEntryrD\s| (+X-= > >F!''))II1D!!   AItJv4F4F/G/G H H H Mrci}|D]}|||<|Srr)keysvaluedrAs rfromkeysrIjs&   AAaDDrci}t|j}i}|D]A}|j}||vrg||<||}||B|D]\}}|d} |} | d5} tj | } dddn #1swxYwYn#t$ri} d} YnwxYwd} i} |D]}|j dd}d| |<|| vs|j| krOd} | }t|}|| |<t#t$rt!jYwxYwt%| D] }|| vr| |=d} | r |tj| nX#t,$r+}t!jd |j|j Yd}~n(d}~wt$rt!jdd YnwxYw|| |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.cacherNrFr.Tz@Unable to write to plugin cache %(path)s: error number %(errno)d)r(patherrnoz)Unexpected error while writing cache file)r r iterModulesfilePathparentrr>childgetModificationTimeopenpickler/ BaseExceptionrsplitrDr errr?rF setContentdumpsOSErrormsgrMrNupdate)moduleallCachesCombinedmodbucketsplugmodfppbucketpseudoPackagePath dropinPath lastCachedfdropinDotCache needsWrite existingKeys pluginModule pluginKeyr@entryes rgetCacherpqsL FO $ $CG??$$%%'' g  GCL g%,]]__.1.1!6&,,^<<  #7799J%% 0!'Q 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0   NJJJ   " 6 6L$)//44R8I&*L #//%99;;zII! 6+0022H 099E05N9-- %GIIIII Jn113344 " "I ,,"9-!  K K%%fl>&B&BCCCC   +$' ! K K KIJJJJJ K  0000 sf)C5C) C5)C- -C50C- 1C55DDFF#"F#'G?? I !H//"IIr"cddlm}|S)Nr)twisted.pluginsr)packages r_pluginsPackagerts%%%%%% Nr _TInterface)boundr2rsc#K|t}t|}|D]E\}}|jD]8} ||d}||V#t$rt jY5wxYwFdS)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)rtrpr>rrVr rX)r2rs allDropinskeyrrCadapteds r getPluginsr{s!##'""J!''))"" Vn " "F "#)FD11&!MMM !      """s AA87A8c^|dfdtjDS)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}tjtjj|gdgzR:tjtjj|gRoS)z __init__.py)osrMexistsr*abspath)r%xrss rr'z&pluginPackagePaths..sz    w~~bgl1Iw-/HIIIJJ   Q111122   r)rWsysrM)rrss @rpluginPackagePathsrsAjjooG       rr{rr)$rr~rUrtypestypingrrrrzope.interfacerrtwisted.pythonr twisted.python.componentsr twisted.python.modulesr twisted.python.reflectr rrr:rDdictrIAttributeErrorrp ModuleTypertrur{ getPlugInsr__all__rrrrsA  44444444444400000000777777,,,,,,++++++i<0}HHIIIX) gm9555 IM""K "+3E4D+E" k"""": < - .s+A33 A?>A?