<commit_before># -*- coding: utf-8 -*-

"""
On the Subject of Passwords

:Copyright: 2015 <NAME>
:License: MIT, see LICENSE for details.
"""

from string import ascii_lowercase

from ..userinterface import Question, ask_for_input, display_question


PASSWORDS = frozenset([
    'about', 'after', 'again', 'below', 'could',
    'every', 'first', 'found', 'great', 'house',
    'large', 'learn', 'never', 'other', 'place',
    'plant', 'point', 'right', 'small', 'sound',
    'spell', 'still', 'study', 'their', 'there',
    'these', 'thing', 'think', 'three', 'water',
    'where', 'which', 'world', 'would', 'write',
])


def ask_for_letters_in_first_position():
    letters = ask_for_letters_in_position('first')
    matches = get_passwords_starting_with(letters)
    print()
    for match in matches:
        print(' ->', match)


def ask_for_letters_in_position(position_label):
    question_label = 'Which letters are selectable in the {} position?' \
                     .format(position_label)
    question = Question(question_label, [])
    display_question(question)

    values = ask_for_input()
    return extract_letters(values)


def extract_letters(value):
    """Select and normalize ASCII letters, drop anything else."""<commit_msg>Handle zero as well as exactly one password matches.<commit_after># -*- coding: utf-8 -*-

"""
On the Subject of Passwords

:Copyright: 2015 <NAME>
:License: MIT, see LICENSE for details.
"""

from string import ascii_lowercase

from ..userinterface import Question, ask_for_input, display_instruction, \
    display_question


PASSWORDS = frozenset([
    'about', 'after', 'again', 'below', 'could',
    'every', 'first', 'found', 'great', 'house',
    'large', 'learn', 'never', 'other', 'place',
    'plant', 'point', 'right', 'small', 'sound',
    'spell', 'still', 'study', 'their', 'there',
    'these', 'thing', 'think', 'three', 'water',
    'where', 'which', 'world', 'would', 'write',
])


def ask_for_letters_in_first_position():
    letters = ask_for_letters_in_position('first')
    matches = list(get_passwords_starting_with(letters))

    if not matches:
        display_instruction('No password matches!')
        return

    if len(matches) == 1:
        display_instruction(matches[0])
        return

    print()
    print('  Multiple candidates:')
    for match in matches:
        print('  ->', match)


def ask_for_letters_in_position(position_label):
    question_label = 'Which letters are selectable in the {} position?' \
                     .format(position_label)
    question = Question(question_label, [])
    display_question(question)

    values = ask_for_input()
    return extract_letters(values)


def extract_letters(value):
    """Select and normalize ASCII letters, drop anything else."""
{'fraction_non_alphanumeric': 0.15165706051873198, 'fraction_numerical': 0.004322766570605188, 'mean_word_length': 3.923758865248227, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '808546', 'n_tokens_mistral': 889, 'n_tokens_neox': 828, 'n_words': 233}