def getUriGroups(self, name, strict=None): groups = TaurusAttributeNameValidator.getUriGroups(self, name, strict) if groups is not None: if groups.get('arch_db', None) is not None: # add devname to the groups groups['devname'] = '?db={arch_db}'.format(**groups) return groups
def getUriGroups(self, name, strict=None): '''Reimplementation of getUriGroups to fix the host and authority name using fully qualified domain name for the host. ''' ret = TaurusAttributeNameValidator.getUriGroups(self, name, strict) if ret is not None and ret.get("host", None) is not None: fqdn = fqdn_no_alias(ret["host"]) ret["host"] = fqdn ret["authority"] = "//{host}:{port}".format(**ret) return ret
def getUriGroups(self, name, strict=None): '''reimplemented from :class:`TaurusAttributeNameValidator` to provide backwards compatibility with old syntax''' # mangle refs before matching the pattern to sanitize them refs = self.getRefs(name, ign_quoted=False) refs_dict = {} _name = name for i, ref in enumerate(refs): refs_dict['__EVALREF_%d__' % i] = '{%s}' % ref _name = _name.replace('{%s}' % ref, '{__EVALREF_%d__}' % i, 1) _groups = TaurusAttributeNameValidator.getUriGroups(self, _name, strict=strict) if _groups is None: return None # create the groups dict with unmangled refs in its values groups = {} for n, g in _groups.items(): if isinstance(g, str): # avoid None or boolean values g = g.format(**refs_dict) groups[n] = g if not groups['__STRICT__']: # adapt attrname to what would be in strict mode _subst = groups['_subst'] or '' _expr = groups['_expr'] if _subst: groups['attrname'] = "%s;%s" % (_subst.rstrip(';'), _expr) else: groups['attrname'] = _expr # adapt devname to what would be in strict mode old_devname = groups['_old_devname'] if old_devname is None: groups['devname'] = None else: groups['devname'] = '@%s' % old_devname # check that there are not ";" in the expr (ign. quoted text and refs) sanitized_expr = QUOTED_TEXT_RE.sub('', groups['_expr']) for ref in self.getRefs(sanitized_expr, ign_quoted=False): sanitized_expr = sanitized_expr.replace(ref, '') if ";" in sanitized_expr: return None # add a group containing refs in attrname (ign. those in quoted text) groups['_evalrefs'] = self.getRefs(groups['attrname'], ign_quoted=True) return groups
def _getKey(self, name): if self._elementType == TaurusElementType.Attribute: g = TaurusAttributeNameValidator.getUriGroups(self, name) elif self._elementType == TaurusElementType.Device: g = TaurusDeviceNameValidator.getUriGroups(self, name) elif self._elementType == TaurusElementType.Authority: g = TaurusAuthorityNameValidator.getUriGroups(self, name) else: msg = '_elementType must be one of (Authority, Device, Attribute)' raise Exception(msg) if g is None: return None else: return g['_resname']
def getUriGroups(self, name, strict=None): """reimplemented from :class:`TaurusAttributeNameValidator`.""" groups = TaurusAttributeNameValidator.getUriGroups(self, name, strict) if groups is None: return None attrname = groups.get('attrname') if attrname is None: return None if attrname != '': try: import ast ast.literal_eval(attrname) except: return None return groups