search message to find and extract a named value
511590
def extract_message_value(self, name):
        '''  '''
        name += ":"
        assert(self._message)
        _start = self._message.find(name)
        if _start >= 0:
            _start += len(name) + 1
            _end = self._message.find("\n", _start)
            _value = self._message[_start:_end]
            return _value.strip()

        return None
181607
def _TryPrintAsAnyMessage(self, message):
    """"""
    packed_message = _BuildMessageFromTypeName(message.TypeName(),
                                               self.descriptor_pool)
    if packed_message:
      packed_message.MergeFromString(message.value)
      self.out.write('%s[%s]' % (self.indent * ' ', message.type_url))
      self._PrintMessageFieldValue(packed_message)
      self.out.write(' ' if self.as_one_line else '\n')
      return True
    else:
      return False
518138
def find_message(self):
        ''''''
        while True:
            self.msg = self.mlog.recv_match(condition=args.condition)
            if self.msg is not None and self.msg.get_type() != 'BAD_DATA':
                break
            if self.mlog.f.tell() > self.filesize - 10:
                self.paused = True
                break
        self.last_timestamp = getattr(self.msg, '_timestamp')
1229858
def parse_match_info(self, req: Request, name: str, field: Field) -> typing.Any:
        """"""
        return core.get_value(req.match_info, name, field)
32561
def extract_from(rails_message, format: :full, source: nil)
      from = nil

      # check to see if a source is present, and if it is use the naming convention
      if source.present?
        # we'll set from here, and then fall through
        from = extract_custom(rails_message, "#{source}_from")
      end

      # if a source was specified and value found, from should already be set
      # otherwise we need to fall back to the normal from field
      from ||= rails_message[:from].formatted.first

      # try to do a complex extract on the from, and proceed from there
      from = complex_extract(from)
      return from[:value] if from[:decoded]

      case format
      when :full
        rails_message[:from].formatted.first
      when :name
        rails_message[:from].address_list.addresses.first.name
      when :address
        rails_message[:from].address_list.addresses.first.address
      end
    end
1158650
protected String getString(Exchange exchange, Message message, String name) {
        Object value = getObject(exchange, message, name);
        if (value instanceof String) {
            return (String)value;
        } else if (value != null) {
            return String.valueOf(value);
        }
        return null;
    }
1228647
def do_search(self, string):
        """"""
        results = self.n.doSearch(string, full_path = self.current_path)

        if results:
            for r in results:
                self.stdout.write("%s\n" % r['path'])
103236
private static String extractTopItem(String searchString, String schema, int startIdx) {
		String extracted = null;
		int propIdx = schema.indexOf("\"properties\"", startIdx);
		if (propIdx == -1) {
			propIdx = Integer.MAX_VALUE;
		}
		// check for second
		int idIdx = schema.indexOf("\"" + searchString + "\"", startIdx);
		int secondIdIdx = schema.indexOf("\"" + searchString + "\"", idIdx + 1);
		if (secondIdIdx != -1 && propIdx > secondIdIdx) {
			idIdx = secondIdIdx;
		}
		if (idIdx != -1 && propIdx > idIdx) { // make sure we're not in a nested
												// id
			// find the 1st and second " after the idx
			int valueStartIdx = schema.indexOf("\"", idIdx + (searchString.length() + 2));
			int valueEndIdx = schema.indexOf("\"", valueStartIdx + 1);
			extracted = schema.substring(valueStartIdx + 1, valueEndIdx);
		}
		return extracted;
	}
1304402
def extract_name_value_type(self, name, value, limit_size=False):
        
        MAX_STRING_LEN_TO_RETURN = 487
        try:
            t_value = repr(value)
        except:
            t_value = "Error while extracting value"

        # convert all var names to string
        if isinstance(name, str):
            r_name = name
        else:
            r_name = repr(name)

        # truncate value to limit data flow between ikpdb and client
        if len(t_value) > MAX_STRING_LEN_TO_RETURN:
            r_value = "%s ... (truncated by ikpdb)" % (t_value[:MAX_STRING_LEN_TO_RETURN],) 
            r_name = "%s*" % r_name  # add a visual marker to truncated var's name
        else:
            r_value = t_value
            
        if isinstance(value, str):
            r_type = "%s [%s]" % (IKPdbRepr(value), len(value),)
        else:
            r_type = IKPdbRepr(value)
            
        return r_name, r_value, r_type
143351
def search_messages(query, &callback)
      http(:get, "/search/#{query}.json") do |data, http|
        callback.call(data[:messages].map { |msg| Firering::Message.instantiate(self, msg) }) if callback
      end
    end
1158031
def namedb_get_name(cur, name, current_block, include_expired=False, include_history=True, only_registered=True):
    

    if not include_expired:

        unexpired_fragment, unexpired_args = namedb_select_where_unexpired_names(current_block, only_registered=only_registered)
        select_query = "SELECT name_records.* FROM name_records JOIN namespaces ON name_records.namespace_id = namespaces.namespace_id " + \
                       "WHERE name = ? AND " + unexpired_fragment + ";"
        args = (name, ) + unexpired_args

    else:
        select_query = "SELECT * FROM name_records WHERE name = ?;"
        args = (name,)

    # log.debug(namedb_format_query(select_query, args))

    name_rows = namedb_query_execute( cur, select_query, args )
    name_row = name_rows.fetchone()
    if name_row is None:
        # no such name
        return None 

    name_rec = {}
    name_rec.update( name_row )
    
    if include_history:
        name_history = namedb_get_history( cur, name )
        name_rec['history'] = name_history

    return name_rec
397391
def named_field(key, regex, vim=False):
    
    if key is None:
        #return regex
        return r'(%s)' % (regex,)
    if vim:
        return r'\(%s\)' % (regex)
    else:
        return r'(?P<%s>%s)' % (key, regex)
580690
def a(value):
    
    name = getattr(value, 'name', value)
    return some(lambda t: t == value).named(u'(a "%s")' % (name,))
754123
def find_next(lines, find_str, start_index):
    
    mode = None
    if isinstance(find_str, basestring):
        mode = 'normal'
        message = find_str
    elif isinstance(find_str, Invert):
        mode = 'invert'
        message = str(find_str)
    else:
        raise TypeError("Unsupported message type")
    for i in range(start_index, len(lines)):
        if re.search(message, lines[i]):
            return mode == 'normal', i, lines[i]
        elif message in lines[i]:
            return mode == 'normal', i, lines[i]
    if mode == 'invert':
        return True, len(lines), None
    raise LookupError("Not found")
730635
def getValueByName(node, name):
    

    try:
        value = node.xpath("*[local-name() = '%s']" % name)[0].text.strip()
    except:
        return None
    return value
156948
public void expectMatch(String name, String message, List<String> values) {
        String value = Optional.ofNullable(get(name)).orElse("");

        if (!(values).contains(value)) {
            addError(name, Optional.ofNullable(message).orElse(messages.get(Validation.MATCH_VALUES_KEY.name(), name)));
        }
    }
1073895
def find_matches(self, text):
        """"""
        if self.use_main_ns:
            self.namespace = __main__.__dict__

        if "." in text:
            return self.attr_matches(text)
        else:
            return self.global_matches(text)