Package enomalism2 :: Module loader
[hide private]

Module loader

Provides various function and hook implementations related to loading Enomalism.


Requires:
Functions [hide private]
Boolean
distro_needs_enomalism(d)
Given a distro object, determines if it has an enomalism2 dependency.
String
get_top_level(d)
Return the text in the top_level file for the specified distribution object.
List
get_options()
Return a list of distributions that are candidate Enomalism extension modules.
Dictionary
hook_cfg_get_defaults(fn, self)
Set the default values that are displayed in the Enomalism configuration editor.
String
hook_cfg_get_template(fn, self)
Add the enabled modules section to the configuration editor template.
List
hook_cfg_get_widgets(fn, self)
Add the enabled modules widgets to the configuration editor.
None
hook_cfg_save_values(fn, self, values)
Save the enabled modules configuration values.
Function Details [hide private]

distro_needs_enomalism(d)

 

Given a distro object, determines if it has an enomalism2 dependency. First, we attempt to get the path of the distribution's requires file. Next, we check if the file exists. If so, we then iterate through the dependency lines in the requires file. If an Enomalism dependency is found, we return true.

Example usage:

>>> from enomalism2 import loader
>>> loader.distro_needs_enomalism(d)
Parameters:
  • d (Object) - A Python package distribution.
Returns: Boolean
True if the distribution object requires Enomalism
Raises:
  • None - No exceptions are raised by this method.

Status: Stable

get_top_level(d)

 

Return the text in the top_level file for the specified distribution object. First get get the relative path of the file. Next, we check if the file exists. If so, we then return the contents of the first line in the file.

Example usage:

>>> from enomalism2 import loader
>>> loader.get_top_level(d)
Parameters:
  • d (Object) - A Python package distribution.
Returns: String
The contents of the top_level file in the distribution.
Raises:
  • None - No exceptions are raised by this method.

Status: Stable

get_options()

 

Return a list of distributions that are candidate Enomalism extension modules. First, we get a list of all Python package distributions. We then iterate through all distributions and check each one for an Enomalism dependency. If one is found, it is added to the list o candidates.

Example usage:

>>> from enomalism2 import loader
>>> loader.get_options()
Returns: List
A list of distributions that require enomalism.
Raises:
  • None - No exceptions are raised by this function.

hook_cfg_get_defaults(fn, self)

 

Set the default values that are displayed in the Enomalism configuration editor. First, we get the results of the original method invocation. Next, we try to load the Enomalism plugins variable. Finally, we update the results with this variable and return the results.

Parameters:
Returns: Dictionary
The modified results of the original method invocation.
Decorators:
  • @hook(ConfigEditorModel, ConfigEditorModel.get_defaults)
Raises:
  • None - No exceptions are raised by this function.

Status: Stable

See Also: enomalism2.configuration.Variable.load

hook_cfg_get_template(fn, self)

 

Add the enabled modules section to the configuration editor template. First, we get the result of the original method invocation. We then append the template to the result and return the result.

Parameters:
Returns: String
The modified result of the original method invocation.
Decorators:
  • @hook(ConfigEditorModel, ConfigEditorModel.get_template)
Raises:
  • None - No exceptions are raised by this method.

Status: Stable

hook_cfg_get_widgets(fn, self)

 

Add the enabled modules widgets to the configuration editor. First, we get the results of the original method invocation. We then append the enabled modules widgets to the list of configuration editor widgets and return the list.

Parameters:
Returns: List
The modified results of the original method invocation.
Decorators:
  • @hook(ConfigEditorModel, ConfigEditorModel.get_widgets)
Raises:
  • None - No exceptions are raised by this function.

Status: Stable

hook_cfg_save_values(fn, self, values)

 

Save the enabled modules configuration values. We then return the original method invocation.

Parameters:
Returns: None
The original method invocation.
Decorators:
  • @hook(ConfigEditorModel, ConfigEditorModel.save_values)
Raises:
  • None - No exceptions are raised by this function.