def Questions(): ''' AIM -> Create a good looking questionnaire to generate required arguments to be used with tweet_collection OUTPUT -> String with desired arguments ''' # Initialize Questionnaire q = Questionnaire() # Create Raw Questions q.raw('Search Keyword') q.raw('Number of Tweets', type=int) q.raw('CSV Name') # Run the module q.run() return q.format_answers()
from questionnaire import Questionnaire import requests q = Questionnaire(show_answers=False, can_go_back=False) q.raw('user', prompt='Username:'******'pass', prompt='Password:'******'https://api.github.com/user/repos', auth=(q.answers.get('user'), q.answers.get('pass'))) if not (r.ok): import sys print('username/password incorrect') sys.exit() repos = [repo.get('url') for repo in r.json()] q.one('repo', *repos, prompt='Choose a repo') q.run() print(q.answers.get('repo'))
from questionnaire import Questionnaire import requests q = Questionnaire(show_answers=False, can_go_back=False) q.raw('user', prompt='Username:'******'pass', prompt='Password:'******'https://api.github.com/user/repos', auth=(q.answers.get('user'), q.answers.get('pass'))) if not(r.ok): import sys print('username/password incorrect') sys.exit() repos = [repo.get('url') for repo in r.json()] q.one('repo', *repos, prompt='Choose a repo') q.run() print(q.answers.get('repo'))
from questionnaire import Questionnaire q = Questionnaire(can_go_back=False) def email(email): import re if not re.match(r'[^@]+@[^@]+\.[^@]+', email): return 'Enter a valid email' def one(options): if len(options) < 1: return 'You must choose at least 1 type of junk mail' def join(options): return ', '.join(options) q.raw('email').validate(email) q.many('junk_mail', 'this one weird trick', 'cheap viagra', 'dermatologists hate her').validate(one).transform(join) q.run() print(q.answers)
q.run() a = q.format_answers(fmt='plain'); a = a.split(" ") #language of choice abbreviated_language = language_name_list[every_language.index(a[-1])][0] # Instantiates a client translate_client = translate.Client() # Translates Quetionire into desired language # translation = translate_client.translate(text,target_language=abbreviated_language) q = Questionnaire() q.raw(translate_client.translate('first_name',target_language=abbreviated_language)['translatedText'], prompt= translate_client.translate('What is your First Name?',target_language=abbreviated_language)['translatedText']) q.raw(translate_client.translate('last_name',target_language=abbreviated_language)['translatedText'],prompt=translate_client.translate('What is your Last Name?',target_language=abbreviated_language)['translatedText']) q.raw(translate_client.translate("email",target_language=abbreviated_language)['translatedText'],prompt=translate_client.translate('What is your email? ',target_language=abbreviated_language)['translatedText']) q.raw(translate_client.translate("phone_number",target_language=abbreviated_language)['translatedText'],prompt=translate_client.translate('What is your phone number?',target_language=abbreviated_language)['translatedText']) q.raw(translate_client.translate("address_line_1",target_language=abbreviated_language)['translatedText'],prompt=translate_client.translate('What is your street address?',target_language=abbreviated_language)['translatedText']) q.raw(translate_client.translate("city",target_language=abbreviated_language)['translatedText'],prompt=translate_client.translate('What city?',target_language=abbreviated_language)['translatedText']) q.raw(translate_client.translate("country",target_language=abbreviated_language)['translatedText'],prompt=translate_client.translate('What country?',target_language=abbreviated_language)['translatedText']) q.raw(translate_client.translate("postal_code",target_language=abbreviated_language)['translatedText'],prompt=translate_client.translate('postal code?',target_language=abbreviated_language)['translatedText']) q.run() PART_ONE = q.format_answers(fmt='array') PART_ONE = "PART_ONE = " + q.format_answers(fmt='array') exec(PART_ONE) qu = Questionnaire()
from questionnaire import Questionnaire q = Questionnaire() q.raw('age', prompt='How old are you?', type=int) q.one('plans', 'Valley College', 'La Escuela de Calor', prompt='Where do you want to go to school?').condition(('age', 18, '<=')) q.one('plans', 'On a farm', 'In an office', 'On the couch', prompt='Where do you want to work?', idx=2).condition(('age', 40, '<=')) q.one('plans', 'El Caribe', 'Disneyland', 'Las Islas Canarias', prompt='Where do you want to vacation?').condition(('age', 60, '<=')) q.one('plans', 'El campo', 'The beach', 'San Miguel de Allende', prompt='Where do you want to retire?') q.run() print(q.answers)
from questionnaire import Questionnaire def not_blank(value): return 'enter a color' if not value else None q = Questionnaire(show_answers=False, can_go_back=False) q.raw('color', prompt='Favorite color (type ENTER to insert the default value):', default='blue').validate(not_blank) q.run() print(q.answers.get('color'))
from questionnaire import Questionnaire q = Questionnaire() q.raw('age', prompt='How old are you?', type=int) q.one('plans', 'Valley College', 'La Escuela de Calor', prompt='Where do you want to go to school?').condition( ('age', 18, '<=')) q.one('plans', 'On a farm', 'In an office', 'On the couch', prompt='Where do you want to work?', idx=2).condition( ('age', 40, '<=')) q.one('plans', 'El Caribe', 'Disneyland', 'Las Islas Canarias', prompt='Where do you want to vacation?').condition( ('age', 60, '<=')) q.one('plans', 'El campo', 'The beach', 'San Miguel de Allende', prompt='Where do you want to retire?') q.run() print(q.answers)