4.2. manager.componentsManager

manager.py

Platform:
Windows, Linux, Mac Os X.
Description:
Defines the Manager class and others helper objects.

Others:

4.2.1. Module Attributes

manager.componentsManager.LOGGER

4.2.2. Classes

class manager.componentsManager.Components(**kwargs)[source]

Bases: foundations.dataStructures.Structure

Defines a storage object for Manager class Components.

Initializes the class.

Parameters:**kwargs (dict) – Arguments.
class manager.componentsManager.Profile(name=None, file=None)[source]

Bases: object

Stores Manager class Components informations and objects.

Initializes the class.

Parameters:
  • name (unicode) – Name of the Component.
  • file (unicode) – File of the Component.
name[source]

Property for self.__name attribute.

Returns:self.__name.
Return type:unicode
file[source]

Property for self.__file attribute.

Returns:self.__file.
Return type:unicode
directory[source]

Property for self.__directory attribute.

Returns:self.__directory.
Return type:unicode
attribute[source]

Property for self.__attribute attribute.

Returns:self.__attribute.
Return type:unicode
require[source]

Property for self.__require attribute.

Returns:self.__require.
Return type:tuple or list
module[source]

Property for self.__module attribute.

Returns:self.__module.
Return type:ModuleType
interface[source]

Property for self.__interface attribute.

Returns:self.__interface.
Return type:object
category[source]

Property for self.__category attribute.

Returns:self.__category.
Return type:unicode
title[source]

Property for self.__title attribute.

Returns:self.__title.
Return type:unicode
package[source]

Property for self.__package attribute.

Returns:self.__package.
Return type:unicode
version[source]

Property for self.__version attribute.

Returns:self.__version.
Return type:unicode
author[source]

Property for self.__author attribute.

Returns:self.__author.
Return type:unicode
email[source]

Property for self.__email attribute.

Returns:self.__email.
Return type:unicode
url[source]

Property for self.__url attribute.

Returns:self.__url.
Return type:unicode
description[source]

Property for self.__description attribute.

Returns:self.__description.
Return type:unicode
initializeProfile()[source]

Initializes the Component Profile.

Returns:Method success.
Return type:bool
class manager.componentsManager.Manager(paths=None, extension=u'rc', categories={u'Default': <class 'manager.component.Component'>, u'QWidget': <class 'manager.qwidgetComponent.QWidgetComponent'>, u'QObject': <class 'manager.qobjectComponent.QObjectComponent'>})[source]

Bases: object

Defines methods to manage Components, allowing Components registration / unregistration, instantiation and reloading.
The Components can be registered in mass by providing paths that are recursively walk for candidates or simply by calling the registration method on a given Component file.
When a Component is registered, a Profile ( Stored using the Profile class ) is built and associated to it, this Profile object contains the Component Interface and various description attributes.

Initializes the class.

Usage:

>>> manager = Manager(("./manager/tests/testsManager/resources/components/core",))
>>> manager.registerComponents()
True
>>> manager.listComponents()
[u'core.testsComponentA', u'core.testsComponentB']
>>> manager.instantiateComponents()
True
>>> manager.getInterface("core.testsComponentA")
<testsComponentA.TestsComponentA object at 0x11dd990>
Parameters:
  • paths (tuple or list) – Paths to walk.
  • extension (unicode) – Components file extension.
  • categories (dict) – Components categories.
paths[source]

Property for self.__paths attribute.

Returns:self.__paths.
Return type:tuple or list
extension[source]

Property for self.__extension attribute.

Returns:self.__extension.
Return type:unicode
categories[source]

Property for self.__categories attribute.

Returns:self.__categories.
Return type:dict
components[source]

Property for self.__components attribute.

Returns:self.__components.
Return type:dict
registerComponent(path)[source]

Registers a Component using given path.

Usage:

>>> manager = Manager()
>>> manager.registerComponent("testsComponentA.rc")
True
>>> manager.components
{u'core.testsComponentA': <manager.componentsManager.Profile object at 0x11c9eb0>}
Parameters:path (unicode) – Component path.
Returns:Method success.
Return type:bool
unregisterComponent(component)[source]

Unregisters given Component.

Warning

The Manager class is not responsible of any deactivation / cleanup actions and will not trigger anything while unregistering a Component.

Usage:

>>> manager = Manager()
>>> manager.registerComponent("testsComponentA.rc")
True
>>> manager.unregisterComponent("core.testsComponentA")
True
>>> manager.components
{}
Parameters:component (unicode) – Component to remove.
Returns:Method success.
Return type:bool
registerComponents()[source]

