<commit_before># -*- coding: utf8 -*-
import arrow


class TranslateBurpuiAPI:
    """
    Translate data from burpui_api to burp_reports
    """

    def __init__(self, clients):
        """
        Initialize vars
        :param: clients list of clients coming from burp_api
        """
        self.clients = clients

    def translate_clients_function(self, data_t):
        """

        :param data_t: list of clients dicts to use for translation
        :return: d_clients dictionary of clients translated to use in burp_reports
        example from clients stats:

        {'client_name':
            { 'b_last'    : 'YYYY-MM-DD HH:mm:ssZZ',
              'b_state'    : 'working/current',
              'b_phase' : 'phase1/phase2',
              'b_date' : 'date(local)',
              'b_time' : 'time(local)'
            }
        }
        """
        d_clients = {}

        for cli in range(len(self.clients)):
            # Get the client dict data from list of clients
            client_data = self.clients[cli]
            client_name = client_data.get(data_t['client_name'])

            # Add server list if it exists
            if client_data.get('server', None):
                if client_name in d_clients:
                    d_clients[client_name]['server'].append(client_data['server'])
                else:
                    d_clients.setdefault(client_name, {})['server'] = [client_data['server']]

            # Translate and define variables:
            # Define a dict with data to clients
            for k, v in data_t.items():

                if k is not 'client_name':
                    # similar and simplified to: d_clients.setdefault(client_name, {})['b_phase'] = b_phase<commit_msg>convert servers to dict, it will avoid duplication if there is a future error in the code.<commit_after># -*- coding: utf8 -*-
import arrow


class TranslateBurpuiAPI:
    """
    Translate data from burpui_api to burp_reports
    """

    def __init__(self, clients):
        """
        Initialize vars
        :param: clients list of clients coming from burp_api
        """
        self.clients = clients

    def translate_clients_function(self, data_t):
        """

        :param data_t: list of clients dicts to use for translation
        :return: d_clients dictionary of clients translated to use in burp_reports
        example from clients stats:

        {'client_name':
            { 'b_last'    : 'YYYY-MM-DD HH:mm:ssZZ',
              'b_state'    : 'working/current',
              'b_phase' : 'phase1/phase2',
              'b_date' : 'date(local)',
              'b_time' : 'time(local)'
            }
        }
        """
        d_clients = {}

        for cli in range(len(self.clients)):
            # Get the client dict data from list of clients
            client_data = self.clients[cli]
            client_name = client_data.get(data_t['client_name'])

            # Add server dict if it exists
            if client_data.get('server', None):
                if client_name in d_clients:
                    d_clients[client_name]['server'].add(client_data['server'])
                else:
                    d_clients.setdefault(client_name, {})['server'] = {client_data['server']}

            # Translate and define variables:
            # Define a dict with data to clients
            for k, v in data_t.items():

                if k is not 'client_name':
                    # similar and simplified to: d_clients.setdefault(client_name, {})['b_phase'] = b_phase
{'fraction_non_alphanumeric': 0.10198300283286119, 'fraction_numerical': 0.0016997167138810198, 'mean_word_length': 1.8660714285714286, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1553930', 'n_tokens_mistral': 1015, 'n_tokens_neox': 979, 'n_words': 277}