

def _parse_backup_log(self, filemap, number, client=None, agent=None):
    'The :func:`burpui.misc.backend.burp1.Burp._parse_backup_log` function\n        is used to parse the log.gz of a given backup and returns a dict\n        containing different stats used to render the charts in the reporting\n        view.\n\n        :param filemap: List representing the content of the log file\n        :type filemap: list\n\n        :param number: Backup number to work on\n        :type number: int\n\n        :param client: Client name to work on\n        :type client: str\n\n        :param agent: What server to ask (only in multi-agent mode)\n        :type agent: str\n\n        :returns: Dict containing the backup log\n        '
    lookup_easy = {
        'start': '^Start time: (.+)$',
        'end': '^\\s*End time: (.+)$',
        'duration': '^Time taken: (.+)$',
        'totsize': '^\\s*Bytes in backup:\\s+(\\d+)',
        'received': '^\\s*Bytes received:\\s+(\\d+)',
    }
    lookup_complex = {
        'files': '^\\s*Files:?\\s+([\\d\\s]+)\\s+\\|\\s+(\\d+)$',
        'files_enc': '^\\s*Files \\(encrypted\\):?\\s+([\\d\\s]+)\\s+\\|\\s+(\\d+)$',
        'dir': '^\\s*Directories:?\\s+([\\d\\s]+)\\s+\\|\\s+(\\d+)$',
        'softlink': '^\\s*Soft links:?\\s+([\\d\\s]+)\\s+\\|\\s+(\\d+)$',
        'hardlink': '^\\s*Hard links:?\\s+([\\d\\s]+)\\s+\\|\\s+(\\d+)$',
        'meta': '^\\s*Meta data:?\\s+([\\d\\s]+)\\s+\\|\\s+(\\d+)$',
        'meta_enc': '^\\s*Meta data\\(enc\\):?\\s+([\\d\\s]+)\\s+\\|\\s+(\\d+)$',
        'special': '^\\s*Special files:?\\s+([\\d\\s]+)\\s+\\|\\s+(\\d+)$',
        'efs': '^\\s*EFS files:?\\s+([\\d\\s]+)\\s+\\|\\s+(\\d+)$',
        'vssheader': '^\\s*VSS headers:?\\s+([\\d\\s]+)\\s+\\|\\s+(\\d+)$',
        'vssheader_enc': '^\\s*VSS headers \\(enc\\):?\\s+([\\d\\s]+)\\s+\\|\\s+(\\d+)$',
        'vssfooter': '^\\s*VSS footers:?\\s+([\\d\\s]+)\\s+\\|\\s+(\\d+)$',
        'vssfooter_enc': '^\\s*VSS footers \\(enc\\):?\\s+([\\d\\s]+)\\s+\\|\\s+(\\d+)$',
        'total': '^\\s*Grand total:?\\s+([\\d\\s]+)\\s+\\|\\s+(\\d+)$',
    }
    _ = agent
    backup = {
        'windows': 'false',
        'number': int(number),
    }
    if (client is not None):
        backup['name'] = client
    useful = False
    for line in filemap:
        if re.match('^\\d{4}-\\d{2}-\\d{2} (\\d{2}:){3} \\w+\\[\\d+\\] Client is Windows$', line):
            backup['windows'] = 'true'
        elif ((not useful) and (not re.match('^-+$', line))):
            continue
        elif (useful and re.match('^-+$', line)):
            useful = False
            continue
        elif re.match('^-+$', line):
            useful = True
            continue
        found = False
        for (key, regex) in iteritems(lookup_easy):
            reg = re.search(regex, line)
            if reg:
                found = True
                if (key in ['start', 'end']):
                    backup[key] = int(time.mktime(datetime.datetime.strptime(reg.group(1), '%Y-%m-%d %H:%M:%S').timetuple()))
                elif (key == 'duration'):
                    tmp = reg.group(1).split(':')
                    i.reverse()
                    fields = ([0] * 4)
                    for (i, val) in enumerate(tmp):
                        fields[i] = int(val)
                    seconds = 0
                    seconds += fields[0]
                    seconds += (fields[1] * 60)
                    seconds += (fields[2] * (60 * 60))
                    seconds += (fields[3] * ((60 * 60) * 24))
                    backup[key] = seconds
                else:
                    backup[key] = int(reg.group(1))
                break
        if found:
            continue
        for (key, regex) in iteritems(lookup_complex):
            reg = re.search(regex, line)
            if reg:
                spl = re.split('\\s+', reg.group(1))
                if (len(spl) < 5):
                    return {
                        
                    }
                backup[key] = {
                    'new': int(spl[0]),
                    'changed': int(spl[1]),
                    'unchanged': int(spl[2]),
                    'deleted': int(spl[3]),
                    'total': int(spl[4]),
                    'scanned': int(reg.group(2)),
                }
                break
    return backup

dataset/ETHPy150Open ziirish/burp-ui/burpui/misc/backend/burp1.py Burp._parse_backup_log/VarMisuse@378/1252 `tmp`->`i`