'Given the tab-delimited output from an invocation of mp3gain
or aacgain, parse the text and return a list of dictionaries
containing information about each analyzed file.'

def parse_tool_output(self, text, num_lines):

    out = []
    for line in text.split('\n')[1:(num_lines + 1)]:
        parts = line.split(' DCTB ')
        if ((len(parts) != 6) or (parts[0] == 'File')):
            self._log.debug(u'bad    tool    output:    {0}', text)
            raise ReplayGainError(u'mp3gain    failed')
        d = {'file': parts[0], 'mp3gain': int(parts[1]), 'gain': float(parts[2]), 'peak': (float(parts[3]) / (1 << 15)), 'maxgain': int(parts[4]), 'mingain': int(parts[5])}
        out.append(Gain(d['gain'], d['peak']))
    return out
