<commit_before>"""
Created on 16 Apr 2018

@author: <NAME> (<EMAIL>)

http://code.activestate.com/recipes/577972-disk-usage/

JSON example:
{"time": "2017-05-29T12:40:58.619+01:00", "up": {"days": 1, "hours": 19, "minutes": 34, "seconds": 0},
"total": 0, "used": {"av1": 0.66, "av5": 0.65, "av15": 0.6}}
"""

from collections import OrderedDict

from scs_core.data.json import JSONable


# --------------------------------------------------------------------------------------------------------------------

class DiskUsageDatum(JSONable):
    """
    classdocs
    """

    # ----------------------------------------------------------------------------------------------------------------

    @classmethod
    def construct_from_jdict(cls, jdict):
        if not jdict:
            return None

        free = jdict.get('free')
        total = jdict.get('total')
        used = jdict.get('used')

        return DiskUsageDatum(free, total, used)


    # ----------------------------------------------------------------------------------------------------------------

    def __init__(self, free, total, used):
        """
        Constructor
        """
        self.__free = int(free)                     # int
        self.__total = int(total)                   # int
        self.__used = int(used)                     # int


    # ----------------------------------------------------------------------------------------------------------------

    def as_json(self):
        jdict = OrderedDict()

        jdict['free'] = self.free
        jdict['total'] = self.total
        jdict['used'] = self.used

        return jdict


    # ----------------------------------------------------------------------------------------------------------------

    @property
    def free(self):
        return self.__free


    @property
    def total(self):
        return self.__total


    @property
    def used(self):
        return self.__used


    # ----------------------------------------------------------------------------------------------------------------

    def __str__(self, *args, **kwargs):
        return "DiskUsageDatum:{free:%s, total:%s, used:%s}" %  (self.free, self.total, self.used)

<commit_msg>Added disk_usage(..) method to node.<commit_after>"""
Created on 16 Apr 2018

@author: <NAME> (<EMAIL>)

JSON example:
{"free": 61745299456, "total": 61749133312, "used": 3833856}
"""

from collections import OrderedDict

from scs_core.data.json import JSONable


# --------------------------------------------------------------------------------------------------------------------

class DiskUsageDatum(JSONable):
    """
    classdocs
    """

    # ----------------------------------------------------------------------------------------------------------------

    @classmethod
    def construct_from_jdict(cls, jdict):
        if not jdict:
            return None

        free = jdict.get('free')
        total = jdict.get('total')
        used = jdict.get('used')

        return DiskUsageDatum(free, total, used)


    # ----------------------------------------------------------------------------------------------------------------

    def __init__(self, free, total, used):
        """
        Constructor
        """
        self.__free = int(free)                     # int
        self.__total = int(total)                   # int
        self.__used = int(used)                     # int


    # ----------------------------------------------------------------------------------------------------------------

    def as_json(self):
        jdict = OrderedDict()

        jdict['free'] = self.free
        jdict['total'] = self.total
        jdict['used'] = self.used

        return jdict


    # ----------------------------------------------------------------------------------------------------------------

    @property
    def free(self):
        return self.__free


    @property
    def total(self):
        return self.__total


    @property
    def used(self):
        return self.__used


    # ----------------------------------------------------------------------------------------------------------------

    def __str__(self, *args, **kwargs):
        return "DiskUsageDatum:{free:%s, total:%s, used:%s}" %  (self.free, self.total, self.used)
{'fraction_non_alphanumeric': 0.4083294555607259, 'fraction_numerical': 0.020241973010702654, 'mean_word_length': 0.8223823654090716, 'pattern_counts': {'":': 14, '<': 7, '<?xml version=': 0, '>': 7, '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': '5883546', 'n_tokens_mistral': 1057, 'n_tokens_neox': 935, 'n_words': 219}