Class EDFactoryPlugin
source code
object --+
|
EDObject.EDObject --+
|
EDLogging.EDLogging --+
|
EDFactoryPlugin
- Known Subclasses:
-
This class provides a factory for loading plugins and/or modules. By
default all plugins/modules located in $EDNA_HOME can be loaded with this
class. A plugin or module located elsewhere can be loaded provided one of
its parent directories is added with the method
"addPluginRootDirectory".
All plugins or modules with file name ending with \*.py are located.
If the file name starts with "EDPlugin" or "XSData" a
warning is issued if multiple modules/plugins with the same name are
located.
Both the loadPlugin and loadModule methods will automatically add the
module location to the application python path, if it not already exists
on the path.
The EDFactoryPlugin also adds the path to a "src" directory
if the following scheme for locating the plugins is followed:
EDNA project, e.g. mxv1, mxExecPlugins etc:
|
|-conf
|-datamodel
|-src
| |-XSData[project name].py
|-tests
| |-data
| |-testsuite
| | |-EDTestSuite[for the project]
|
|-plugins
| |-EDPlugin[name of plugin]-v1.0
| | |-plugins
| | | |-EDPlugin[name of plugin]v10.py
| | | |-EDPlugin[another name of plugin]v10.py
| | |-tests
| | | |-data
| | | |-testsuite
| | | | |-EDTestCase[for a plugin]
The "src" directory above is used for storing the data
bindings for a project common data model, e.g. XSDataMXv1.py, or in
general for code used by all the plugins. The path to the "src"
directory is added using a relative path from the plugin location:
../../../src The path to the src directory is only added if the src
directory exists.
In order to improve speed, a cache of the modules and their location
is saved to disk the first time a module/plugin is located. The default
location of this cache file is in $EDNA_HOME, and the default name is
".XSDataDictionaryModule.xml".
If a cache files is present, and if a module/plugin cannot be loaded,
the cache is updated by searching all plugin root directories again.
If a directory contains the file ".ednaignore" in this
directory and sub-directories are ignored.
|
|
|
|
|
|
|
|
|
|
|
checkDirectoriesForIgnoreFile(self,
_strDirectory) |
source code
|
|
|
isPlugin(self,
_strFileName)
This method returns a True if the file name provided is considered to
be an EDNA plugin or module, i.e. |
source code
|
|
|
__addPluginLocation(self,
_strPluginRootDirectory,
_strDirectoryVisit,
_listDirectory)
This method is called by the python walk command in the
addPluginRootDirectory method. |
source code
|
|
|
addPluginRootDirectory(self,
_strPluginRootDirectory)
This method can be called by an application if plugins or modules are
supposed to be loaded outside the EDNA_HOME directory. |
source code
|
|
|
__searchRootDirectories(self)
This method loops through all the root directories and recursively
searchs for modules/plugins. |
source code
|
|
|
loadPlugin(self,
_strPluginName)
This method loads a plugin if it's present in the
self.__dictModuleLocation. |
source code
|
|
|
|
|
appendPath(self,
_strModuleLocation)
This method appends the plugin "src" directory to the
system path, if it's not already present. |
source code
|
|
|
|
|
getProjectName(self,
_strModuleName)
This method returns the name of the project by finding the project
root directory and returning the basename. |
source code
|
|
Inherited from EDLogging.EDLogging :
ASSERT ,
DEBUG ,
ERROR ,
WARNING ,
error ,
isVerboseDebug ,
log ,
screen ,
setAllLogLevels ,
setLogFileName ,
setLogFileOff ,
setLogLevel ,
setTestOff ,
setTestOn ,
setVerboseDebugOff ,
setVerboseDebugOn ,
setVerboseOff ,
setVerboseOn ,
unitTest ,
warning ,
writeErrorTrace
Inherited from EDObject.EDObject :
getClassName ,
getId ,
getRunTime ,
getSemaphoreValue ,
getTimeEnd ,
getTimeInit ,
locked ,
setTimeEnd ,
setTimeInit ,
synchronizeOff ,
synchronizeOn
Inherited from object :
__delattr__ ,
__format__ ,
__getattribute__ ,
__hash__ ,
__new__ ,
__reduce__ ,
__reduce_ex__ ,
__repr__ ,
__setattr__ ,
__sizeof__ ,
__str__ ,
__subclasshook__
|
|
preImport(cls,
_strModuleName,
_strPath=None,
_strForceVersion=None,
_strMethodVersion=None)
Static method that import locally with a lock and keeps track of
already imported module. |
source code
|
|
|
unImport(cls,
_strModuleName)
Static method that remove a module from the imported modules. |
source code
|
|
|
|
|
IGNORE_FILE = ' .ednaignore '
|
|
_dictLoadedModules = {}
|
|
__dictConfFiles = { None: None}
|
|
__dictProjectRootDir = { None: None}
|
|
__semaphoreStatic = Semaphore()
|
|
__edFactoryPlugin = None
hash(x)
|
|
_EDObject__iId_class = 3
|
Inherited from object :
__class__
|
Constructor of the main pure virtual class.
This constructor implements:
- the creation of the semaphore
- definition of timer object (uninitialized as potentially not used)
- Overrides:
object.__init__
- (inherited documentation)
|
This private method initialises the dictionary with all plugins. If
the path to the dictionary cache file exists the plugins are loaded,
otherwise the plugin root directories are searched and the dictionary is
written to the cache file.
|
This method saves the module dictionary to disk in form of XML. This
method should be private but is kept public in order to be unit
tested.
- Parameters:
_strPath (python string) - Path to the module dictionary XML file
|
loadModuleDictionaryFromDisk(self,
_strPath)
| source code
|
Loads the cache from disk.
- Parameters:
_strPath (python string) - Path to the module dictionary XML file
|
This method returns the location of a module, e.g. XSDataCommon.
- Parameters:
_strModuleName (python string) - Name of the module
- Returns:
- Path to the module location
|
This method returns a True if the file name provided is considered to
be an EDNA plugin or module, i.e. it starts with either
"EDPlugin" or "XSData" and it ends with
".py", otherwise the method returns False.
- Parameters:
_strFileName (python string) - Name of the file
- Returns:
- True or False
|
__addPluginLocation(self,
_strPluginRootDirectory,
_strDirectoryVisit,
_listDirectory)
| source code
|
This method is called by the python walk command in the
addPluginRootDirectory method.
It checks all the file names in the _listDirectory list if they
corresponds to plugins or modules using the method "isPlugin".
If the file name corresponds to a plugin or module, the location of the
plugin or module is added to the self.__dictModuleLocation.
- Parameters:
_strPluginRootDirectory (python string) - Name of the root directory
_strDirectoryVisit (python string) - Name of the directory currently visited
_listDirectory (python list) - List of directory entries
|
addPluginRootDirectory(self,
_strPluginRootDirectory)
| source code
|
This method can be called by an application if plugins or modules are
supposed to be loaded outside the EDNA_HOME directory.
- Parameters:
_strPluginRootDirectory (python string) - Name of the root directory
|
This method loads a plugin if it's present in the
self.__dictModuleLocation.
- Parameters:
_strPluginName (python string) - Name of the plugin to be loaded
|
This method loads a module, i.e. it adds the module to the python
path.
- Parameters:
_strModuleName (python string) - Name of the module to be loaded
|
This method appends the plugin "src" directory to the system
path, if it's not already present.
- Parameters:
_strModuleLocation (python string) - Path to the module location
|
getProjectRootDirectory(self,
_strModuleName)
| source code
|
This method returns the project root directory of a given module name.
A directory is considered to be a project root if it contains the
following directories: "conf", "src" and
"plugins"
- Parameters:
_strModuleName (python string) - Name of the module
- Returns:
- The project root directory
|
This method returns the name of the project by finding the project
root directory and returning the basename.
- Parameters:
_strModuleName (python string) - Name of the module
- Returns:
- The project name
|
preImport(cls,
_strModuleName,
_strPath=None,
_strForceVersion=None,
_strMethodVersion=None)
Class Method
| source code
|
Static method that import locally with a lock and keeps track of
already imported module.
- Parameters:
_strModuleName - Name of the module to import
_strPath - Path to the module to import
_strForceVersion - version string to enforce to. Should be compatible with the
method given !!!
_strMethodVersion - property or method to get the version number (should return a
string)
- Returns:
- reference to the module loaded
|
Static method that remove a module from the imported modules.
- Parameters:
_strModuleName - Name of the module to un-import
|
This is a class method to provide compatibility with
EDFactoryPluginStatic
- Returns:
- the static version of the factory plugin.
|