Registers the Components.

Usage:

>>> manager = Manager(("./manager/tests/testsManager/resources/components/core",))
>>> manager.registerComponents()
True
>>> manager.components.keys()
[u'core.testsComponentA', u'core.testsComponentB']
Returns:Method success.
Return type:bool
unregisterComponents()[source]

Unregisters the Components.

Warning

The Manager class is not responsible of any deactivation / cleanup actions and will not trigger anything while unregistering a Component.

Usage:

>>> manager = Manager(("./manager/tests/testsManager/resources/components/core",))
>>> manager.registerComponents()
True
>>> manager.unregisterComponents()
True
>>> manager.components
{}
Returns:Method success.
Return type:bool
instantiateComponent(component, callback=None)[source]

Instantiates given Component.

Usage:

>>> manager = Manager()
>>> manager.registerComponent("testsComponentA.rc")
True
>>> manager.instantiateComponent("core.testsComponentA")
True
>>> manager.getInterface("core.testsComponentA")
<testsComponentA.TestsComponentA object at 0x17a5b90>
Parameters:
  • component (unicode) – Component to instantiate.
  • callback (object) – Callback object.
instantiateComponents(callback=None)[source]

Instantiates the Components.

Usage:

>>> manager = Manager(("./manager/tests/testsManager/resources/components/core",))
>>> manager.registerComponents()
True
>>> manager.instantiateComponents()
True
>>> manager.getInterface("core.testsComponentA")
<testsComponentA.TestsComponentA object at 0x17a5bb0>
Parameters:callback (object) – Callback object.
reloadComponent(component)[source]

Reload given Component module.

Usage:

>>> manager = Manager()
>>> manager.registerComponent("testsComponentA.rc")
True
>>> manager.instantiateComponent("core.testsComponentA")
True
>>> manager.getInterface("core.testsComponentA")
<testsComponentA.TestsComponentA object at 0x17b4890>
>>> manager.reloadComponent("core.testsComponentA")
True
>>> manager.getInterface("core.testsComponentA")
<testsComponentA.TestsComponentA object at 0x17b0d70>
Parameters:component (unicode) – Component name.
Returns:Reload success.
Return type:bool
listComponents(dependencyOrder=True)[source]

Lists the Components by dependency resolving.

Usage:

>>> manager = Manager(("./manager/tests/testsManager/resources/components/core",))
>>> manager.registerComponents()
True
>>> manager.listComponents()
[u'core.testsComponentA', u'core.testsComponentB']
Parameters:dependencyOrder (bool) – Components are returned by dependency order.
listDependents(component, dependents=None)[source]

Lists given Component dependents Components.

Usage:

>>> manager = Manager(("./manager/tests/testsManager/resources/components/core",))
>>> manager.registerComponents()
True
>>> manager.listDependents("core.testsComponentA")
[u'core.testsComponentB']
Parameters:
  • component (unicode) – Component to retrieve the dependents Components.
  • dependents (set) – Component dependents Components.
Returns:

Dependent Components.

Return type:

list

filterComponents(pattern, category=None)[source]

Filters the Components using given regex pattern.

Usage:

>>> manager = Manager(("./manager/tests/testsManager/resources/components/core",))
>>> manager.registerComponents()
True
>>> manager.filterComponents("\w+A$")
[u'core.testsComponentA']
Parameters:
  • pattern (unicode) – Regex filtering pattern.
  • category (unicode) – Category filter.
Returns:

Matching Components.

Return type:

list

getProfile(component)[source]

Gets given Component profile.

Usage:

>>> manager = Manager()
>>> manager.registerComponent("testsComponentA.rc")
True
>>> manager.getProfile("core.testsComponentA")
<manager.componentsManager.Profile object at 0x10258ef10>
Parameters:component (unicode) – Component to get the profile.
Returns:Component profile.
Return type:Profile
getInterface(component)[source]

Gets given Component interface.

Usage:

>>> manager = Manager()
>>> manager.registerComponent("testsComponentA.rc")
True
>>> manager.getInterface("core.testsComponentA")
<testsComponentA.TestsComponentA object at 0x17b0d70>
Parameters:component (unicode) – Component to get the interface.
Returns:Component interface.
Return type:object
getComponentAttributeName(component)[source]

Gets given Component attribute name.

Usage:

>>> Manager.getComponentAttributeName("factory.componentsManagerUi")
u'factoryComponentsManagerUi'
Parameters:component (unicode) – Component to get the attribute name.
Returns:Component attribute name.
Return type:object