EvaluationAttributeNameValidator

Inheritance diagram of EvaluationAttributeNameValidator
class EvaluationAttributeNameValidator(*p, **k)[source]

Validator for Evaluation attribute names. Apart from the standard named groups (scheme, authority, path, query and fragment), the following named groups are created:

  • attrname: attribute name. same as concatenating _subst with _expr

  • _expr: a mathematical expression

  • _evalrefs: a list of eval refs found in the name (see getRefs())

  • [_subst]: a semicolon-separated repetition of key=value (for replacing them in _expr)

  • [devname]: as in EvaluationDeviceNameValidator

  • [_evalname]: evaluation instance name (aka non-dotted dev name)

  • [_evaldotname]: evaluator instance dotted name (if dotted name given)

  • [_old_devname]: devname without “@”. Only in non-strict mode

  • [_dbname] and [_subst]: unused. Only if non-strict mode

  • [cfgkey] same as fragment (for bck-compat use only)

Note: brackets on the group name indicate that this group will only contain a value if the URI contains it.

Import from taurus.core.evaluation.evalvalidator as:

from taurus.core.evaluation.evalvalidator import EvaluationAttributeNameValidator
authority = '//localhost'
static expandExpr(expr, substmap)[source]

expands expr by substituting all keys in map by their value. Note that eval references in expr (i.e. text within curly brackets) is not substituted.

Parameters:
  • expr (str) – string that may contain symbols defined in symbolMap

  • symbolMap (dict or str) – dictionary whose keys (strings) are symbols to be substituted in expr and whose values are the corresponding replacements. Alternatively, a string containing a semi-colon separated list of symbol=value pairs can also be passed.

fragment = '(?P<cfgkey>[^# ]*)'
getAttrName(s)[source]
getDBName(s)[source]

returns the full data base name for the given attribute name

getDeviceName(name)[source]

Obtain the fullname of the device from the attribute name

getExpandedExpr(name)[source]

Returns the expanded expression from the attribute name URI

Parameters:

name (str) – eval attribute URI

Returns:

the expression (from the name )expanded with any substitution k,v pairs also defined in the name

Return type:

str

getNames(fullname, factory=None, fragment=False)[source]

reimplemented from TaurusDeviceNameValidator

static getRefs(expr, ign_quoted=True)[source]

Find the attribute references (strings within brackets) in an eval expression. In case of nested references, only the outermost level is returned.

Example: val.getRefs(‘{foo}bar{zig{zag}}boom’) –> [‘foo’, ‘zig{zag}’]

Parameters:
  • expr (str) – the expression to parse

  • ign_quoted – If True (default) ignore refs within quotes

Returns:

a list of refs (not including the brackets)

Return type:

list<str>

getUriGroups(name, strict=None)[source]

reimplemented from TaurusAttributeNameValidator to provide backwards compatibility with old syntax

isValid(name, matchLevel=None, strict=None)[source]

reimplemented from TaurusAttributeNameValidator to do extra check on references validity (recursive)

property nonStrictNamePattern

In non-strict mode support old-style eval config names

path = '(?!//)/?((?P<devname>@((?P<_evalname>[^/?#:\\.=]+)|(?P<_evaldotname>((?P<_evalinstname>\\w+)=)?(?P<_evalmodname>(\\w+\\.)*\\w+)\\.(?P<_evalclassname>(\\w+|\\*))(?P<_evalclassparenths>\\(("[^"]*"|\\\'[^\\\']*\\\'|[^\\\'"/])*?\\))?)))/)?(?P<attrname>(?P<_subst>(((?<![\\.a-zA-Z0-9_])[a-zA-Z_][a-zA-Z0-9_]*)=([^?#=;]+);)+)?(?P<_expr>[^@?#]+))'
query = '(?!)'
static replaceUnquotedRef(string, substring, repl)[source]

Return a copy of string where first non-quoted occurrence of substring is replaced by repl

Parameters:
  • string (str) – string to be used

  • substring (str) – substring to be replaced

  • repl (str) – replacement

Returns:

Return type:

str

scheme = 'eval'