<commit_before>import random
import lipsum
import datetime
import base64
from decimal import getcontext, Decimal
getcontext().prec = 7
from django.contrib.localflavor.us.us_states import STATE_CHOICES

class QiFactory:
    @classmethod
    def rand_int(cls, start=0, end=100):
        return random.randint(start,end)

    @classmethod
    def rand_str(cls, length=None):
        # from http://stackoverflow.com/questions/785058/random-strings-in-python-2-6-is-this-ok
        if not length:
            length = cls.rand_int(end=10)
        nbits = length * 6 + 1
        bits = random.getrandbits(nbits)
        uc = u"%0x" % bits
        newlen = int(len(uc) / 2) * 2
        ba = bytearray.fromhex(uc[:newlen])
        return base64.urlsafe_b64encode(str(ba))[:length]

    @classmethod
    def rand_text(cls):
        g = lipsum.Generator()
        return g.generate_paragraph()

    @classmethod
    def rand_bool(cls):
        return cls.rand_int(0,1) == 0

    @classmethod
    def rand_name(cls):
        return RANDOM_NAME_SOURCE[cls.rand_int(0,len(RANDOM_NAME_SOURCE)-1)]

    @classmethod
    def rand_plant_name(cls):
        return RANDOM_PLANT_NAME_SOURCE[cls.rand_int(0,len(RANDOM_PLANT_NAME_SOURCE)-1)]

    @classmethod
    def rand_street_suffix(cls):
        return RANDOM_STREET_SUFFIX_SOURCE[cls.rand_int(0,len(RANDOM_STREET_SUFFIX_SOURCE)-1)]

    @classmethod
    def rand_date(cls, start_year=1900, end_year=2011):
        return datetime.date(year=cls.rand_int(start_year,end_year),month=cls.rand_int(1,12), day=cls.rand_int(1,28))

    @classmethod
    def rand_currency(cls, start=0, end=100):
        return Decimal(cls.rand_int(start=start*100,end=end*100))/100

    @classmethod
    def rand_domain(cls):
        return RANDOM_EMAIL_DOMAINS[cls.rand_int(0,len(RANDOM_EMAIL_DOMAINS)-1)]
    
    @classmethod
    def rand_us_state(cls):
        return STATE_CHOICES[cls.rand_int(0,len(STATE_CHOICES)-1)][0]

    @classmethod
    def valid_test_cc_number(cls):
        return "4242424242424242"

    @classmethod
    def invalid_test_cc_number(cls):
        return "4242424242424241"


