Parse a 'Value' declaration.

    Args:
      value: String line from a template file, must begin with 'Value '.

    Raises:
      TextFSMTemplateError: Value declaration contains an error.
185110
def Parse(self, value):
    

    value_line = value.split(' ')
    if len(value_line) < 3:
      raise TextFSMTemplateError('Expect at least 3 tokens on line.')

    if not value_line[2].startswith('('):
      # Options are present
      options = value_line[1]
      for option in options.split(','):
        self._AddOption(option)
      # Call option OnCreateOptions callbacks
      [option.OnCreateOptions() for option in self.options]

      self.name = value_line[2]
      self.regex = ' '.join(value_line[3:])
    else:
      # There were no valid options, so there are no options.
      # Treat this argument as the name.
      self.name = value_line[1]
      self.regex = ' '.join(value_line[2:])

    if len(self.name) > self.max_name_len:
      raise TextFSMTemplateError(
          "Invalid Value name '%s' or name too long." % self.name)

    if (not re.match(r'^\(.*\)$', self.regex) or
        self.regex.count('(') != self.regex.count(')')):
      raise TextFSMTemplateError(
          "Value '%s' must be contained within a '()' pair." % self.regex)

    self.template = re.sub(r'^\(', '(?P<%s>' % self.name, self.regex)
758871
def value_assign(self, end_token=None):
        
        while True:
            token = self.next()
            t_value = token["value"]
            if end_token:
                if t_value == end_token:
                    raise self.ParseEnd()
                elif t_value == "\n":
                    continue
            if token["type"] == "literal":
                return self.make_value(t_value)
            if token["type"] == "function":
                return self.config_function(token)
            elif t_value == "[":
                return self.make_list()
            elif t_value == "{":
                return self.make_dict()
            elif t_value == "(":
                return tuple(self.make_list(end_token=")"))
            else:
                self.error("Value expected", previous=not (end_token))
1333548
def _handle_value(self, value):
        
        if self._inspec:
            # Parsing a configspec so don't handle comments
            return (value, '')
        # do we look for lists in values ?
        if not self.list_values:
            mat = self._nolistvalue.match(value)
            if mat is None:
                raise SyntaxError()
            # NOTE: we don't unquote here
            return mat.groups()
        #
        mat = self._valueexp.match(value)
        if mat is None:
            # the value is badly constructed, probably badly quoted,
            # or an invalid list
            raise SyntaxError()
        (list_values, single, empty_list, comment) = mat.groups()
        if (list_values == '') and (single is None):
            # change this if you want to accept empty values
            raise SyntaxError()
        # NOTE: note there is no error handling from here if the regex
        # is wrong: then incorrect values will slip through
        if empty_list is not None:
            # the single comma - meaning an empty list
            return ([], comment)
        if single is not None:
            # handle empty values
            if list_values and not single:
                # FIXME: the '' is a workaround because our regex now matches
                #   '' at the end of a list if it has a trailing comma
                single = None
            else:
                single = single or '""'
                single = self._unquote(single)
        if list_values == '':
            # not a list value
            return (single, comment)
        the_list = self._listvalueexp.findall(list_values)
        the_list = [self._unquote(val) for val in the_list]
        if single is not None:
            the_list += [single]
        return (the_list, comment)
676469
def _parse_value(self):
        """"""
        indent = 0
        while self._cur_token['type'] is TT.ws:
            indent = self._skip_whitespace()
            self._skip_newlines()

        if self._cur_token['type'] is TT.id:
            return self._parse_key(indent)
        elif self._cur_token['type'] is TT.hyphen:
            self._increment()
            if self._cur_token['type'] is TT.hyphen:
                self._increment()
                return []
            else:
                return self._parse_object_list()
        else:
            # TODO: single comma gives empty list
            return self._parse_literal_list(indent)
1325647
def expand_template(template, value):
    
    value = wrap(value)
    if is_text(template):
        return _simple_expand(template, (value,))

    return _expand(template, (value,))
671030
def tag(self, value):
        
        if value is None:
            value = sys.argv[0]
        self._tag = value[:self.MAX_TAG_LEN]
425467
def parse(self, value):
        
        result = {}
        rest = {}
        for k, v in value.iteritems():
            if k in self.fields:
                if (isinstance(v, dict)
                        and not self.fields[k].supports_multiple):
                    if len(v) == 1:
                        # We support "foo.1" as "foo" as long as there is only
                        # one "foo.#" parameter provided.... -_-
                        v = v.values()[0]
                    else:
                        raise InvalidParameterCombinationError(k)
                result[k] = self.fields[k].coerce(v)
            else:
                rest[k] = v
        for k, v in self.fields.iteritems():
            if k not in result:
                result[k] = v.coerce(None)
        if rest:
            raise UnknownParametersError(result, rest)
        return result
