src/lsi/utils/term.py
def get_input(prompt, default=None, exit_msg='bye!'):
    """
    Reads stdin, exits with a message if interrupted, EOF, or a quit message.

    :return: The entered input. Converts to an integer if possible.
    :rtype: ``str`` or ``int``
    """
    try:
        response = six.moves.input(prompt)
    except (KeyboardInterrupt, EOFError):
        print()
        print(exit_msg)
        exit()
    try:
        return int(response)
    except ValueError:
        if response.strip() == "" and default is not None:
            return default
        else:
            return response
def get_input(prompt, default=None, exit_msg='bye!'):
    """
    Reads stdin, exits with a message if interrupted, EOF, or a quit message.

    :return: The entered input. Converts to an integer if possible.
    :rtype: ``str`` or ``int``
    """
    try:
        response = six.moves.input(prompt)
    except (KeyboardInterrupt, EOFError):
        print()
        print(exit_msg)
        exit()
    try:
        return int(response)
    except ValueError:
        if response.strip() == "" and default is not None:
            return default
        else:
            return response
Reads stdin, exits with a message if interrupted, EOF, or a quit message.

    :return: The entered input. Converts to an integer if possible.
    :rtype: ``str`` or ``int``