Your IP : 172.28.240.42


Current Path : /usr/lib/python2.7/dist-packages/twisted/
Upload File :
Current File : //usr/lib/python2.7/dist-packages/twisted/plugin.pyc

ó
Ð#…Mc@s2dZddlZddlZddlmZmZd„ZeƒZddlm	Z	ddl
mZddlm
Z
ddlmZd	efd
„ƒYZdefd„ƒYZd
efd„ƒYZd„Zy
ejZWnek
rýdd„ZnXd„Zdd„ZeZd„ZddgZdS(sL
Plugin system for Twisted.

@author: Jp Calderone
@author: Glyph Lefkowitz
iÿÿÿÿN(t	Interfacet
providedBycCs9yddl}|SWntk
r4ddl}|SXdS(s5
    Determine which 'pickle' API module to use.
    iÿÿÿÿN(tcPickletImportErrortpickle(RR((s2/usr/lib/python2.7/dist-packages/twisted/plugin.pyt_determinePickleModules
(tgetAdapterFactory(tnamedAny(tlog(t	getModuletIPlugincBseZdZRS(sý
    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.
    (t__name__t
__module__t__doc__(((s2/usr/lib/python2.7/dist-packages/twisted/plugin.pyR
&stCachedPlugincBs8eZd„Zd„Zd„Zddd„ZeZRS(cCs;||_||_||_||_|jjj|ƒdS(N(tdropintnametdescriptiontprovidedtpluginstappend(tselfRRRR((s2/usr/lib/python2.7/dist-packages/twisted/plugin.pyt__init__2s
				cCs<d|j|jjdjg|jD]}|j^q"ƒfS(Ns"<CachedPlugin %r/%r (provides %r)>s, (RRt
moduleNametjoinRR(Rti((s2/usr/lib/python2.7/dist-packages/twisted/plugin.pyt__repr__9scCst|jjd|jƒS(Nt.(RRRR(R((s2/usr/lib/python2.7/dist-packages/twisted/plugin.pytload>scCs\xU|jD]J}|j|ƒr)|jƒSt||dƒdk	r
||jƒ|ƒSq
W|S(N(RtisOrExtendsRRtNone(Rt	interfacetregistrytdefaulttprovidedInterface((s2/usr/lib/python2.7/dist-packages/twisted/plugin.pyt__conform__As
N(RRRRRRR#tgetComponent(((s2/usr/lib/python2.7/dist-packages/twisted/plugin.pyR1s
				tCachedDropincBseZdZd„ZRS(s
    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 C{NoneType}
    @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(RRR(RRR((s2/usr/lib/python2.7/dist-packages/twisted/plugin.pyR_s		(RRR
R(((s2/usr/lib/python2.7/dist-packages/twisted/plugin.pyR%NscCsyt|j|jƒ}x]|jjƒD]L\}}t|dƒ}|dk	r%t|||jtt	|ƒƒƒq%q%W|S(N(
R%RR
t__dict__t	iteritemsR
RRtlistR(tproviderRtktvtplugin((s2/usr/lib/python2.7/dist-packages/twisted/plugin.pyt_generateCacheEntryfs	)cCs%i}x|D]}|||<q
W|S(N((tkeystvaluetdR*((s2/usr/lib/python2.7/dist-packages/twisted/plugin.pytfromkeysss
cCs1i}t|jƒ}i}xS|jƒD]E}|jjƒ}||krVg||<n||}|j|ƒq(Wx¹|jƒD]«\}}|jdƒ}y(|jƒ}	t	j
|jdƒƒ}
Wni}
d}	nXt}i}x’|D]Š}
|
j
jdƒd}t||<||
ks1|
jjƒ|	krêt}y|
j
ƒ}WntjƒqtXt|ƒ}||
|<qêqêWx0|
jƒD]"}||kr…|
|=t}q…q…W|ry|jt	j|
ƒƒWqtk
r}tjddd|jd	|jƒqtjdd
ƒqXn|j|
ƒq~W|S(s;
    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.
    sdropin.cachetriRiÿÿÿÿtformats@Unable to write to plugin cache %(path)s: error number %(errno)dtpathterrnos)Unexpected error while writing cache fileN(R	RtiterModulestfilePathtparentRR'tchildtgetModificationTimeRRtopentFalseRtsplittTrueRterrR-R.t
setContenttdumpstOSErrortmsgR4R5Rtupdate(tmoduletallCachesCombinedtmodtbucketstplugmodtfpptbuckettpseudoPackagePatht
dropinPatht
lastCachedtdropinDotCachet
needsWritetexistingKeystpluginModulet	pluginKeyR)tentryte((s2/usr/lib/python2.7/dist-packages/twisted/plugin.pytgetCache{s\






	ccs”|dkrddlj}nt|ƒ}xc|jƒD]U}xL|jD]A}y||dƒ}WntjƒqGX|dk	rG|VqGqGWq7WdS(sc
    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.
    iÿÿÿÿN(Rttwisted.pluginsRRVt
itervaluesRR?(Rtpackaget
allDropinsRR,tadapted((s2/usr/lib/python2.7/dist-packages/twisted/plugin.pyt
getPluginsÃscCsl|jdƒ}gtjD]O}tjjtjj||dgŒƒstjjtjj||Œƒ^qS(s¨
    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.
    Rs__init__.py(R=tsysR4tostexistsRtabspath(RRYtx((s2/usr/lib/python2.7/dist-packages/twisted/plugin.pytpluginPackagePathsás

R\Rb(R
R^R]tzope.interfaceRRRRttwisted.python.componentsRttwisted.python.reflectRttwisted.pythonRttwisted.python.modulesR	R
tobjectRR%R-tdictR1tAttributeErrorRRVR\t
getPlugInsRbt__all__(((s2/usr/lib/python2.7/dist-packages/twisted/plugin.pyt<module>s,			


	H