<commit_before>"""
====
ralc
====

Rate Calculator for multiplicate spent hours and rate per hour to find out how
many money you earned.

"""

from __future__ import print_function

import sys

from decimal import ROUND_UP, Decimal, DecimalException


__author__ = '<NAME>'
__license__ = 'BSD License'
__script__ = 'ralc'
__version__ = '0.1'


IS_PY3 = sys.version_info[0] == 3
ROUNDER = Decimal('.01')

integer_types = (int, ) if IS_PY3 else (int, long)  # noqa
text_types = (bytes, str) if IS_PY3 else (basestring, )  # noqa


class ValidationError(ValueError):
    """
    Validation error class.
    """


def calc(hours, rate):
    """
    Multiplicate spent hours with rate per hour to find out how many money has
    been earned.
    """
    return to_decimal(validate_hours(hours) * to_decimal(rate))


def main(*args):
    """
    Parse command line arguments and make calulcaiton if arguments is valid.
    """
    # Parse command line arguments
    args = parse_args(args or sys.argv[1:])

    # Make calculation and print result
    print('>', args.hours, 'x', args.rate, '=', calc(args.hours, args.rate))
    return False


def parse_args(args):
    """
    Parse command line arguments.
    """
    from argparse import ArgumentParser

    def rate_type(value):
        """
        Raise decimal exceptions as value errors.
        """
        try:
            return to_decimal(value)
        except DecimalException as err:
            raise ValueError(str(err))

    hours_type = validate_hours
    hours_type.__name__ = 'hours'
    rate_type.__name__ = 'rate'

    parser = ArgumentParser(description='Rate Calculator')
    parser.add_argument(
        'hours', help='Spent hours, e.g.: "30", "120:40", "10:55:30"',
        metavar='HH[:MM[:SS]]', type=hours_type
    )
    parser.add_argument(
        'rate', help='Rate per hour. Should be decimal value.',
        metavar='RATE', type=rate_type
    )

    return parser.parse_args(args)<commit_msg>Add version argument to parser.<commit_after>"""
====
ralc
====

Rate Calculator for multiplicate spent hours and rate per hour to find out how
many money you earned.

"""

from __future__ import print_function

import sys

from decimal import ROUND_UP, Decimal, DecimalException


__author__ = '<NAME>'
__license__ = 'BSD License'
__script__ = 'ralc'
__version__ = '0.1'


IS_PY3 = sys.version_info[0] == 3
ROUNDER = Decimal('.01')

integer_types = (int, ) if IS_PY3 else (int, long)  # noqa
text_types = (bytes, str) if IS_PY3 else (basestring, )  # noqa


class ValidationError(ValueError):
    """
    Validation error class.
    """


def calc(hours, rate):
    """
    Multiplicate spent hours with rate per hour to find out how many money has
    been earned.
    """
    return to_decimal(validate_hours(hours) * to_decimal(rate))


def main(*args):
    """
    Parse command line arguments and make calulcaiton if arguments is valid.
    """
    # Parse command line arguments
    args = parse_args(args or sys.argv[1:])

    # Make calculation and print result
    print('>', args.hours, 'x', args.rate, '=', calc(args.hours, args.rate))
    return False


def parse_args(args):
    """
    Parse command line arguments.
    """
    from argparse import ArgumentParser

    def rate_type(value):
        """
        Raise decimal exceptions as value errors.
        """
        try:
            return to_decimal(value)
        except DecimalException as err:
            raise ValueError(str(err))

    hours_type = validate_hours
    hours_type.__name__ = 'hours'
    rate_type.__name__ = 'rate'

    parser = ArgumentParser(description='Rate Calculator')
    parser.add_argument(
        'hours', help='Spent hours, e.g.: "30", "120:40", "10:55:30"',
        metavar='HH[:MM[:SS]]', type=hours_type
    )
    parser.add_argument(
        'rate', help='Rate per hour. Should be decimal value.',
        metavar='RATE', type=rate_type
    )
    parser.add_argument(
        '--version', action='version',
        version='%(prog)s {0}'.format(__version__)
    )

    return parser.parse_args(args)
{'fraction_non_alphanumeric': 0.11969585479519254, 'fraction_numerical': 0.011528084375766495, 'mean_word_length': 3.0617529880478087, 'pattern_counts': {'":': 0, '<': 5, '<?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': '6548358', 'n_tokens_mistral': 1328, 'n_tokens_neox': 1260, 'n_words': 372}