Look for all the lines that match the field name and return
 a hash of hashes. An empty hash is returned when there are
 no matches.
971669
def find_fields name
      res = {}
      @lines.each do | line |
        value = line.scan(/###{name}=<(.*)>/)
        if value[0]
          str = value[0][0]
          # p str
          v = VcfHeaderParser.parse_field(line,@debug)
          id = v['ID']
          res[id] = v
        end
      end
      # p res
      res
    end
64122
def parse_file path, matcher
      File.open(path) do |f|
        f.each do |line|
          if m = matcher.call(line)
            return m
          end
        end
      end

      raise "#{path}: found no matching lines."
    end
1095080
def find_lines(self, linespec):
        """"""
        res = []
        linespec += ".*"
        for line in self.cfg:
            match = re.search(linespec, line)
            if match:
                res.append(match.group(0))
        return res
547964
def hashes_get(versions_file, base_path):
    
    files = versions_file.files_get_all()
    result = {}
    for f in files:
        try:
            result[f] = functions.md5_file(base_path + f)
        except IOError:
            # Not all files exist for all versions.
            pass

    return result
559551
def read_lines lines, options = {}
      table_apply = TableApply.new(options)

      header = table_apply.parse_header(lines[0], options)
      Validator::valid_header?(header, @header)  # compare against older header when merging
      column_index,header = table_apply.column_index(header) # we may rewrite the header
      @header = header if not @header
 
      newheader = @header[1..-1]
      # parse the rest
      prev_line = newheader
      (lines[1..-1]).each_with_index do | line, line_num |
        rowname, data_fields = table_apply.parse_row(line_num, line, newheader, column_index, prev_line, options)
        if data_fields
          @rownames << rowname if not options[:with_rownames] # otherwise doubles rownames
          @rows << data_fields if data_fields
        end
        prev_line = data_fields
      end
      return @rownames,@rows
    end
382474
def text_fields_hash
      @text_fields_hash ||=
        setups.inject({}) do |hash, setup|
          setup.all_text_fields.each do |text_field|
            (hash[text_field.name] ||= Set.new) << text_field
          end
          hash
        end
    end
1241776
def find_lines_with(cls, lines, what):
        
        result = []
        for line in lines:
            if what in line:
                result = result + [line]
        return result
766098
def hash(self):
        '''
        
        '''
        hashed = super(Calculated, self).hash()
        return khash(hashed, self._field_name)
258033
def matches_whitelist(self, matches, whitelist):
        '''
        
        '''
        if not whitelist:
            return matches
        ret_matches = {}
        if not isinstance(whitelist, list):
            whitelist = whitelist.split(',')
        for env in matches:
            for sls in matches[env]:
                if sls in whitelist:
                    ret_matches[env] = ret_matches[env] if env in ret_matches else []
                    ret_matches[env].append(sls)
        return ret_matches
849811
def search(self):
        
        results = self.index.objects.all()
        # reduce the results based on the q field
        if self.cleaned_data.get("q"):
            results = results.query(
                "multi_match",
                query=self.cleaned_data['q'],
                fields=self.get_fields(),
                # this prevents ES from erroring out when a string is used on a
                # number field (for example)
                lenient=True
            )

        return results
514758
def lines(name=nil) #:yield: Line
      # FIXME - this would be much easier if #lines was #each, and there was a
      # different #lines that returned an Enumerator that used #each
      unless block_given?
        map do |f|
          if( !name || f.name?(name) )
            f2l(f)
          else
            nil
          end
        end.compact
      else
        each do |f|
          if( !name || f.name?(name) )
            line = f2l(f)
            if line
              yield line
            end
          end
        end
        self
      end
    end
419680
def extract_key_value(line)
      match = line.match(KEY_VALUE_PATTERN)
      if match
        key = match[1]
        value = match[2]
        [key.strip, value.strip]
      else
        []
      end
    end
653036
def search(lines, pattern):
    
    p = pattern.replace("*", ".*")
    test = re.compile(p)
    result = []
    for l in lines:
        if test.search(l):
            result.append(l)
    return result
142393
def matches_conditions_hash?(subject, conditions = @conditions)
      return true if conditions.empty?

      adapter = model_adapter(subject)

      if adapter.override_conditions_hash_matching?(subject, conditions)
        return adapter.matches_conditions_hash?(subject, conditions)
      end

      matches_all_conditions?(adapter, conditions, subject)
    end
1248623
def matching_lines(re)
      @lines.each_with_index.select{|text, linenum| re.match(text)}.map{
        |i| i[1]+1}
    end
232840
private @CheckForNull HashedToken searchMatch(@Nonnull String plainSecret) {
        byte[] hashedBytes = plainSecretToHashBytes(plainSecret);
        for (HashedToken token : tokenList) {
            if (token.match(hashedBytes)) {
                return token;
            }
        }
        
        return null;
    }
271435
def hash_count(self, line, pound=None):
        
        if pound is None:
            pound = '#'
            
        count = 0
        for c in line:
            if c != pound:
                break
            count += 1

        return count