325710
public final void value_section() throws RecognitionException {
		try {
			// src/main/resources/org/drools/compiler/lang/dsl/DSLMapWalker.g:105:5: ( ^( VT_ENTRY_VAL ( value_sentence )+ ) )
			// src/main/resources/org/drools/compiler/lang/dsl/DSLMapWalker.g:105:7: ^( VT_ENTRY_VAL ( value_sentence )+ )
			{
			match(input,VT_ENTRY_VAL,FOLLOW_VT_ENTRY_VAL_in_value_section329); 
			match(input, Token.DOWN, null); 
			// src/main/resources/org/drools/compiler/lang/dsl/DSLMapWalker.g:105:22: ( value_sentence )+
			int cnt11=0;
			loop11:
			while (true) {
				int alt11=2;
				int LA11_0 = input.LA(1);
				if ( (LA11_0==VT_LITERAL||LA11_0==VT_SPACE||LA11_0==VT_VAR_REF) ) {
					alt11=1;
				}

				switch (alt11) {
				case 1 :
					// src/main/resources/org/drools/compiler/lang/dsl/DSLMapWalker.g:105:22: value_sentence
					{
					pushFollow(FOLLOW_value_sentence_in_value_section331);
					value_sentence();
					state._fsp--;

					}
					break;

				default :
					if ( cnt11 >= 1 ) break loop11;
					EarlyExitException eee = new EarlyExitException(11, input);
					throw eee;
				}
				cnt11++;
			}

			match(input, Token.UP, null); 

			}


			    entry_stack.peek().valuebuffer.append(" ");

		}
		catch (RecognitionException re) {
			reportError(re);
			recover(input,re);
		}
		finally {
			// do for sure before leaving
		}
	}
446212
def setValue(self, value):
        
        if value >= self.minimum() and value <= self.maximum():
            self._lineEdit.setText(str(value))
        elif value < self.minimum():
            self._lineEdit.setText(str(self.minimum()))
        elif value > self.maximum():
            self._lineEdit.setText(str(self.maximum()))
        return True
1031619
def pprint_value_string(self, value):
        
        unit = '' if self.unit is None else ' ' + bytes_to_unicode(self.unit)
        value = self.pprint_value(value)
        return title_format.format(name=bytes_to_unicode(self.label), val=value, unit=unit)
1153929
def parse(self, declaration):
        
        declaration = declaration.strip()
        for regex, constructor in self._compiled:
            m = regex.match(declaration)
            if m:
                return constructor(*m.groups())
        raise ValueError('Unable to parse type declaration', declaration)
720873
def parse_value(value, allow_spaces=True, unquote=default_unquote):
    ""
    if value is None:
        return None
    value = strip_spaces_and_quotes(value)
    value = parse_string(value, unquote=unquote)
    if not allow_spaces:
        assert ' ' not in value
    return value
913012
def contains_value(self, value):
        
        check_not_none(value, "value can't be None")
        value_data = self._to_data(value)
        return self._encode_invoke(map_contains_value_codec, value=value_data)
1104027
def fmt(self, value):
        
        if isinstance(value, str):
            value = value.split(self.join_str)
        if not (value and isinstance(value, (list, tuple))):
            raise TypeError(
                ' '.join((
                    'Expecting str or list/tuple of formats {!r}.',
                    'Got: ({}) {!r}'
                )).format(
                    self.default_format,
                    type(value).__name__,
                    value,
                ))
        self._fmt = value
976099
def _value_decode(cls, member, value):
        
        if value is None:
            return None
        try:
            field_validator = cls.fields[member]
        except KeyError:
            return cls.valueparse.decode(value)

        return field_validator.decode(value)
145787
def message(self, value):
        
        try:
            import ast
            value = ast.literal_eval(value)
        except (SyntaxError, TypeError, ValueError):
            pass
        try:
            value = value.get('value', value)
            msg_data = value.split('\n')
            self._message = msg_data[0]
        except AttributeError:
            self._message = value
            return
        try:
            self.request_id = msg_data[1].partition(':')[2]
            time_str = msg_data[2].partition(':')
            self.error_time = Deserializer.deserialize_iso(
                "".join(time_str[2:]))
        except (IndexError, DeserializationError):
            pass
126841
def handle_value_definition
      value_def = @entry.at_xpath('./*/cda:repeatNumber', HQMF2::Document::NAMESPACES)
      unless value_def
        # TODO: HQMF needs better differentiation between SUM & COUNT...
        # currently using presence of repeatNumber...
        @type = 'SUM' if @type == 'COUNT'
        value_def = @entry.at_xpath('./*/cda:value', HQMF2::Document::NAMESPACES)
      end

      # TODO: Resolve extracting values embedded in criteria within outboundRel's
      if @type == 'SUM'
        value_def = @entry.at_xpath('./*/*/*/cda:value', HQMF2::Document::NAMESPACES)
      end

      if value_def
        value_type = value_def.at_xpath('./@xsi:type', HQMF2::Document::NAMESPACES)
        @value = HQMF2::AnyValue.new if String.try_convert(value_type) == 'ANY'
      end

      value_def
    end