def _set_value(self, node, value, vid=None, subgroup=None, ignore_type=False): """ Set the value of an entry-id field to value Returns the value or None if not found subgroup is ignored in the general routine and applied in specific methods """ expect(subgroup is None, "Subgroup not supported") valid_values = self.get_optional_node("valid_values", root=node) if ignore_type: expect( type(value) is str, "Value must be type string if ignore_type is true") str_value = value else: type_str = self._get_type_info(node) str_value = convert_to_string(value, type_str, vid) if valid_values is not None and valid_values.text is not None and not str_value.startswith( '$'): vvlist = [item.lstrip() for item in valid_values.text.split(',')] expect(str_value in vvlist, "Did not find %s in valid values:%s" % (value, vvlist)) node.set("value", str_value) return value
def get_valid_value_string(self, node, value,vid=None, ignore_type=False): valid_values = self._get_valid_values(node) if ignore_type: expect(type(value) is str, "Value must be type string if ignore_type is true") str_value = value return str_value type_str = self._get_type_info(node) str_value = convert_to_string(value, type_str, vid) if valid_values is not None and not str_value.startswith('$'): expect(str_value in valid_values, "Did not find {} in valid values for {}: {}".format(value, vid, valid_values)) return str_value
def get_valid_value_string(self, node, value,vid=None, ignore_type=False): valid_values = self._get_valid_values(node) if ignore_type: expect(type(value) is str, "Value must be type string if ignore_type is true") str_value = value return str_value type_str = self._get_type_info(node) str_value = convert_to_string(value, type_str, vid) if valid_values is not None and not str_value.startswith('$'): expect(str_value in valid_values, "Did not find %s in valid values for %s: %s" % (value, vid, valid_values)) return str_value
def get_valid_value_string(self, node, value,vid=None, ignore_type=False): valid_values = self._get_valid_values(node) if ignore_type: expect(isinstance(value, six.string_types), "Value must be type string if ignore_type is true") str_value = value return str_value type_str = self._get_type_info(node) str_value = convert_to_string(value, type_str, vid) if valid_values is not None and not str_value.startswith('$'): expect(str_value in valid_values, "Did not find {} in valid values for {}: {}".format(value, vid, valid_values)) return str_value
def _set_value(self, node, value, vid=None, subgroup=None, ignore_type=False): """ Set the value of an entry-id field to value Returns the value or None if not found subgroup is ignored in the general routine and applied in specific methods """ if ignore_type: expect(type(value) is str, "Value must be type string if ignore_type is true") node.set("value",value) else: type_str = self._get_type_info(node) node.set("value", convert_to_string(value, type_str, vid)) return value
def _set_value(self, node, value, vid=None, subgroup=None, ignore_type=False): """ Set the value of an entry-id field to value Returns the value or None if not found subgroup is ignored in the general routine and applied in specific methods """ expect(subgroup is None, "Subgroup not supported") valid_values = self._get_valid_values(node) if ignore_type: expect(type(value) is str, "Value must be type string if ignore_type is true") str_value = value else: type_str = self._get_type_info(node) str_value = convert_to_string(value, type_str, vid) if valid_values is not None and not str_value.startswith('$'): expect(str_value in valid_values, "Did not find %s in valid values:%s"%(value, valid_values)) node.set("value", str_value) return value
def _set_value(self, node, value, vid=None, subgroup=None, ignore_type=False, component=None): if vid is None: vid = node.get("id") vid, _, iscompvar = self.check_if_comp_var(vid, None) if iscompvar: attribute = {"component": component} type_str = self._get_type_info(node) val = self.set_element_text("value", convert_to_string( value, type_str, vid), attribute, root=node) return val val = EntryID._set_value(self, node, value, vid, subgroup, ignore_type) return val