X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=src%2Fnepi%2Fexecution%2Fattribute.py;h=e9f4c54a277e951a38707d28e6c11d60d3df2286;hb=573bc6721a33d323047f204841dd58ef2b83d195;hp=3d46edc405d972a7af86038bc256c5c52474c684;hpb=4e41e58c71c09ac4a38f6ecff12d3ae98a9e4154;p=nepi.git diff --git a/src/nepi/execution/attribute.py b/src/nepi/execution/attribute.py index 3d46edc4..e9f4c54a 100644 --- a/src/nepi/execution/attribute.py +++ b/src/nepi/execution/attribute.py @@ -44,23 +44,42 @@ class Flags: class Attribute(object): """ .. class:: Class Args : + + An Attribute reflects a configuration parameter for + a particular resource. Attributes might be read only or + not. :param name: Name of the attribute :type name: str - :param help: Help about the attribute + + :param help: Attribute description :type help: str - :param type: type of the attribute + + :param type: The type expected for the attribute value. + Should be one of Attribute.Types . :type type: str - :param flags: Help about the attribute - :type flags: str + + :param flags: Defines attribute behavior (i.e. whether it is read-only, + read and write, etc). This parameter should take its values from + Attribute.Flags. Flags values can be bitwised. + :type flags: hex + :param default: Default value of the attribute - :type default: str - :param allowed: Allowed value for this attribute - :type allowed: str - :param range: Range of the attribute - :type range: str - :param set_hook: hook that is related with this attribute - :type set_hook: str + :type default: depends on the type of attribute + + :param allowed: List of values that the attribute can take. + This parameter is only meaningful for Enumerate type attributes. + :type allowed: list + + :param range: (max, min) tuple with range of possible values for + attributes. + This parameter is only meaningful for Integer or Double type + attributes. + :type range: (int, int) or (float, float) + + :param set_hook: Function that will be executed when ever a new + value is set for the attribute. + :type set_hook: function """ def __init__(self, name, help, type = Types.String, @@ -79,53 +98,53 @@ class Attribute(object): @property def name(self): - """ Returns the name of the attribute """ + """ Returns the name of the attribute """ return self._name @property def default(self): - """ Returns the default value of the attribute """ + """ Returns the default value of the attribute """ return self._default @property def type(self): - """ Returns the type of the attribute """ + """ Returns the type of the attribute """ return self._type @property def help(self): - """ Returns the help of the attribute """ + """ Returns the help of the attribute """ return self._help @property def flags(self): - """ Returns the flags of the attribute """ + """ Returns the flags of the attribute """ return self._flags @property def allowed(self): - """ Returns the allowed value for this attribute """ + """ Returns the allowed value for this attribute """ return self._allowed @property def range(self): - """ Returns the range of the attribute """ + """ Returns the range of the attribute """ return self._range def has_flag(self, flag): - """ Returns true if the attribute has the flag 'flag' + """ Returns true if the attribute has the flag 'flag' :param flag: Flag that need to be ckecked :type flag: Flags - """ + """ return (self._flags & flag) == flag def get_value(self): - """ Returns the value of the attribute """ + """ Returns the value of the attribute """ return self._value def set_value(self, value): - """ Change the value of the attribute after checking the type """ + """ Change the value of the attribute after checking the type """ valid = True if self.type == Types.Enumerate: