<commit_before>#! /usr/bin/python

import json
jsonResponseFile = open('response.txt', 'r')
menu = json.load(jsonResponseFile)
data = menu['response']['data']

days = ('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday')

def displayMenu(restaurant, foodlist):
	if foodlist and 'Menu' in foodlist:
		print(restaurant + ':')
		print
		print
		for day in days:
			if day in foodlist['Menu'].keys():
				print('    ' + day + ':')
				print
				for meal, itemlist in foodlist['Menu'][day].iteritems():
					print('        ' + meal + ':')
					if type(itemlist['Items']['result']) == list:
						for item in itemlist['Items']['result']:
							print('        ' + item)
					else:
						print('        ' + itemlist['Items']['result'])
					print
				print

print
print('This menu is valid from ' + data['Start'] + ' to ' + data['End'] + '.')
print
print
# print json.dumps(data, indent=1)

for restaurant, foodlist in data['Restaurants'].iteritems():
	displayMenu(restaurant, foodlist)<commit_msg>Update parseMenu.py to use data from Amazon S3, refactoring of methods/main.<commit_after>#!/usr/bin/env python
import json, os, requests
from awsauth import S3Auth

def displayMenu(restaurant, foodlist):
	if foodlist and 'Menu' in foodlist:
		print(restaurant + ':')
		print
		print
		days = ('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday')
		for day in days:
			if day in foodlist['Menu'].keys():
				print('    ' + day + ':')
				print
				for meal, itemlist in foodlist['Menu'][day].iteritems():
					print('        ' + meal + ':')
					if type(itemlist['Items']['result']) == list:
						for item in itemlist['Items']['result']:
							print('        ' + item)
					else:
						print('        ' + itemlist['Items']['result'])
					print
				print

if __name__ == "__main__":
	ACCESS_KEY = os.environ.get('AWS_ACCESS_KEY_ID')
	SECRET_KEY = os.environ.get('AWS_SECRET_ACCESS_KEY')
	r = requests.get('http://s3.amazonaws.com/uwfoodmenu/response.txt', auth=S3Auth(ACCESS_KEY, SECRET_KEY))
	menu = r.json()['response']['data']
	for restaurant, foodlist in menu['Restaurants'].iteritems():
		displayMenu(restaurant, foodlist)
	print
	print('This menu is valid from ' + menu['Start'] + ' to ' + menu['End'] + '.')
	print
	print
	# print json.dumps(menu, indent=4)
{'fraction_non_alphanumeric': 0.17425227568270482, 'fraction_numerical': 0.002600780234070221, 'mean_word_length': 3.758762886597938, 'pattern_counts': {'":': 1, '<': 3, '<?xml version=': 0, '>': 3, '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': '4064446', 'n_tokens_mistral': 881, 'n_tokens_neox': 753, 'n_words': 189}