49 lines
942 B
Python
49 lines
942 B
Python
'''WizardKit: Standard Functions'''
|
|
# vim: sts=2 sw=2 ts=2
|
|
|
|
import os
|
|
import sys
|
|
|
|
try:
|
|
from termios import tcflush, TCIOFLUSH
|
|
except ImportError:
|
|
if os.name == 'posix':
|
|
raise
|
|
|
|
|
|
# STATIC VARIABLES
|
|
COLORS = {
|
|
'CLEAR': '\033[0m',
|
|
'RED': '\033[31m',
|
|
'ORANGE': '\033[31;1m',
|
|
'GREEN': '\033[32m',
|
|
'YELLOW': '\033[33m',
|
|
'BLUE': '\033[34m',
|
|
'PURPLE': '\033[35m',
|
|
'CYAN': '\033[36m',
|
|
}
|
|
|
|
|
|
# Functions
|
|
def input_text(prompt='Enter text'):
|
|
"""Get text from user, returns string."""
|
|
prompt = str(prompt)
|
|
response = None
|
|
if prompt[-1:] != ' ':
|
|
prompt += ' '
|
|
|
|
while response is None:
|
|
if os.name == 'posix':
|
|
# Flush input to (hopefully) avoid EOFError
|
|
tcflush(sys.stdin, TCIOFLUSH)
|
|
try:
|
|
response = input(prompt)
|
|
except EOFError:
|
|
# Ignore and try again
|
|
print('')
|
|
|
|
return response
|
|
|
|
|
|
if __name__ == '__main__':
|
|
print("This file is not meant to be called directly.")
|