RANDOM_NAME_SOURCE = ["Atricia", "Linda", "Barbara", "Elizabeth", "Jennifer", 
"Maria", "Susan", "Margaret", "Dorothy", "Lisa", "Nancy", "Karen", "Betty", 
"Helen", "Sandra", "Donna", "Carol", "Ruth", "Sharon", "Michelle", "Laura", 
"Sarah", "Kimberly", "Deborah", "Jessica", "Shirley", "Cynthia", "Angela", 
"Melissa", "Brenda", "Amy", "Anna", "Rebecca", "Virginia", "Kathleen", 
"Pamela", "Martha", "Debra", "Amanda", "Stephanie", "Carolyn", "Christine", 
"Marie", "Janet", "Catherine", "Frances", "Ann", "Joyce", "Diane", "Alice", 
"Julie", "Heather", "Teresa", "Doris", "Gloria", "Evelyn", "Jean", "Cheryl", 
"Mildred", "Katherine", "Joan", "Ashley", "Judith", "Rose", "Janice", "Kelly",
"Nicole", "Judy", "Christina", "Kathy", "Theresa", "Beverly", "Denise",
"Tammy", "Irene", "Jane", "Lori", "Rachel", "Marilyn", "Andrea", "Kathryn", 
"Louise", "Sara", "Anne", "Jacquelin", "Wanda", "Bonnie", "Julia", "Ruby", 
"Lois", "Tina", "Phyllis", "Norma", "Paula", "Diana", "Annie", "Lillian", 
"Emily", "Robin", "Peggy", "Crystal", "Gladys", "Rita", "Dawn", "Connie", 
"Florence", "Tracy", "Edna", "Tiffany", "Carmen", "Rosa", "Cindy", "Grace", 
"Wendy", "Victoria", "Edith", "Kim", "Sherry", "Sylvia", "Josephine", "Thelma", 
"Shannon", "Sheila", "Ethel", "Ellen", "Elaine", "Marjorie", "Carrie", 
"Charlotte", "Monica", "Esther", "Pauline", "Emma", "Juanita", "Anita", 
"Rhonda", "Hazel", "Amber", "Eva", "Debbie", "April", "Leslie", "Clara", 
"Lucille", "Jamie", "Joanne", "Eleanor", "Valerie", "Danielle", "Megan", 
"Alicia", "Suzanne", "Michele", "Gail", "Bertha", "Darlene", "Veronica", 
"Jill", "Erin", "Geraldine", "Lauren", "Cathy", "Joann", "Lorraine", "Lynn", 
"Sally", "Regina", "Erica", "Beatrice", "Dolores", "Bernice", "Audrey", 
"Yvonne", "Annette", "June", "Samantha", "Marion", "Dana", "Stacy", "Ana", 
"Renee", "Ida", "Vivian", "Roberta", "Holly", "Brittany", "Melanie", 
"Loretta", "Yolanda", "Jeanette", "Laurie", "Katie", "Kristen", "Vanessa",<commit_msg>added a nicer cc helper method<commit_after>import random
import lipsum
import datetime
import base64
from decimal import getcontext, Decimal
getcontext().prec = 7
from django.contrib.localflavor.us.us_states import STATE_CHOICES

class QiFactory:
    @classmethod
    def rand_int(cls, start=0, end=100):
        return random.randint(start,end)

    @classmethod
    def rand_str(cls, length=None):
        # from http://stackoverflow.com/questions/785058/random-strings-in-python-2-6-is-this-ok
        if not length:
            length = cls.rand_int(end=10)
        nbits = length * 6 + 1
        bits = random.getrandbits(nbits)
        uc = u"%0x" % bits
        newlen = int(len(uc) / 2) * 2
        ba = bytearray.fromhex(uc[:newlen])
        return base64.urlsafe_b64encode(str(ba))[:length]

    @classmethod
    def rand_text(cls):
        g = lipsum.Generator()
        return g.generate_paragraph()

    @classmethod
    def rand_bool(cls):
        return cls.rand_int(0,1) == 0

    @classmethod
    def rand_name(cls):
        return RANDOM_NAME_SOURCE[cls.rand_int(0,len(RANDOM_NAME_SOURCE)-1)]

    @classmethod
    def rand_plant_name(cls):
        return RANDOM_PLANT_NAME_SOURCE[cls.rand_int(0,len(RANDOM_PLANT_NAME_SOURCE)-1)]

    @classmethod
    def rand_street_suffix(cls):
        return RANDOM_STREET_SUFFIX_SOURCE[cls.rand_int(0,len(RANDOM_STREET_SUFFIX_SOURCE)-1)]

    @classmethod
    def rand_date(cls, start_year=1900, end_year=2011):
        return datetime.date(year=cls.rand_int(start_year,end_year),month=cls.rand_int(1,12), day=cls.rand_int(1,28))

    @classmethod
    def rand_currency(cls, start=0, end=100):
        return Decimal(cls.rand_int(start=start*100,end=end*100))/100

    @classmethod
    def rand_domain(cls):
        return RANDOM_EMAIL_DOMAINS[cls.rand_int(0,len(RANDOM_EMAIL_DOMAINS)-1)]
    
    @classmethod
    def rand_us_state(cls):
        return STATE_CHOICES[cls.rand_int(0,len(STATE_CHOICES)-1)][0]

    @classmethod
    def valid_test_cc_number(cls):
        return "4242424242424242"

    @classmethod
    def invalid_test_cc_number(cls):
        return "4242424242424241"

    @classmethod
    def test_cc_number(cls, valid=True):
        if valid:
            return cls.valid_test_cc_number()
        else:
            return cls.invalid_test_cc_number()




RANDOM_NAME_SOURCE = ["Atricia", "Linda", "Barbara", "Elizabeth", "Jennifer", 
"Maria", "Susan", "Margaret", "Dorothy", "Lisa", "Nancy", "Karen", "Betty", 
"Helen", "Sandra", "Donna", "Carol", "Ruth", "Sharon", "Michelle", "Laura", 
"Sarah", "Kimberly", "Deborah", "Jessica", "Shirley", "Cynthia", "Angela", 
"Melissa", "Brenda", "Amy", "Anna", "Rebecca", "Virginia", "Kathleen", 
"Pamela", "Martha", "Debra", "Amanda", "Stephanie", "Carolyn", "Christine", 
"Marie", "Janet", "Catherine", "Frances", "Ann", "Joyce", "Diane", "Alice", 
"Julie", "Heather", "Teresa", "Doris", "Gloria", "Evelyn", "Jean", "Cheryl", 
"Mildred", "Katherine", "Joan", "Ashley", "Judith", "Rose", "Janice", "Kelly",
"Nicole", "Judy", "Christina", "Kathy", "Theresa", "Beverly", "Denise",
"Tammy", "Irene", "Jane", "Lori", "Rachel", "Marilyn", "Andrea", "Kathryn", 
"Louise", "Sara", "Anne", "Jacquelin", "Wanda", "Bonnie", "Julia", "Ruby", 
"Lois", "Tina", "Phyllis", "Norma", "Paula", "Diana", "Annie", "Lillian", 
"Emily", "Robin", "Peggy", "Crystal", "Gladys", "Rita", "Dawn", "Connie", 
"Florence", "Tracy", "Edna", "Tiffany", "Carmen", "Rosa", "Cindy", "Grace", 
"Wendy", "Victoria", "Edith", "Kim", "Sherry", "Sylvia", "Josephine", "Thelma", 
"Shannon", "Sheila", "Ethel", "Ellen", "Elaine", "Marjorie", "Carrie", 
"Charlotte", "Monica", "Esther", "Pauline", "Emma", "Juanita", "Anita", 
"Rhonda", "Hazel", "Amber", "Eva", "Debbie", "April", "Leslie", "Clara", 
"Lucille", "Jamie", "Joanne", "Eleanor", "Valerie", "Danielle", "Megan", 
"Alicia", "Suzanne", "Michele", "Gail", "Bertha", "Darlene", "Veronica", 
"Jill", "Erin", "Geraldine", "Lauren", "Cathy", "Joann", "Lorraine", "Lynn", 
"Sally", "Regina", "Erica", "Beatrice", "Dolores", "Bernice", "Audrey", 
"Yvonne", "Annette", "June", "Samantha", "Marion", "Dana", "Stacy", "Ana", 
"Renee", "Ida", "Vivian", "Roberta", "Holly", "Brittany", "Melanie", 
"Loretta", "Yolanda", "Jeanette", "Laurie", "Katie", "Kristen", "Vanessa",
{'fraction_non_alphanumeric': 0.19680343511450382, 'fraction_numerical': 0.02361641221374046, 'mean_word_length': 4.711852861035422, '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': '3355286', 'n_tokens_mistral': 3569, 'n_tokens_neox': 3296, 'n_words': 643}