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

import random
import string
import click


@click.command()
@click.argument('length', required=False, default=64)
def random_cli(length):
    click.echo(random_alphanumeric_string(length))


def random_alphanumeric_string(len):
    alphanumeric = string.ascii_letters + string.digits
    return random_string(len, alphanumeric)


def random_hex_string(len):
    return random_string(len, string.hexdigits)


def random_string(len, characters):
    result = ''
    while True:
        if len > 0:
            result += random.choice(characters)
            len -= 1
        else:
            return result


if __name__ == '__main__':
    random_cli()
<commit_msg>added type option for different character sets.<commit_after>#!/usr/bin/env python3

import random
import string
import click


@click.command()
@click.option(
    '--type',
    default='alphanumeric',
    help='type of characters to be generated.')
@click.argument('length', required=False, default=64)
def random_cli(type, length):
    if 'alphanumeric' == type:
        click.echo(random_alphanumeric_string(length))
    elif 'hex' == type:
        click.echo(random_hex_string(length))
    elif type in ['print', 'printable']:
        click.echo(random_string(length, string.printable))
    elif type in ['lower', 'lowercase']:
        click.echo(random_string(length, string.ascii_lowercase))
    elif type in ['upper', 'uppercase']:
        click.echo(random_string(length, string.ascii_uppercase))
    elif type in ['letter', 'letters', 'alpha']:
        click.echo(random_string(length, string.ascii_letters))


def random_alphanumeric_string(len):
    alphanumeric = string.ascii_letters + string.digits
    return random_string(len, alphanumeric)


def random_hex_string(len):
    return random_string(len, string.hexdigits)


def random_string(len, characters):
    result = ''
    while True:
        if len > 0:
            result += random.choice(characters)
            len -= 1
        else:
            return result


if __name__ == '__main__':
    random_cli()

{'fraction_non_alphanumeric': 0.11575408261287223, 'fraction_numerical': 0.004803073967339097, 'mean_word_length': 3.479569892473118, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '5780237', 'n_tokens_mistral': 655, 'n_tokens_neox': 637, 'n_words': 148}