<commit_before>import json
import os.path
import unittest

from unittest.mock import patch, MagicMock, mock_open

from metacore.database import files

__author__ = 'karatel'


class Node(object):
    """
    Node.
    """

    def __init__(self, file_path):
        with open(file_path, 'r') as config_file:
            config_data = json.load(config_file)

        self.__public_key = config_data['public_key']
        self.__limits = config_data['bandwidth']['limits']
        self.__current_bandwidth = config_data['bandwidth']['current']
        self.__total_bandwidth = config_data['bandwidth']['total']
        self.__capacity = config_data['storage']['capacity']

        self.__file_path = file_path

    def add_incoming(self, volume):
        """
        Increase incoming bandwidth values.
        :param volume: added value in bytes
        :type volume: int
        :return: None
        :rtype: NoneType
        """
        self.__increase_traffic(volume)

    def add_outgoing(self, volume):
        """
        Increase outgoing bandwidth values.
        :param volume: added value in bytes
        :type volume: int
        :return: None
        :rtype: NoneType
        """
        self.__increase_traffic(volume, False)

    @property
    def info(self):
        """
        Aggregate common status info for Node (public key, bandwidth, storage).
        :return: Node status info
        :rtype: dict
        """
        files_size = [_['size'] for _ in files.select().execute()]
        info = {
            'public_key': self.public_key,
            'bandwidth': {
                'current': self.__current_bandwidth,
                'limits': self.__limits,
                'total': self.__total_bandwidth
            },
            'storage': {
                'capacity': self.__capacity,
                'max_file_size': max(files_size, default=0),
                'used': sum(files_size)
            }
        }
        return info

    @property<commit_msg>refactor: adapt max() for Python 3.3<commit_after>import json
import os.path
import unittest

from unittest.mock import patch, MagicMock, mock_open

from metacore.database import files

__author__ = 'karatel'


class Node(object):
    """
    Node.
    """

    def __init__(self, file_path):
        with open(file_path, 'r') as config_file:
            config_data = json.load(config_file)

        self.__public_key = config_data['public_key']
        self.__limits = config_data['bandwidth']['limits']
        self.__current_bandwidth = config_data['bandwidth']['current']
        self.__total_bandwidth = config_data['bandwidth']['total']
        self.__capacity = config_data['storage']['capacity']

        self.__file_path = file_path

    def add_incoming(self, volume):
        """
        Increase incoming bandwidth values.
        :param volume: added value in bytes
        :type volume: int
        :return: None
        :rtype: NoneType
        """
        self.__increase_traffic(volume)

    def add_outgoing(self, volume):
        """
        Increase outgoing bandwidth values.
        :param volume: added value in bytes
        :type volume: int
        :return: None
        :rtype: NoneType
        """
        self.__increase_traffic(volume, False)

    @property
    def info(self):
        """
        Aggregate common status info for Node (public key, bandwidth, storage).
        :return: Node status info
        :rtype: dict
        """
        files_size = [_['size'] for _ in files.select().execute()]
        info = {
            'public_key': self.public_key,
            'bandwidth': {
                'current': self.__current_bandwidth,
                'limits': self.__limits,
                'total': self.__total_bandwidth
            },
            'storage': {
                'capacity': self.__capacity,
                'max_file_size': max(files_size) if files_size else 0,
                'used': sum(files_size)
            }
        }
        return info

    @property
{'fraction_non_alphanumeric': 0.10642018486135399, 'fraction_numerical': 0.0009992505620784412, 'mean_word_length': 2.0564885496183205, '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': '606764', 'n_tokens_mistral': 1128, 'n_tokens_neox': 1089, 'n_words': 269}