ExtensionManager
index
/home/laszlo/Dev/joko-gtk-builder/Jokosher/ExtensionManager.py

#       THIS FILE IS PART OF THE JOKOSHER PROJECT AND LICENSED UNDER THE GPL. SEE
#       THE 'COPYING' FILE FOR DETAILS
#
#       ExtensionManager.py
#       
#       This module defines the ExtensionManager class which is 
#       responsible for controlling extensions to Jokosher
#
#-------------------------------------------------------------------------------

 
Modules
       
Extension
Globals
gtk
imp
os
pkg_resources
shutil

 
Classes
       
ExtensionManager

 
class ExtensionManager
    The ExtensionManager class handles the installation and running of
Extensions. It also controls their disabling and removal.
 
  Methods defined here:
ExtensionPreferences(self, filename)
Loads the preferences() function of an Extension.
 
Parameters:
        filename -- the name of the file containing the Extension.
        
Returns:
        True -- the Extension's preferences were successfully loaded.
        False -- an error ocurred while trying to load the Extension's
                        preferences.
GetExtensions(self)
Obtain a generator for iterating the list of loadedExtensions.
 
Returns:
        a generator with the list of loadedExtensions.
LoadAllExtensions(self)
Load all the Extensions found in EXTENSION_PATHS and import every .py
and .egg file found.
LoadExtensionFromFile(self, filename, directory, local=False)
Tries to load an Extension fron a given file.
 
Parameters:
        filename -- the name of the file containing the Extension.
        directory -- full path to the directory containing the file.
        local --        True = the extension is to be copied to the
                                                local extension directory after checking
                                False = don't copy the Extension.
 
Returns:
        True -- the Extension was successfully loaded.
        False -- an error ocurred while trying to load the Extension,
                        or the Extension has been disabled via the ExtensionManagerDialog.
RemoveExtension(self, filename)
Removes the given Extension.
 
Considerations:
        This function "unloads" the Extension. It executes the shutdown()
        function of the Extension and then removes it from loadedExtensions.
        
Parameters:
        filename -- the name of the file containing the Extension.
        
Returns:
        True -- the Extension was successfully removed.
        False -- an error ocurred while trying to remove the Extension.
StartExtension(self, filename)
Starts the given Extension.
 
Considerations:
        This method executes the startup() function of the Extension
        This is mainly for enabling an Extension on the fly without
        loading another instance.
        
Parameters:
        filename -- the name of the file containing the Extension.
        
Returns:
        True -- the Extension was successfully started.
        False -- an error ocurred while trying to start the Extension.
StopExtension(self, filename)
Stops the given Extension.
 
Considerations:
        This method executes the shutdown() function of the Extension.
        This is mainly for disabling Extensions on the fly, but is also
        used for removing them.
        
Parameters:
        filename -- the name of the file containing the Extension.
        
Returns:
        True -- the Extension was successfully stopped.
        False -- an error ocurred while trying to stop the Extension.
__init__(self, mainapp)
Creates a new Instance of ExtensionManager.
 
Parameters:
        parent -- the parent MainApp Jokosher window.
register(self, extension, filename, directory, local)
Called from Extension.LoadAllExtensions afer the Extensions
module has been imported (and the class instantiated in the case
of extensions that are eggs). 
 
Parameters:     
        extension -- a reference to the Extension. Either a module 
                                or in the case of an Extension imported from an
                                egg, an instance object.
        filename -- the name of the file containing the Extension.
        directory -- full path to the directory containing the file.
        local --        True = the extension is to be copied to the
                                                local extension directory after checking
                                False = don't copy the Extension.
 
Returns:
        True -- the Extension was successfully registered.
        False -- an error ocurred while trying to register the Extension,
                        or the Extension has been disabled via the ExtensionManagerDialog.