Commit a3a8b1e5 authored by eric pellegrini's avatar eric pellegrini
Browse files

docstringed new set of configurators

parent f99ab373
......@@ -27,7 +27,7 @@
'''
Created on Mar 30, 2015
@author: pellegrini
@author: Eric C. Pellegrini
'''
......@@ -35,15 +35,29 @@ from MDANSE import REGISTRY
from MDANSE.Framework.Configurators.IConfigurator import IConfigurator, ConfiguratorError
class ProjectionConfigurator(IConfigurator):
"""
This configurator allows to define a projection axis.
"""
'''
This configurator allows to define a projector for atomic coordinates.
Planar and axial projections are supported by MDANSE while a null projector, that does not project the coordinates, has been introduced
in MDANSE.Framework.Projectors.IProjector.IProjector for the sake of homogeneity.
'''
type = 'projection'
_default = None
def configure(self, configuration, value):
'''
Configure a projector.
:param configuration: the current configuration.
:type configuration: a MDANSE.Framework.Configurable.Configurable object
:param value: the input projector definition. It must be a 2-tuple whose 1st element if the name of the projector (one of 'null','axial' or 'planar')
and the 2nd element the parameters for hte selected projector (None for 'null', a Scientific.Vector for 'axial' and a list of two Scientific.Vector for
'planar').
a list of file formats.
:type value: 2-tuple
'''
if value is None:
value = ('null',None)
......@@ -67,5 +81,11 @@ class ProjectionConfigurator(IConfigurator):
self["axis"] = self["projector"].axis
def get_information(self):
'''
Returns string information about this configurator.
:return: the information about this configurator.
:rtype: str
'''
return "Projection along %r axis:" % self["axis"]
\ No newline at end of file
......@@ -27,7 +27,7 @@
'''
Created on Mar 30, 2015
@author: pellegrini
@author: Eric C. Pellegrini
'''
import ast
......@@ -36,7 +36,11 @@ from MDANSE.Framework.Configurators.IConfigurator import IConfigurator
class PythonObjectConfigurator(IConfigurator):
"""
This Configurator allows to input any kind of basic python object.
This Configurator allows to input and evaluate basic python object.
The python object supported are strings, numbers, tuples, lists, dicts, booleans and None type.
:note: this configurator is based on a literal and safe evaluation of the input using ast standard library module.
"""
type = 'python_object'
......@@ -44,11 +48,25 @@ class PythonObjectConfigurator(IConfigurator):
_default = '""'
def configure(self, configuration, value):
'''
Configure a python object.
:param configuration: the current configuration.
:type configuration: a MDANSE.Framework.Configurable.Configurable object
:param value: the python object to be configured and evaluated.
:type value: strings, numbers, tuples, lists, dicts, booleans or None type.
'''
value = ast.literal_eval(repr(value))
self['value'] = value
def get_information(self):
'''
Returns string information about this configurator.
:return: the information about this configurator.
:rtype: str
'''
return "Python object: %r" % self['value']
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment