def greetings(): user_greeting_response = choice.Menu(['Login', 'Create new profile']).ask() if user_greeting_response == 'Login': username = choice.Input('Enter your username', str).ask() password = choice.Input('Enter your password', str).ask() user_data = get_user_data(username, password) if user_data: click.echo('You are logged in! What would you like to do?') return user_data else: click.echo('Incorrect password or username') greetings() else: click.echo('creating a new user') first_name = choice.Input('What is your first name?', str).ask() last_name = choice.Input('What is your last name?', str).ask() username = choice.Input('Pick a username?', str).ask() password = choice.Input('Enter a password', str).ask() email = choice.Input('Enter your email address', str).ask() # can be null add_addresses = choice.Binary( 'Would you like to add addresses to your profile?', True).ask() insert_into_profile(first_name, last_name, username, password, email, add_addresses) if add_addresses: user_id = get_user_data(username, password)['user_id'] add_addresses_prompt(user_id)
def bbref_scrape(): # This is to ask the nature of the data print("Please select if you'd like to have your data from the playoffs, regular season, or both:\n") rpb = choice.Menu(['Playoffs', 'Regular Season', 'Both']).ask() # This is to ask the specific data required print("Please select what data you'd like: \n") data = 'something else' # just to start the loop wanted_data = [] while data != 'No more': data = choice.Menu(['Totals', 'Advanced', 'Per 36', 'Per 100', 'Per Game', 'All', 'No more']).ask() if data != 'No more' and data != 'All' and data not in wanted_data: wanted_data.append(data) elif data != 'No more' and data != 'All' and data in wanted_data: print("Please try again. Do not select a source that you've already selected and please do not select 'All' if you've already selected a source. If you're done please select the 'No more' option.\n") elif data == 'All' and not wanted_data: wanted_data.append('Totals') wanted_data.append('Advanced') wanted_data.append('Per 36') wanted_data.append('Per 100') wanted_data.append('Per Game') data = 'No more' years = userYears() # This is to actually create whatever data that the user requested for wd in wanted_data: if wd == 'Advanced': advanced_scrape(rpb, years[0], years[1]) elif wd == 'Totals': totals_scrape(rpb, years[0], years[1]) elif wd == 'Per 36': per_36_scrape(rpb, years[0], years[1]) elif wd == 'Per 100': per_100_scrape(rpb, years[0], years[1]) elif wd == 'Per Game': per_game_scrape(rpb, years[0], years[1]) return
import choice # Get a yes or no response (default is no) confirm = choice.Binary('Are you sure you want to delete?', False).ask() if confirm: deleteIt() # Input an arbitrary value, check for correctness howmany = choice.Input('How many pies?', int).ask() print("You ordered {} pies".format(howmany)) # Choose from a set of options entree = choice.Menu(['steak', 'potatoes', 'eggplant']).ask() print("You choice {}".format(entree)) posts = ['post {}'.format(num) for num in range(15)] resp = choice.Menu(posts, ['edit', 'delete', 'publish'], ['newpost', 'exit']).ask() print(resp) resp = choice.Input('Enter an integer', int).ask() resp = choice.Input('Enter a string with "a" in it', choice.validate(lambda s: "a" in s)).ask() resp = choice.Binary('Yes or no?', True).ask() resp = choice.Binary('yes or No?', False).ask() resp = choice.Binary('yes or no?').ask()
# for task in asana_api.get_project_tasks(17412748309135): # resp = requests.post("http://localhost:5000/tasks", # data=json.dumps({'title': task['name'], # 'project': "54c4e110d54df36a33fb1f72", # 'external_id': {'asana_id': task['id']}}), # headers={'content-type': 'application/json'} # ) # if resp.ok: # print task['name'], resp.status_code # else: # import pdb; pdb.set_trace() # import pdb; pdb.set_trace() choices = [(item['id'], item['name']) for item in asana_api.list_workspaces()] workspace = choice.Menu(choices).ask() for project in asana_api.list_projects(workspace, include_archived=False): # {u'id': 20786005245857, u'name': u'API 0.4'} # import pdb; pdb.set_trace() extended_project = asana_api.get_project(project['id']) resp = requests.post("http://localhost:5000/projects", data=json.dumps({ 'name': extended_project['name'], 'asana': { 'id': extended_project['id'], 'created_at': extended_project['created_at'], 'modified_at': extended_project['modified_at'], 'archived': extended_project['archived'] }
| ( ) Oooo. | +---------------------\ (----( )--------------------+ \_) ) / (_/ ------------------------------------------------ Thank you for visiting https://asciiart.website/ This ASCII pic can be found at https://asciiart.website/index.php?art=art%20and%20design/signatures """ ## using choice library print("Which of these is your favorite mythical creature?") favorite_creature = choice.Menu(['dragon','unicorn','kraken','none']).ask() if favorite_creature == 'dragon': print(dragon) elif favorite_creature == 'unicorn': print(unicorn) elif favorite_creature == 'kraken': print(kraken) else: print(thanks) #print(dragon) #print(unicorn)
else: raise AssertionError( 'Unknown report type: {}'.format(report_type)) except Exception as e: log.exception('Error occured on outbox processing %s %s', filename, repr(e)) if DEBUG: import pdb pdb.set_trace() # noqa continue finally: cabinet.quit() log.info('Sent report inn=%s fio=%s filename=%s', cabinet.inn, cabinet.fio, os.path.basename(filename)) for filename in ([filename] + (subreports and list(subreports) or [])): dest = os.path.join(sent_dir, os.path.basename(filename)) maybe_remove(dest) os.rename(filename, dest) # TODO: add to xls log, or rename budget_status to just status? if __name__ == '__main__': funcs = ['scan_keys', 'get_info', 'get_report_status', 'send_outbox'] try: func = choice.Menu(funcs).ask() globals()[func]() except Exception as e: log.exception(repr(e)) input('DONE. press any key to close')
def user_want(): user_want_response = choice.Menu( ['Manage my addresses', 'See the weather', 'Check traffic conditions']).ask() return user_want_response