'Given the  output from bs1770gain, parse the text and
return a list of dictionaries
containing information about each analyzed file.'

def parse_tool_output(self, text, num_lines):

    out = []
    data = text.decode('utf-8', errors='ignore')
    regex = re.compile(u'(\\s{2,2}\\[\\d+\\/\\d+\\].*?|\\[ALBUM\\].*?)(?=\\s{2,2}\\[\\d+\\/\\d+\\]|\\s{2,2}\\[ALBUM\\]:|done\\.\\s)', (re.DOTALL | re.UNICODE))
    results = re.findall(regex, data)
    for parts in results[0:num_lines]:
        part = parts.split(u'\n')
        if (len(part) == 0):
            self._log.debug(u'bad    tool    output:    {0!r}', text)
            raise ReplayGainError(u'bs1770gain    failed')
        try:
            song = {'file': part[0], 'gain': float(part[1].split('/')[1].split('LU')[0]), 'peak': float(part[2].split('/')[1])}
        except IndexError:
            self._log.info(u'bs1770gain    reports    (faulty    file?):    {}', parts)
            continue
        out.append(Gain(song['gain'], song['peak']))
    return out
