4.2. manager.componentsManager

manager.py

Platform:
Windows, Linux, Mac Os X.
Description:
This module 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

This class represents a storage object for Manager class Components.

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

Bases: object

This class is used by the Manager class to store Components informations and objects.

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

This method is the property for self.__name attribute.

Returns:self.__name. ( String )
file[source]

This method is the property for self.__file attribute.

Returns:self.__file. ( String )
directory[source]

This method is the property for self.__directory attribute.

Returns:self.__directory. ( String )
attribute[source]

This method is the property for self.__attribute attribute.

Returns:self.__attribute. ( String )
require[source]

This method is the property for self.__require attribute.

Returns:self.__require. ( Tuple / List )
module[source]

This method is the property for self.__module attribute.

Returns:self.__module. ( Module )
interface[source]

This method is the property for self.__interface attribute.

Returns:self.__interface. ( Object )
category[source]

This method is the property for self.__category attribute.

Returns:self.__category. ( String )
title[source]

This method is the property for self.__title attribute.

Returns:self.__title. ( String )
package[source]

This method is the property for self.__package attribute.

Returns:self.__package. ( String )
version[source]

This method is the property for self.__version attribute.

Returns:self.__version. ( String )
author[source]

This method is the property for self.__author attribute.

Returns:self.__author. ( String )
email[source]

This method is the property for self.__email attribute.

Returns:self.__email. ( String )
url[source]

This method is the property for self.__url attribute.

Returns:self.__url. ( String )
description[source]

This method is the property for self.__description attribute.

Returns:self.__description. ( String )
initializeProfile()[source]

This method gets initializes the Component Profile.

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

Bases: object

This class 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.

Usage:

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

This method is the property for self.__paths attribute.

Returns:self.__paths. ( Tuple / List )
extension[source]

This method is the property for self.__extension attribute.

Returns:self.__extension. ( String )
categories[source]

This method is the property for self.__categories attribute.

Returns:self.__categories. ( Dictionary )
components[source]

This method is the property for self.__components attribute.

Returns:self.__components. ( Dictionary )
registerComponent(path)[source]

This method registers a Component using given path.

Usage:

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

This method 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 – Component to remove. ( String )
Returns:Method success. ( Boolean )
registerComponents()[source]

This method registers the Components.

Usage:

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

This method 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. ( Boolean )
instantiateComponent(component, callback=None)[source]

This method 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 – Component to instantiate. ( String )
  • callback – Callback object. ( Object )
instantiateComponents(callback=None)[source]

This method 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 – Callback object. ( Object )
reloadComponent(component)[source]

This method 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 – Component name. ( String )
Returns:Reload success. ( Boolean )
listComponents(dependencyOrder=True)[source]

This method lists the Components by dependency resolving.

Usage:

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

This method lists given Component dependents Components.

Usage:

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

Dependent Components. ( List )

filterComponents(pattern, category=None)[source]

This method filters the Components using given regex pattern.

Usage:

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

Matching Components. ( List )

getProfile(component)[source]

This method gets given Component profile.

Usage:

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

This method gets given Component interface.

Usage:

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

This method gets given Component attribute name.

Usage:

>>> Manager.getComponentAttributeName("factory.componentsManagerUi")
'factoryComponentsManagerUi'
Parameters:component – Component to get the attribute name. ( String )
Returns:Component attribute name. ( Object )

Table Of Contents

Previous topic

4.1. manager.component

Next topic

4.3. manager.exceptions

This Page