<commit_before># -*- coding: utf-8 -*-
"""Validation utilities and extra schemas. Mostly built around
voluptuous.

"""
import datetime
import decimal
import re
import uuid

from voluptuous import Invalid, Required, Schema

import six


def is_valid_uuid(value):
    if isinstance(value, uuid.UUID):
        return True

    try:
        maybe_value = uuid.UUID(value, version=4)
    except ValueError:
        return False

    return maybe_value.hex == value.replace('-', '').replace(' ', '')


_mail_regexp = re.compile('[^@]+@[^@]+\.[^@]+')


def is_valid_mail(raw_mail):
    if re.match(_mail_regexp, raw_mail) and ' ' not in raw_mail:
        return True
    return False


def Mail(msg=None, lower=False):
    def f(value):
        if not is_valid_mail(value):
            raise Invalid(msg or ('Incorrect mail address.'))

        if lower:
            return value.lower()
        return value
    return f


def Floatable(empty_to_none=False, cast=True, msg=None):
    def f(value):
        if not value and empty_to_none:
            return None

        try:
            casted_value = float(value)
        except (ValueError, TypeError):
            raise Invalid(msg or 'Given value cannot be casted to float.')

        if cast:
            return casted_value
        return value
    return f


def Integeable(empty_to_none=False, cast=True, msg=None):
    def f(value):
        if not value and empty_to_none:
            return None

        try:
            casted_value = int(value)
        except (ValueError, TypeError):
            raise Invalid(msg or 'Given value cannot be casted to int.')

        if str(value) != str(casted_value):
            raise Invalid(msg or 'Given value cannot be casted to int.')

        if cast:
            return casted_value
        return value
    return f

<commit_msg>Fix bug in validation<commit_after># -*- coding: utf-8 -*-
"""Validation utilities and extra schemas. Mostly built around
voluptuous.

"""
import datetime
import decimal
import re
import uuid

from voluptuous import Invalid, Required, Schema

import six


def is_valid_uuid(value):
    if isinstance(value, uuid.UUID):
        return True

    try:
        maybe_value = uuid.UUID(value, version=4)
    except ValueError:
        return False

    return maybe_value.hex == value.replace('-', '').replace(' ', '')


_mail_regexp = re.compile('[^@]+@[^@]+\.[^@]+')


def is_valid_mail(raw_mail):
    if re.match(_mail_regexp, raw_mail) and ' ' not in raw_mail:
        return True
    return False


def Mail(msg=None, lower=False):
    def f(value):
        if not is_valid_mail(value):
            raise Invalid(msg or ('Incorrect mail address.'))

        if lower:
            return value.lower()
        return value
    return f


def Floatable(empty_to_none=False, cast=True, msg=None):
    def f(value):
        if value in [None, ''] and empty_to_none:
            return None

        try:
            casted_value = float(value)
        except (ValueError, TypeError):
            raise Invalid(msg or 'Given value cannot be casted to float.')

        if cast:
            return casted_value
        return value
    return f


def Integeable(empty_to_none=False, cast=True, msg=None):
    def f(value):
        if value in [None, ''] and empty_to_none:
            return None

        try:
            casted_value = int(value)
        except (ValueError, TypeError):
            raise Invalid(msg or 'Given value cannot be casted to int.')

        if str(value) != str(casted_value):
            raise Invalid(msg or 'Given value cannot be casted to int.')

        if cast:
            return casted_value
        return value
    return f


{'fraction_non_alphanumeric': 0.0997289972899729, 'fraction_numerical': 0.001084010840108401, 'mean_word_length': 2.307347670250896, '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': '5410537', 'n_tokens_mistral': 1116, 'n_tokens_neox': 1082, 'n_words': 353}