<commit_before>#coding: utf-8
""" base.py from package velat

    Author and Copyright © <NAME> <feth ×AT× tuttu.info>, 2010-2011

    This file is part of velat-core.

    the program velat-core is free software: you can redistribute it and/or
    modify it under the terms of the GNU Affero General Public License as
    published by the Free Software Foundation, either version 3 of the
    License, or (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Affero General Public License for more details.

    You should have received a copy of the GNU Affero General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.


    Here be basic types as needed by velat, a simple expenses calculator
"""

from decimal import Decimal


def _to_decimal(value):
    """
    given a Decimal, a string, a float or whatever, tries and
    returns a Decimal. For maximum precision, give me a string like
    "2.4567897654"
    """
    if type(value) is Decimal:
        return value
    elif type(value) is float:
        value = '%.5f' % value

    value = Decimal(value)

    return value


class Person(object):
    """
    a person is an object to which credits and debts can be assigned
    """

    def __init__(self, name, information=""):
        """
        name: string
        """
        self.name = name
        self.information = information

    def __repr__(self):
        """
        object like repr. Maybe should contain more than just the name.
        """
        return """<Person "%s">""" % self.name

    def _totalpaid(self):
        """
        How much this person paid
        """
        #FIXME: stub
        return 42
    totalpaid = property(fget=_totalpaid)

    def _totalowed(self):
        """
        How much this person owes
        """
        #FIXME: stub
        return 43
    totalowed = property(fget=_totalowed)

    def __cmp__(self, other):
        return cmp(self.name, other.name)<commit_msg>convenience data in Person. keep commit?<commit_after>#coding: utf-8
""" base.py from package velat

    Author and Copyright © <NAME> <feth ×AT× tuttu.info>, 2010-2011

    This file is part of velat-core.

    the program velat-core is free software: you can redistribute it and/or
    modify it under the terms of the GNU Affero General Public License as
    published by the Free Software Foundation, either version 3 of the
    License, or (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Affero General Public License for more details.

    You should have received a copy of the GNU Affero General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.


    Here be basic types as needed by velat, a simple expenses calculator
"""

from decimal import Decimal


def _to_decimal(value):
    """
    given a Decimal, a string, a float or whatever, tries and
    returns a Decimal. For maximum precision, give me a string like
    "2.4567897654"
    """
    if type(value) is Decimal:
        return value
    elif type(value) is float:
        value = '%.5f' % value

    value = Decimal(value)

    return value


class Person(object):
    """
    a person is an object to which credits and debts can be assigned
    """

    SECTIONS = 'name', 'information', 'balance', 'total paid'

    def __init__(self, name, information=""):
        """
        name: string
        """
        self.name = name
        self.information = information

    def __repr__(self):
        """
        object like repr. Maybe should contain more than just the name.
        """
        return """<Person "%s">""" % self.name

    def _totalpaid(self):
        """
        How much this person paid
        """
        #FIXME: stub
        return 42
    totalpaid = property(fget=_totalpaid)

    def _totalowed(self):
        """
        How much this person owes
        """
        #FIXME: stub
        return 43
    totalowed = property(fget=_totalowed)

    def __cmp__(self, other):
        return cmp(self.name, other.name)

    def __getitem__(self, value):
        if value == 0:
            return self.name
        if value == 1:
            return self.information
        if value == 2:
            return self.totalowed
        if value == 3:
            return self.totalpaid
        raise ValueError('%s is not in 0..3' % value)
{'fraction_non_alphanumeric': 0.0821337849280271, 'fraction_numerical': 0.012277730736663843, 'mean_word_length': 2.3392226148409896, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3251971', 'n_tokens_mistral': 1348, 'n_tokens_neox': 1265, 'n_words': 552}