GitHub PullRequestReviewCommentEvent at 2014-12-16 05:14:19
Repository: sea-c28-students
Actor: jefrailey
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/codefellows/sea-c28-students/pulls/comments/21878239","id":21878239,"diff_hunk":"@@ -0,0 +1,162 @@\n+#!/usr/bin/env python\n+\n+# Mailroom\n+#\n+# Maintains a list of donors and sends out emails to them.\n+from collections import OrderedDict\n+\n+\n+def printlist():\n+    \"\"\"Print a list of donor names\n+    \"\"\"\n+    for donor in donordict.keys():\n+        print(donor)\n+\n+\n+def addnametolist(name):\n+    \"\"\"Add a name to the list\n+\n+    Also sets up an empty list to add amounts to.\n+    \"\"\"\n+    donordict[name] = []\n+\n+\n+def addamounttolist(name, amount):\n+    \"\"\"Add amount to the end of a list of amounts for a donor\n+    \"\"\"\n+    donordict[name].append(amount)\n+\n+\n+def generateemail(donor):\n+    \"\"\"Print email to terminal\n+\n+    Store an email in symbol email and print it to the screen\n+    \"\"\"\n+    email = \"Hi %s,\\nThank you for your generous donation of %.2f\\n\\n\" \\\n+            \"Thanks,\\nGoodbye\\n\\n\" \\\n+            % (donor, donordict[donor][-1])\n+    print(email)\n+\n+\n+def sendthankyou():\n+    \"\"\"Takes steps to add donor or email thank you.\n+\n+    This does two things:\n+    1) Prompts uses for a name.\n+    If user puts in a name, it will either add the name into the donor list\n+    or if the person is already in the list, it will select that donor.\n+    The name has to be a mix of letters and spaces.\n+    If user selects list, it will print out a list of names already in.\n+    If user selects q, it will quit out to main menu.\n+\n+    2) Prompts user for an amount\n+    If the user puts in an illegal value (not convertable to a float),\n+    tell them it is illegal and then reprompt\n+    If user selects q, it will quit out to main menu. If it is a new donor,\n+    and they quit, the donor will have an empty list of donation amounts.\n+    If the value is legal then print an email.\n+    \"\"\"\n+    quiting = False  # if user quits, set this to True\n+    while not(quiting):\n+        promptstr = u\"What is the donor's name (list for list; q for menu)?\"\n+        donor = unicode(raw_input(promptstr))\n+        if donor == u'q':\n+            quiting = True\n+        elif donor == u'list':\n+            printlist()\n+            continue\n+        elif donor in donordict:\n+            break\n+        elif donor.replace(' ', '').isalpha():\n+            addnametolist(donor)\n+            break\n+        else:\n+            continue\n+\n+    # Add amount to the donating person's donation list.\n+    while not(quiting):\n+        try:\n+            promptstr = u\"How much did they donate (q to exit to menu)?\"\n+            donoramount = unicode(raw_input(promptstr))\n+            if donoramount == u'q':\n+                quiting = True\n+                break\n+            else:\n+                addamounttolist(donor, float(donoramount))\n+                generateemail(donor)\n+                break\n+        except ValueError:\n+            print(u\"Illegal value. Please enter in a number.\")\n+            continue\n+\n+\n+def createreport():\n+    \"\"\"Create a report with list of donors and amounts they donated.\n+\n+    Table contains these four columns:\n+    Donor Name,\n+    total donated,\n+    number of donations,\n+    average donation\n+\n+    and is sorted by total donations.\n+\n+    The first column will scale to the size of the donor's name.\n+    \"\"\"\n+    # create a sorted donordict sorted by total of amounts.\n+    sort = sorted(donordict.items(), key=lambda t: sum(t[1]))\n+    sorteddonorlist = OrderedDict(sort)\n+\n+    # Columns\n+    col1 = 'Donor Name'\n+    col2 = 'Total Donations'\n+    col3 = '# of Donations'\n+    col4 = 'Average Donations'\n+\n+    # determine width of first column\n+    longestname = max(len(donor) for donor in donordict.keys())\n+    col1width = max(len(col1), longestname) + 1\n+\n+    report = \"{:{width}} | {:^17} | {:^16} | {:^19}\\n\"\\\n+        .format(col1, col2, col3, col4, width=col1width)","path":"Students/HenryGrantham/session05/mailroom.py","position":121,"original_position":121,"commit_id":"73d78d74907e44ac32f58fb8b3f2abe2cc8c3fd1","original_commit_id":"73d78d74907e44ac32f58fb8b3f2abe2cc8c3fd1","user":{"login":"jefrailey","id":7455511,"avatar_url":"https://avatars.githubusercontent.com/u/7455511?v=3","gravatar_id":"","url":"https://api.github.com/users/jefrailey","html_url":"https://github.com/jefrailey","followers_url":"https://api.github.com/users/jefrailey/followers","following_url":"https://api.github.com/users/jefrailey/following{/other_user}","gists_url":"https://api.github.com/users/jefrailey/gists{/gist_id}","starred_url":"https://api.github.com/users/jefrailey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jefrailey/subscriptions","organizations_url":"https://api.github.com/users/jefrailey/orgs","repos_url":"https://api.github.com/users/jefrailey/repos","events_url":"https://api.github.com/users/jefrailey/events{/privacy}","received_events_url":"https://api.github.com/users/jefrailey/received_events","type":"User","site_admin":false},"body":"Nice use of dynamic formatting!","created_at":"2014-12-16T05:14:19Z","updated_at":"2014-12-16T05:14:19Z","html_url":"https://github.com/codefellows/sea-c28-students/pull/113#discussion_r21878239","pull_request_url":"https://api.github.com/repos/codefellows/sea-c28-students/pulls/113","_links":{"self":{"href":"https://api.github.com/repos/codefellows/sea-c28-students/pulls/comments/21878239"},"html":{"href":"https://github.com/codefellows/sea-c28-students/pull/113#discussion_r21878239"},"pull_request":{"href":"https://api.github.com/repos/codefellows/sea-c28-students/pulls/113"}}},"pull_request":{"url":"https://api.github.com/repos/codefellows/sea-c28-students/pulls/113","id":26037535,"html_url":"https://github.com/codefellows/sea-c28-students/pull/113","diff_url":"https://github.com/codefellows/sea-c28-students/pull/113.diff","patch_url":"https://github.com/codefellows/sea-c28-students/pull/113.patch","issue_url":"https://api.github.com/repos/codefellows/sea-c28-students/issues/113","number":113,"state":"open","locked":false,"title":"Session05 - Final mailroom.py and safe_input.py","user":{"login":"henry808","id":9962045,"avatar_url":"https://avatars.githubusercontent.com/u/9962045?v=3","gravatar_id":"","url":"https://api.github.com/users/henry808","html_url":"https://github.com/henry808","followers_url":"https://api.github.com/users/henry808/followers","following_url":"https://api.github.com/users/henry808/following{/other_user}","gists_url":"https://api.github.com/users/henry808/gists{/gist_id}","starred_url":"https://api.github.com/users/henry808/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/henry808/subscriptions","organizations_url":"https://api.github.com/users/henry808/orgs","repos_url":"https://api.github.com/users/henry808/repos","events_url":"https://api.github.com/users/henry808/events{/privacy}","received_events_url":"https://api.github.com/users/henry808/received_events","type":"User","site_admin":false},"body":"Final Mailroom madness and Exceptions assignments","created_at":"2014-12-14T18:55:22Z","updated_at":"2014-12-16T05:14:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d10d06c901748c1b5746ccb1c1c8ac9bc4f87f25","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/codefellows/sea-c28-students/pulls/113/commits","review_comments_url":"https://api.github.com/repos/codefellows/sea-c28-students/pulls/113/comments","review_comment_url":"https://api.github.com/repos/codefellows/sea-c28-students/pulls/comments/{number}","comments_url":"https://api.github.com/repos/codefellows/sea-c28-students/issues/113/comments","statuses_url":"https://api.github.com/repos/codefellows/sea-c28-students/statuses/73d78d74907e44ac32f58fb8b3f2abe2cc8c3fd1","head":{"label":"henry808:session05","ref":"session05","sha":"73d78d74907e44ac32f58fb8b3f2abe2cc8c3fd1","user":{"login":"henry808","id":9962045,"avatar_url":"https://avatars.githubusercontent.com/u/9962045?v=3","gravatar_id":"","url":"https://api.github.com/users/henry808","html_url":"https://github.com/henry808","followers_url":"https://api.github.com/users/henry808/followers","following_url":"https://api.github.com/users/henry808/following{/other_user}","gists_url":"https://api.github.com/users/henry808/gists{/gist_id}","starred_url":"https://api.github.com/users/henry808/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/henry808/subscriptions","organizations_url":"https://api.github.com/users/henry808/orgs","repos_url":"https://api.github.com/users/henry808/repos","events_url":"https://api.github.com/users/henry808/events{/privacy}","received_events_url":"https://api.github.com/users/henry808/received_events","type":"User","site_admin":false},"repo":{"id":27208132,"name":"sea-c28-students","full_name":"henry808/sea-c28-students","owner":{"login":"henry808","id":9962045,"avatar_url":"https://avatars.githubusercontent.com/u/9962045?v=3","gravatar_id":"","url":"https://api.github.com/users/henry808","html_url":"https://github.com/henry808","followers_url":"https://api.github.com/users/henry808/followers","following_url":"https://api.github.com/users/henry808/following{/other_user}","gists_url":"https://api.github.com/users/henry808/gists{/gist_id}","starred_url":"https://api.github.com/users/henry808/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/henry808/subscriptions","organizations_url":"https://api.github.com/users/henry808/orgs","repos_url":"https://api.github.com/users/henry808/repos","events_url":"https://api.github.com/users/henry808/events{/privacy}","received_events_url":"https://api.github.com/users/henry808/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/henry808/sea-c28-students","description":"","fork":true,"url":"https://api.github.com/repos/henry808/sea-c28-students","forks_url":"https://api.github.com/repos/henry808/sea-c28-students/forks","keys_url":"https://api.github.com/repos/henry808/sea-c28-students/keys{/key_id}","collaborators_url":"https://api.github.com/repos/henry808/sea-c28-students/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/henry808/sea-c28-students/teams","hooks_url":"https://api.github.com/repos/henry808/sea-c28-students/hooks","issue_events_url":"https://api.github.com/repos/henry808/sea-c28-students/issues/events{/number}","events_url":"https://api.github.com/repos/henry808/sea-c28-students/events","assignees_url":"https://api.github.com/repos/henry808/sea-c28-students/assignees{/user}","branches_url":"https://api.github.com/repos/henry808/sea-c28-students/branches{/branch}","tags_url":"https://api.github.com/repos/henry808/sea-c28-students/tags","blobs_url":"https://api.github.com/repos/henry808/sea-c28-students/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/henry808/sea-c28-students/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/henry808/sea-c28-students/git/refs{/sha}","trees_url":"https://api.github.com/repos/henry808/sea-c28-students/git/trees{/sha}","statuses_url":"https://api.github.com/repos/henry808/sea-c28-students/statuses/{sha}","languages_url":"https://api.github.com/repos/henry808/sea-c28-students/languages","stargazers_url":"https://api.github.com/repos/henry808/sea-c28-students/stargazers","contributors_url":"https://api.github.com/repos/henry808/sea-c28-students/contributors","subscribers_url":"https://api.github.com/repos/henry808/sea-c28-students/subscribers","subscription_url":"https://api.github.com/repos/henry808/sea-c28-students/subscription","commits_url":"https://api.github.com/repos/henry808/sea-c28-students/commits{/sha}","git_commits_url":"https://api.github.com/repos/henry808/sea-c28-students/git/commits{/sha}","comments_url":"https://api.github.com/repos/henry808/sea-c28-students/comments{/number}","issue_comment_url":"https://api.github.com/repos/henry808/sea-c28-students/issues/comments/{number}","contents_url":"https://api.github.com/repos/henry808/sea-c28-students/contents/{+path}","compare_url":"https://api.github.com/repos/henry808/sea-c28-students/compare/{base}...{head}","merges_url":"https://api.github.com/repos/henry808/sea-c28-students/merges","archive_url":"https://api.github.com/repos/henry808/sea-c28-students/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/henry808/sea-c28-students/downloads","issues_url":"https://api.github.com/repos/henry808/sea-c28-students/issues{/number}","pulls_url":"https://api.github.com/repos/henry808/sea-c28-students/pulls{/number}","milestones_url":"https://api.github.com/repos/henry808/sea-c28-students/milestones{/number}","notifications_url":"https://api.github.com/repos/henry808/sea-c28-students/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/henry808/sea-c28-students/labels{/name}","releases_url":"https://api.github.com/repos/henry808/sea-c28-students/releases{/id}","created_at":"2014-11-27T03:58:07Z","updated_at":"2014-12-14T02:59:20Z","pushed_at":"2014-12-16T03:35:29Z","git_url":"git://github.com/henry808/sea-c28-students.git","ssh_url":"git@github.com:henry808/sea-c28-students.git","clone_url":"https://github.com/henry808/sea-c28-students.git","svn_url":"https://github.com/henry808/sea-c28-students","homepage":null,"size":2400,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"codefellows:master","ref":"master","sha":"fab265e8ea7fddce84ef36e162c5848eed188303","user":{"login":"codefellows","id":3904529,"avatar_url":"https://avatars.githubusercontent.com/u/3904529?v=3","gravatar_id":"","url":"https://api.github.com/users/codefellows","html_url":"https://github.com/codefellows","followers_url":"https://api.github.com/users/codefellows/followers","following_url":"https://api.github.com/users/codefellows/following{/other_user}","gists_url":"https://api.github.com/users/codefellows/gists{/gist_id}","starred_url":"https://api.github.com/users/codefellows/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codefellows/subscriptions","organizations_url":"https://api.github.com/users/codefellows/orgs","repos_url":"https://api.github.com/users/codefellows/repos","events_url":"https://api.github.com/users/codefellows/events{/privacy}","received_events_url":"https://api.github.com/users/codefellows/received_events","type":"Organization","site_admin":false},"repo":{"id":27015627,"name":"sea-c28-students","full_name":"codefellows/sea-c28-students","owner":{"login":"codefellows","id":3904529,"avatar_url":"https://avatars.githubusercontent.com/u/3904529?v=3","gravatar_id":"","url":"https://api.github.com/users/codefellows","html_url":"https://github.com/codefellows","followers_url":"https://api.github.com/users/codefellows/followers","following_url":"https://api.github.com/users/codefellows/following{/other_user}","gists_url":"https://api.github.com/users/codefellows/gists{/gist_id}","starred_url":"https://api.github.com/users/codefellows/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codefellows/subscriptions","organizations_url":"https://api.github.com/users/codefellows/orgs","repos_url":"https://api.github.com/users/codefellows/repos","events_url":"https://api.github.com/users/codefellows/events{/privacy}","received_events_url":"https://api.github.com/users/codefellows/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/codefellows/sea-c28-students","description":"","fork":false,"url":"https://api.github.com/repos/codefellows/sea-c28-students","forks_url":"https://api.github.com/repos/codefellows/sea-c28-students/forks","keys_url":"https://api.github.com/repos/codefellows/sea-c28-students/keys{/key_id}","collaborators_url":"https://api.github.com/repos/codefellows/sea-c28-students/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/codefellows/sea-c28-students/teams","hooks_url":"https://api.github.com/repos/codefellows/sea-c28-students/hooks","issue_events_url":"https://api.github.com/repos/codefellows/sea-c28-students/issues/events{/number}","events_url":"https://api.github.com/repos/codefellows/sea-c28-students/events","assignees_url":"https://api.github.com/repos/codefellows/sea-c28-students/assignees{/user}","branches_url":"https://api.github.com/repos/codefellows/sea-c28-students/branches{/branch}","tags_url":"https://api.github.com/repos/codefellows/sea-c28-students/tags","blobs_url":"https://api.github.com/repos/codefellows/sea-c28-students/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/codefellows/sea-c28-students/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/codefellows/sea-c28-students/git/refs{/sha}","trees_url":"https://api.github.com/repos/codefellows/sea-c28-students/git/trees{/sha}","statuses_url":"https://api.github.com/repos/codefellows/sea-c28-students/statuses/{sha}","languages_url":"https://api.github.com/repos/codefellows/sea-c28-students/languages","stargazers_url":"https://api.github.com/repos/codefellows/sea-c28-students/stargazers","contributors_url":"https://api.github.com/repos/codefellows/sea-c28-students/contributors","subscribers_url":"https://api.github.com/repos/codefellows/sea-c28-students/subscribers","subscription_url":"https://api.github.com/repos/codefellows/sea-c28-students/subscription","commits_url":"https://api.github.com/repos/codefellows/sea-c28-students/commits{/sha}","git_commits_url":"https://api.github.com/repos/codefellows/sea-c28-students/git/commits{/sha}","comments_url":"https://api.github.com/repos/codefellows/sea-c28-students/comments{/number}","issue_comment_url":"https://api.github.com/repos/codefellows/sea-c28-students/issues/comments/{number}","contents_url":"https://api.github.com/repos/codefellows/sea-c28-students/contents/{+path}","compare_url":"https://api.github.com/repos/codefellows/sea-c28-students/compare/{base}...{head}","merges_url":"https://api.github.com/repos/codefellows/sea-c28-students/merges","archive_url":"https://api.github.com/repos/codefellows/sea-c28-students/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/codefellows/sea-c28-students/downloads","issues_url":"https://api.github.com/repos/codefellows/sea-c28-students/issues{/number}","pulls_url":"https://api.github.com/repos/codefellows/sea-c28-students/pulls{/number}","milestones_url":"https://api.github.com/repos/codefellows/sea-c28-students/milestones{/number}","notifications_url":"https://api.github.com/repos/codefellows/sea-c28-students/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/codefellows/sea-c28-students/labels{/name}","releases_url":"https://api.github.com/repos/codefellows/sea-c28-students/releases{/id}","created_at":"2014-11-22T23:11:01Z","updated_at":"2014-12-15T22:38:47Z","pushed_at":"2014-12-16T00:16:28Z","git_url":"git://github.com/codefellows/sea-c28-students.git","ssh_url":"git@github.com:codefellows/sea-c28-students.git","clone_url":"https://github.com/codefellows/sea-c28-students.git","svn_url":"https://github.com/codefellows/sea-c28-students","homepage":null,"size":4017,"stargazers_count":2,"watchers_count":2,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":24,"mirror_url":null,"open_issues_count":63,"forks":24,"open_issues":63,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/codefellows/sea-c28-students/pulls/113"},"html":{"href":"https://github.com/codefellows/sea-c28-students/pull/113"},"issue":{"href":"https://api.github.com/repos/codefellows/sea-c28-students/issues/113"},"comments":{"href":"https://api.github.com/repos/codefellows/sea-c28-students/issues/113/comments"},"review_comments":{"href":"https://api.github.com/repos/codefellows/sea-c28-students/pulls/113/comments"},"review_comment":{"href":"https://api.github.com/repos/codefellows/sea-c28-students/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/codefellows/sea-c28-students/pulls/113/commits"},"statuses":{"href":"https://api.github.com/repos/codefellows/sea-c28-students/statuses/73d78d74907e44ac32f58fb8b3f2abe2cc8c3fd1"}}}}