Your IP : 172.28.240.42


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


Oc@sxddlZddlZddlZddlZddlZejZdefdYZdefdYZ	dS(iNtPlugincBsSeZdZdZdZeeeZdZdZdZ	dZ
RS(sBase class for plugins.
    
    These plugins only do one thing: identify cruft. See the 'get_cruft'
    method for details.
    
    cCst|dr|jSgSdS(Nt
_condition(thasattrR(tself((s:/usr/lib/python2.7/dist-packages/computerjanitor/plugin.pyt
get_condition"scCs
||_dS(N(R(Rt	condition((s:/usr/lib/python2.7/dist-packages/computerjanitor/plugin.pyt
set_condition(scCs
||_dS(sSet the Application instance this plugin belongs to.
        
        This is used by the plugin manager when creating the plugin
        instance. In a perfect world, this would be done via the
        __init__ method, but since I took a wrong left turn, I ended
        up in an imperfect world, and therefore giving the Application
        instance to __init__ would mandate that all sub-classes would
        have to deal with that explicitly. That is a lot of unnecessary
        make-work, which we should avoid. Therefore, we do it via this
        method.
        
        The class may access the Application instance via the
        'app' attribute.
        
        N(tapp(RR((s:/usr/lib/python2.7/dist-packages/computerjanitor/plugin.pytset_application-scCs/x|jD]}|jq
W|jdS(sFFind cruft and clean it up.

        This is a helper method.
        N(t	get_crufttcleanuptpost_cleanup(Rtcruft((s:/usr/lib/python2.7/dist-packages/computerjanitor/plugin.pytdo_cleanup_cruft@scCstj|jdS(sFind some cruft in the system.
        
        This method MUST return an iterator (see 'yield' statement).
        This interface design allows cruft to be collected piecemeal,
        which makes it easier to show progress in the user interface.
        
        The base class default implementation of this raises an
        exception. Subclasses MUST override this method.

        N(tcomputerjanitortUnimplementedMethodR	(R((s:/usr/lib/python2.7/dist-packages/computerjanitor/plugin.pyR	JscCsdS(sDoes plugin wide cleanup after the individual cleanup
           was performed.
           
           This is useful for stuff that needs to be proccessed
           in batches (e.g. for performance reasons) like package
           removal.
        N((R((s:/usr/lib/python2.7/dist-packages/computerjanitor/plugin.pyRXs(t__name__t
__module__t__doc__RRtpropertyRRR
R	R(((s:/usr/lib/python2.7/dist-packages/computerjanitor/plugin.pyRs				
	t
PluginManagercBsAeZdZdZdZdZdZgddZRS(sClass to find and load plugins.
    
    Plugins are stored in files named '*_plugin.py' in the list of
    directories given to the initializer.
    
    cCs||_||_d|_dS(N(t_appt_plugin_dirstNonet_plugins(RRtplugin_dirs((s:/usr/lib/python2.7/dist-packages/computerjanitor/plugin.pyt__init__ls		cCsg}x|jD]}tjj|s.qngtj|D]}|jdr>|^q>}tjd|dj|f|g|D]}tjj||^q7}qW|S(s4Return all filenames in which plugins may be stored.s
_plugin.pysPlugin modules in %s: %st (	Rtostpathtexiststlistdirtendswithtloggingtdebugtjoin(Rtnamestdirnametxt	basenames((s:/usr/lib/python2.7/dist-packages/computerjanitor/plugin.pytget_plugin_filesqs	0cCsg}xKtj|D]:\}}tj|rt|tr|j|qqWtjd|djd|Dfg|D]}|^qS(s-Find and instantiate all plugins in a module.sPlugins in %s: %sRcss|]}t|VqdS(N(tstr(t.0R&((s:/usr/lib/python2.7/dist-packages/computerjanitor/plugin.pys	<genexpr>s(	tinspectt
getmemberstisclasst
issubclassRtappendR!R"R#(Rtmoduletpluginstdummytmembertplugin((s:/usr/lib/python2.7/dist-packages/computerjanitor/plugin.pyt
_find_pluginss	!cCstjd|tjjtjj|\}}t|d}y(tj|||ddtj	f}Wn+t
k
r}tjd||fdSX|j
|S(sLoad a module from a filename.sLoading module %strs.pysFailed to load plugin '%s' (%s)N(R!R"RRtsplitexttbasenametfiletimptload_modulet	PY_SOURCEt	ExceptiontwarningRtclose(Rtfilenametmodule_nameR2tfR0te((s:/usr/lib/python2.7/dist-packages/computerjanitor/plugin.pyt_load_modules$	
c	Cs|jdkrg|_|j}xtt|D]v}|r`||||t|n|j||}x7|j|D]&}|j|j|jj	|qWq7Wng|jD]6}|j
|ks||j
ks|dkr|^q}tjd||f|S(sReturn all plugins that have been found.
        
        If callback is specified, it is called after each plugin has
        been found, with the following arguments: filename, index of
        filename in list of files to be examined (starting with 0), and
        total number of files to be examined. The purpose of this is to
        allow the callback to inform the user in case things take a long
        time.
        
        t*s#plugins for condition '%s' are '%s'N(
RRR(trangetlenRDR5RRR/RR!R"(	RRtcallbackt	filenamestiR0R4tpR1((s:/usr/lib/python2.7/dist-packages/computerjanitor/plugin.pytget_pluginss"		N(	RRRRR(R5RDRRL(((s:/usr/lib/python2.7/dist-packages/computerjanitor/plugin.pyRcs			
	(
R:R+R!RRt
setup_gettextt_tobjectRR(((s:/usr/lib/python2.7/dist-packages/computerjanitor/plugin.pyt<module>sJ