# Path: burp_reports/lib/humanize.py
# def humanize_file_size(size):
#     # It will be used on some prints of text for size representation.
#     import math
#     size = abs(size)
#     if size == 0:
#         return "0B"
#     units = ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB']
#     p = math.floor(math.log(size, 2) / 10)
#     return "%.3f%s" % (size / math.pow(1024, p), units[int(p)])
# 
# Path: burp_reports/defaults/default_data_structure.py
# def default_client_backup_report():
#     empty_backup_report = dict()
#     empty_backup_report = {'totsize': 0,
#                        'efs': {'total': 0, 'deleted': 0, 'unchanged': 0, 'scanned': 0, 'changed': 0, 'new': 0},
#                        'vssheader_enc': {'total': 0, 'deleted': 0, 'unchanged': 0, 'scanned': 0, 'changed': 0, 'new': 0},
#                        'start': '0', 'encrypted': False,
#                        'hardlink': {'total': 0, 'deleted': 0, 'unchanged': 0, 'scanned': 0, 'changed': 0, 'new': 0},
#                        'windows': 'Unknown',
#                        'vssheader': {'total': 0, 'deleted': 0, 'unchanged': 0, 'scanned': 0, 'changed': 0, 'new': 0},
#                         'softlink': {'total': 0, 'deleted': 0, 'unchanged': 0, 'scanned': 0, 'changed': 0, 'new': 0},
#                        'files': {'total': 0, 'deleted': 0, 'unchanged': 0, 'scanned': 0, 'changed': 0, 'new': 0},
#                        'end': '0',
#                        'meta_enc': {'total': 0, 'deleted': 0, 'unchanged': 0, 'scanned': 0, 'changed': 0, 'new': 0},
#                        'duration': 0, 'number': 0,
#                        'meta': {'total': 0, 'deleted': 0, 'unchanged': 0, 'scanned': 0, 'changed': 0, 'new': 0},
#                        'special': {'total': 0, 'deleted': 0, 'unchanged': 0, 'scanned': 0, 'changed': 0, 'new': 0},
#                        'dir': {'total': 0, 'deleted': 0, 'unchanged': 0, 'scanned': 0, 'changed': 0, 'new': 0},
#                        'vssfooter_enc': {'total': 0, 'deleted': 0, 'unchanged': 0, 'scanned': 0, 'changed': 0, 'new': 0},
#                        'received': 0,
#                        'vssfooter': {'total': 0, 'deleted': 0, 'unchanged': 0, 'scanned': 0, 'changed': 0, 'new': 0},
#                        'files_enc': {'total': 0, 'deleted': 0, 'unchanged': 0, 'scanned': 0, 'changed': 0, 'new': 0}
#                        }
#     
#     return empty_backup_report


