taurus-org / taurus

Moved to https://gitlab.com/taurus-org/taurus
http://taurus-scada.org
43 stars 46 forks source link

No isString in taurus.core.tango.tangoattribute.TangoAttribute #1079

Closed vallsv closed 4 years ago

vallsv commented 4 years ago

HI,

I would like to know why there is no string check, while, isBoolean, isInteger... are there.

Is there a clean way to check that the attribute stores a string?

vallsv commented 4 years ago

Well, in fact i also receive a warning for other getters

MainThread     WARNING  2020-02-24 11:27:46,301 TaurusRootLogger: /users/valls/workspace/id16/linecontrol.git/src/linecontrol/widget/taurus/TaurusButtonAttributeSetter.py:121: DeprecationWarning: TangoAttrValue.isBoolean is deprecated since 4.0. Use TangoAttribute.isBoolean instead
  if obj.isBoolean():

But i only inherit from TaurusBaseWritableWidget, and reach the attribute this way:

obj = self.getModelObj().getValueObj()

Any idea what's wrong here?

vallsv commented 4 years ago

By code base was only needed the attribute type, then i remove the value. I also found the generic way to check string.

attr.type == taurusbasetypes.DataType.String

If it's fine, please close this issue.

cpascual commented 4 years ago

Yes, as you already found out, the recommended scheme-agnostic way of checking the data type is comparing the value of TaurusAttribute.type aginst the taurus.core.DataType enumeration values.

In fact, I am surprised that TaurusAttribute.isBoolean() and TaurusAttribute.isNumeric() are not yet deprecated, since they are there only for historical reasons due to previous tango-centrisms