<commit_before>#!/usr/bin/env python

from __future__ import absolute_import

import re
import random

from .util import clean_id, pad_id

"""
Functions for working with Brazilian CPF identifiers.

"""

NONDIGIT = re.compile(r'[^0-9]')
CPF_WEIGHTS = [1, 2, 3, 4, 5, 6, 7, 8, 9]


def validate_cpf(cpf, autopad=True):
    """Check whether CPF is valid."""
    cpf = clean_id(cpf)
    # all complete CPF are 11 digits long
    if len(cpf) != 11:
        return validate_cpf(pad_cpf(cpf), False) if autopad else False

    if cpf == '00000000000':
        return False<commit_msg>Ensure CPF is exactly 11 digits<commit_after>#!/usr/bin/env python

from __future__ import absolute_import

import re
import random

from .util import clean_id, pad_id

"""
Functions for working with Brazilian CPF identifiers.

"""

NONDIGIT = re.compile(r'[^0-9]')
CPF_WEIGHTS = [1, 2, 3, 4, 5, 6, 7, 8, 9]


def validate_cpf(cpf, autopad=True):
    """Check whether CPF is valid."""
    cpf = clean_id(cpf)

    # all complete CPF are 11 digits long
    if len(cpf) < 11:
        if not autopad:
            return False
        cpf = pad_cpf(cpf)

    elif len(cpf) > 11:
        return False

    if cpf == '00000000000':
        return False
{'fraction_non_alphanumeric': 0.11447260834014718, 'fraction_numerical': 0.04578904333605887, 'mean_word_length': 3.0936454849498327, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '6670278', 'n_tokens_mistral': 501, 'n_tokens_neox': 438, 'n_words': 141}