from datetime import datetime
from .humanize import humanize_file_size
from ..defaults.default_data_structure import default_client_backup_report
import os
        :return:
        """
        # Additional details to add on headers and clients to the end of the strings
        headers_text = ' {:{}.{}} '.format('Duration', clength, clength)
        headers_text += ' {:{}.{}} '.format('Size', clength, clength)
        headers_text += ' {:{}.{}} '.format('Received', clength, clength)

        return headers_text

    def _txt_client_details(self, client_data, clength):
        """

        :param client_data: dict in burp reports format only for the client you want to get additional details
        :param clength: number of spaces to use to justify and format columns
        :return:
        """
        # Additional details to add on headers and clients to the end of the strings
        # Additional calculated added data
        # Look into client_data['backup_report']['duration']
        s = int(client_data.get('backup_report', self.empty_backup_report).get('duration', 0))
        duration = str('{:02}:{:02}:{:02}'.format(s // 3600, s % 3600 // 60, s % 60))
        # Look into client_data['backup_report']['totsize']
        totsize = int(client_data.get('backup_report', self.empty_backup_report).get('totsize', 0))

        # Look into client_data['backup_report']['received']
        received = int(client_data.get('backup_report', self.empty_backup_report).get('received', 0))

        # Additional calculated added data
        client_text = ' {:^{}} '.format(duration, clength, clength)
        client_text += ' {:<{}} '.format(humanize_file_size(totsize), clength)

# Path: burp_reports/lib/humanize.py
# def humanize_file_size(size):
#     # It will be used on some prints of text for size representation.
#     import math
#     size = abs(size)
#     if size == 0:
#         return "0B"
#     units = ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB']
#     p = math.floor(math.log(size, 2) / 10)
#     return "%.3f%s" % (size / math.pow(1024, p), units[int(p)])
# 
# Path: burp_reports/defaults/default_data_structure.py
# def default_client_backup_report():
#     empty_backup_report = dict()
#     empty_backup_report = {'totsize': 0,
#                        'efs': {'total': 0, 'deleted': 0, 'unchanged': 0, 'scanned': 0, 'changed': 0, 'new': 0},
#                        'vssheader_enc': {'total': 0, 'deleted': 0, 'unchanged': 0, 'scanned': 0, 'changed': 0, 'new': 0},
#                        'start': '0', 'encrypted': False,
#                        'hardlink': {'total': 0, 'deleted': 0, 'unchanged': 0, 'scanned': 0, 'changed': 0, 'new': 0},
#                        'windows': 'Unknown',
#                        'vssheader': {'total': 0, 'deleted': 0, 'unchanged': 0, 'scanned': 0, 'changed': 0, 'new': 0},
#                         'softlink': {'total': 0, 'deleted': 0, 'unchanged': 0, 'scanned': 0, 'changed': 0, 'new': 0},
#                        'files': {'total': 0, 'deleted': 0, 'unchanged': 0, 'scanned': 0, 'changed': 0, 'new': 0},
#                        'end': '0',
#                        'meta_enc': {'total': 0, 'deleted': 0, 'unchanged': 0, 'scanned': 0, 'changed': 0, 'new': 0},
#                        'duration': 0, 'number': 0,
#                        'meta': {'total': 0, 'deleted': 0, 'unchanged': 0, 'scanned': 0, 'changed': 0, 'new': 0},
#                        'special': {'total': 0, 'deleted': 0, 'unchanged': 0, 'scanned': 0, 'changed': 0, 'new': 0},
#                        'dir': {'total': 0, 'deleted': 0, 'unchanged': 0, 'scanned': 0, 'changed': 0, 'new': 0},
#                        'vssfooter_enc': {'total': 0, 'deleted': 0, 'unchanged': 0, 'scanned': 0, 'changed': 0, 'new': 0},
#                        'received': 0,
#                        'vssfooter': {'total': 0, 'deleted': 0, 'unchanged': 0, 'scanned': 0, 'changed': 0, 'new': 0},
#                        'files_enc': {'total': 0, 'deleted': 0, 'unchanged': 0, 'scanned': 0, 'changed': 0, 'new': 0}
#                        }
#     
#     return empty_backup_report


# Path: burp_reports/lib/txt.py
from datetime import datetime
from .humanize import humanize_file_size
from ..defaults.default_data_structure import default_client_backup_report
import os

        :return:
        """
        # Additional details to add on headers and clients to the end of the strings
        headers_text = ' {:{}.{}} '.format('Duration', clength, clength)
        headers_text += ' {:{}.{}} '.format('Size', clength, clength)
        headers_text += ' {:{}.{}} '.format('Received', clength, clength)

        return headers_text

    def _txt_client_details(self, client_data, clength):
        """

        :param client_data: dict in burp reports format only for the client you want to get additional details
        :param clength: number of spaces to use to justify and format columns
        :return:
        """
        # Additional details to add on headers and clients to the end of the strings
        # Additional calculated added data
        # Look into client_data['backup_report']['duration']
        s = int(client_data.get('backup_report', self.empty_backup_report).get('duration', 0))
        duration = str('{:02}:{:02}:{:02}'.format(s // 3600, s % 3600 // 60, s % 60))
        # Look into client_data['backup_report']['totsize']
        totsize = int(client_data.get('backup_report', self.empty_backup_report).get('totsize', 0))

        # Look into client_data['backup_report']['received']
        received = int(client_data.get('backup_report', self.empty_backup_report).get('received', 0))

        # Additional calculated added data
        client_text = ' {:^{}} '.format(duration, clength, clength)
        client_text += ' {:<{}} '.format(humanize_file_size(totsize), clength)

        client_text += ' {:<{}} '.format(humanize_file_size(received), clength)