예제 #1
0
def get_password(length=8):
    """
    Create a password with uppercase letters, lowercase letters, and digits.

    The password will include lowercase letters with higher probability.
    """
    assert length >= 8
    #
    chars = string.ascii_lowercase + string.ascii_lowercase + string.ascii_lowercase + \
            string.ascii_uppercase + string.digits + string.digits + string.digits
    chars = ''.join(my_shuffle([x for x in chars]))
    return ''.join(choice(chars) for x in range(length))
예제 #2
0
def header():
    """
    Print a fancy header. The rainbow colored logo only looks good
    with dark background. If the background is light, skip it.
    """
    rainbow_index = len(logos) - 1
    if cfg.g.BACKGROUND == cfg.DARK:
        # include the rainbow
        indexes = range(len(logos))
    else:
        # exclude the rainbow
        indexes = range(len(logos)-1)

    pos = choice(my_shuffle(indexes))
    if pos == rainbow_index:
        print(logos[pos])
    else:
        col = cfg.colors[cfg.g.BACKGROUND]["header"]
        print(bold(logos[pos], col))