{"action":"created","comment":{"url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-fathead/pulls/comments/67964324","id":67964324,"diff_hunk":"@@ -0,0 +1,147 @@\n+#!/usr/bin/python\n+\n+import os\n+from urlparse import urljoin\n+\n+from bs4 import BeautifulSoup\n+\n+__target__ = \"https://opam.ocaml.org/\"\n+__module__ = \"OPAM\"\n+\n+class Environment(object):\n+  \"\"\"\n+  The Environment class is responsible for setting up the directory\n+  and retriving the appropriate files from the web. It is made up of\n+  a constructor and a 'setup/0' and 'get_contents/0' member functions.\n+  \"\"\"\n+  def __init__(self):\n+    print(\"Environment instanciated\")\n+    self.setup()\n+\n+  def setup(self):\n+    \"\"\"\n+    The setup member function checks to see if the 'output.txt' file\n+    exists. If it does, delete it and move on, otherwise move on. This\n+    is called in the constructor of the Environment object and shouldn't\n+    be called again.\n+    \"\"\"\n+    if os.path.exists(\"output.txt\"):\n+      os.remove(\"output.txt\")\n+\n+  def get_contents(self):\n+    \"\"\"\n+    The 'get_contents/0' member function loads the file into memory and\n+    reads the contents. The file buffer is then closed and then a\n+    BeautifulSoup object is instanciated, with the contents. More on\n+    this can be read at the BeautifulSoup documentation website.\n+    \"\"\"\n+    with open('download/packages.html') as f:\n+      contents = f.read()\n+    contents = BeautifulSoup(contents, 'html.parser')\n+\n+    return contents\n+\n+\n+class Document(object):\n+  \"\"\"\n+  The Document class is responsible for setting up the end document\n+  (output.txt). It is made up of 4 member functions and a dummy\n+  constructor.\n+  \"\"\"\n+  def __init__(self):\n+    print(\"Document object instanciated\")\n+\n+  def parse_contents(self, soup):\n+    \"\"\"\n+    This member function parses the html document and extracts the\n+    cells from the table.\n+    \"\"\"\n+    data = []\n+    table = soup.find('table', attrs={'id':'packages'})\n+    table_body = table.find('tbody')\n+    rows = table_body.find_all('tr')\n+\n+    \"\"\"\n+    This section aims to extract the idividual data points from the\n+    table and turn them into a list. For each of the cols found in\n+    <td> tags, we return them in a list, while finding one link.\n+    We then preprocess the contents by stripping whitespace and\n+    stripping the front of the relative link. Once this preprocessing\n+    has been done, we connect the url, and append it to the list.","path":"lib/fathead/opam/parse.py","position":70,"original_position":70,"commit_id":"1496dbda235e9b713ca458aebe93d6797b1911c4","original_commit_id":"1496dbda235e9b713ca458aebe93d6797b1911c4","user":{"login":"milmazz","id":34700,"avatar_url":"https://avatars.githubusercontent.com/u/34700?v=3","gravatar_id":"","url":"https://api.github.com/users/milmazz","html_url":"https://github.com/milmazz","followers_url":"https://api.github.com/users/milmazz/followers","following_url":"https://api.github.com/users/milmazz/following{/other_user}","gists_url":"https://api.github.com/users/milmazz/gists{/gist_id}","starred_url":"https://api.github.com/users/milmazz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/milmazz/subscriptions","organizations_url":"https://api.github.com/users/milmazz/orgs","repos_url":"https://api.github.com/users/milmazz/repos","events_url":"https://api.github.com/users/milmazz/events{/privacy}","received_events_url":"https://api.github.com/users/milmazz/received_events","type":"User","site_admin":false},"body":"s/url/URL/\r\n\r\nPlease remember that URL is an acronym for *Uniform Resource Locator*","created_at":"2016-06-21T22:29:39Z","updated_at":"2016-06-21T22:29:39Z","html_url":"https://github.com/duckduckgo/zeroclickinfo-fathead/pull/210#discussion_r67964324","pull_request_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-fathead/pulls/210","_links":{"self":{"href":"https://api.github.com/repos/duckduckgo/zeroclickinfo-fathead/pulls/comments/67964324"},"html":{"href":"https://github.com/duckduckgo/zeroclickinfo-fathead/pull/210#discussion_r67964324"},"pull_request":{"href":"https://api.github.com/repos/duckduckgo/zeroclickinfo-fathead/pulls/210"}}},"pull_request":{"url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-fathead/pulls/210","id":70963191,"html_url":"https://github.com/duckduckgo/zeroclickinfo-fathead/pull/210","diff_url":"https://github.com/duckduckgo/zeroclickinfo-fathead/pull/210.diff","patch_url":"https://github.com/duckduckgo/zeroclickinfo-fathead/pull/210.patch","issue_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-fathead/issues/210","number":210,"state":"open","locked":false,"title":"Adding OPAM Fathead.","user":{"login":"pjhampton","id":8960296,"avatar_url":"https://avatars.githubusercontent.com/u/8960296?v=3","gravatar_id":"","url":"https://api.github.com/users/pjhampton","html_url":"https://github.com/pjhampton","followers_url":"https://api.github.com/users/pjhampton/followers","following_url":"https://api.github.com/users/pjhampton/following{/other_user}","gists_url":"https://api.github.com/users/pjhampton/gists{/gist_id}","starred_url":"https://api.github.com/users/pjhampton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pjhampton/subscriptions","organizations_url":"https://api.github.com/users/pjhampton/orgs","repos_url":"https://api.github.com/users/pjhampton/repos","events_url":"https://api.github.com/users/pjhampton/events{/privacy}","received_events_url":"https://api.github.com/users/pjhampton/received_events","type":"User","site_admin":false},"body":"This is the OPAM Fathead. @jdorweiler :)\r\n\r\nhttps://duck.co/ia/view/opam","created_at":"2016-05-21T23:26:54Z","updated_at":"2016-06-21T22:29:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5293d145ad6c69532a7ddae9591802305fb54305","assignee":{"login":"jdorweiler","id":1882892,"avatar_url":"https://avatars.githubusercontent.com/u/1882892?v=3","gravatar_id":"","url":"https://api.github.com/users/jdorweiler","html_url":"https://github.com/jdorweiler","followers_url":"https://api.github.com/users/jdorweiler/followers","following_url":"https://api.github.com/users/jdorweiler/following{/other_user}","gists_url":"https://api.github.com/users/jdorweiler/gists{/gist_id}","starred_url":"https://api.github.com/users/jdorweiler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jdorweiler/subscriptions","organizations_url":"https://api.github.com/users/jdorweiler/orgs","repos_url":"https://api.github.com/users/jdorweiler/repos","events_url":"https://api.github.com/users/jdorweiler/events{/privacy}","received_events_url":"https://api.github.com/users/jdorweiler/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-fathead/pulls/210/commits","review_comments_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-fathead/pulls/210/comments","review_comment_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-fathead/pulls/comments{/number}","comments_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-fathead/issues/210/comments","statuses_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-fathead/statuses/1496dbda235e9b713ca458aebe93d6797b1911c4","head":{"label":"pjhampton:opam","ref":"opam","sha":"1496dbda235e9b713ca458aebe93d6797b1911c4","user":{"login":"pjhampton","id":8960296,"avatar_url":"https://avatars.githubusercontent.com/u/8960296?v=3","gravatar_id":"","url":"https://api.github.com/users/pjhampton","html_url":"https://github.com/pjhampton","followers_url":"https://api.github.com/users/pjhampton/followers","following_url":"https://api.github.com/users/pjhampton/following{/other_user}","gists_url":"https://api.github.com/users/pjhampton/gists{/gist_id}","starred_url":"https://api.github.com/users/pjhampton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pjhampton/subscriptions","organizations_url":"https://api.github.com/users/pjhampton/orgs","repos_url":"https://api.github.com/users/pjhampton/repos","events_url":"https://api.github.com/users/pjhampton/events{/privacy}","received_events_url":"https://api.github.com/users/pjhampton/received_events","type":"User","site_admin":false},"repo":{"id":53757378,"name":"zeroclickinfo-fathead","full_name":"pjhampton/zeroclickinfo-fathead","owner":{"login":"pjhampton","id":8960296,"avatar_url":"https://avatars.githubusercontent.com/u/8960296?v=3","gravatar_id":"","url":"https://api.github.com/users/pjhampton","html_url":"https://github.com/pjhampton","followers_url":"https://api.github.com/users/pjhampton/followers","following_url":"https://api.github.com/users/pjhampton/following{/other_user}","gists_url":"https://api.github.com/users/pjhampton/gists{/gist_id}","starred_url":"https://api.github.com/users/pjhampton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pjhampton/subscriptions","organizations_url":"https://api.github.com/users/pjhampton/orgs","repos_url":"https://api.github.com/users/pjhampton/repos","events_url":"https://api.github.com/users/pjhampton/events{/privacy}","received_events_url":"https://api.github.com/users/pjhampton/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/pjhampton/zeroclickinfo-fathead","description":"DuckDuckGo Instant Answers based on keyword data files","fork":true,"url":"https://api.github.com/repos/pjhampton/zeroclickinfo-fathead","forks_url":"https://api.github.com/repos/pjhampton/zeroclickinfo-fathead/forks","keys_url":"https://api.github.com/repos/pjhampton/zeroclickinfo-fathead/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pjhampton/zeroclickinfo-fathead/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pjhampton/zeroclickinfo-fathead/teams","hooks_url":"https://api.github.com/repos/pjhampton/zeroclickinfo-fathead/hooks","issue_events_url":"https://api.github.com/repos/pjhampton/zeroclickinfo-fathead/issues/events{/number}","events_url":"https://api.github.com/repos/pjhampton/zeroclickinfo-fathead/events","assignees_url":"https://api.github.com/repos/pjhampton/zeroclickinfo-fathead/assignees{/user}","branches_url":"https://api.github.com/repos/pjhampton/zeroclickinfo-fathead/branches{/branch}","tags_url":"https://api.github.com/repos/pjhampton/zeroclickinfo-fathead/tags","blobs_url":"https://api.github.com/repos/pjhampton/zeroclickinfo-fathead/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pjhampton/zeroclickinfo-fathead/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pjhampton/zeroclickinfo-fathead/git/refs{/sha}","trees_url":"https://api.github.com/repos/pjhampton/zeroclickinfo-fathead/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pjhampton/zeroclickinfo-fathead/statuses/{sha}","languages_url":"https://api.github.com/repos/pjhampton/zeroclickinfo-fathead/languages","stargazers_url":"https://api.github.com/repos/pjhampton/zeroclickinfo-fathead/stargazers","contributors_url":"https://api.github.com/repos/pjhampton/zeroclickinfo-fathead/contributors","subscribers_url":"https://api.github.com/repos/pjhampton/zeroclickinfo-fathead/subscribers","subscription_url":"https://api.github.com/repos/pjhampton/zeroclickinfo-fathead/subscription","commits_url":"https://api.github.com/repos/pjhampton/zeroclickinfo-fathead/commits{/sha}","git_commits_url":"https://api.github.com/repos/pjhampton/zeroclickinfo-fathead/git/commits{/sha}","comments_url":"https://api.github.com/repos/pjhampton/zeroclickinfo-fathead/comments{/number}","issue_comment_url":"https://api.github.com/repos/pjhampton/zeroclickinfo-fathead/issues/comments{/number}","contents_url":"https://api.github.com/repos/pjhampton/zeroclickinfo-fathead/contents/{+path}","compare_url":"https://api.github.com/repos/pjhampton/zeroclickinfo-fathead/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pjhampton/zeroclickinfo-fathead/merges","archive_url":"https://api.github.com/repos/pjhampton/zeroclickinfo-fathead/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pjhampton/zeroclickinfo-fathead/downloads","issues_url":"https://api.github.com/repos/pjhampton/zeroclickinfo-fathead/issues{/number}","pulls_url":"https://api.github.com/repos/pjhampton/zeroclickinfo-fathead/pulls{/number}","milestones_url":"https://api.github.com/repos/pjhampton/zeroclickinfo-fathead/milestones{/number}","notifications_url":"https://api.github.com/repos/pjhampton/zeroclickinfo-fathead/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pjhampton/zeroclickinfo-fathead/labels{/name}","releases_url":"https://api.github.com/repos/pjhampton/zeroclickinfo-fathead/releases{/id}","deployments_url":"https://api.github.com/repos/pjhampton/zeroclickinfo-fathead/deployments","created_at":"2016-03-12T22:57:28Z","updated_at":"2016-03-12T22:57:30Z","pushed_at":"2016-06-21T22:11:47Z","git_url":"git://github.com/pjhampton/zeroclickinfo-fathead.git","ssh_url":"git@github.com:pjhampton/zeroclickinfo-fathead.git","clone_url":"https://github.com/pjhampton/zeroclickinfo-fathead.git","svn_url":"https://github.com/pjhampton/zeroclickinfo-fathead","homepage":"http://duckduckhack.com/","size":1906,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"duckduckgo:master","ref":"master","sha":"2de71b1d759cb0b13d9cb007687ccf6cd750ef72","user":{"login":"duckduckgo","id":342708,"avatar_url":"https://avatars.githubusercontent.com/u/342708?v=3","gravatar_id":"","url":"https://api.github.com/users/duckduckgo","html_url":"https://github.com/duckduckgo","followers_url":"https://api.github.com/users/duckduckgo/followers","following_url":"https://api.github.com/users/duckduckgo/following{/other_user}","gists_url":"https://api.github.com/users/duckduckgo/gists{/gist_id}","starred_url":"https://api.github.com/users/duckduckgo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/duckduckgo/subscriptions","organizations_url":"https://api.github.com/users/duckduckgo/orgs","repos_url":"https://api.github.com/users/duckduckgo/repos","events_url":"https://api.github.com/users/duckduckgo/events{/privacy}","received_events_url":"https://api.github.com/users/duckduckgo/received_events","type":"Organization","site_admin":false},"repo":{"id":1997918,"name":"zeroclickinfo-fathead","full_name":"duckduckgo/zeroclickinfo-fathead","owner":{"login":"duckduckgo","id":342708,"avatar_url":"https://avatars.githubusercontent.com/u/342708?v=3","gravatar_id":"","url":"https://api.github.com/users/duckduckgo","html_url":"https://github.com/duckduckgo","followers_url":"https://api.github.com/users/duckduckgo/followers","following_url":"https://api.github.com/users/duckduckgo/following{/other_user}","gists_url":"https://api.github.com/users/duckduckgo/gists{/gist_id}","starred_url":"https://api.github.com/users/duckduckgo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/duckduckgo/subscriptions","organizations_url":"https://api.github.com/users/duckduckgo/orgs","repos_url":"https://api.github.com/users/duckduckgo/repos","events_url":"https://api.github.com/users/duckduckgo/events{/privacy}","received_events_url":"https://api.github.com/users/duckduckgo/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/duckduckgo/zeroclickinfo-fathead","description":"DuckDuckGo Instant Answers based on keyword data files","fork":false,"url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-fathead","forks_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-fathead/forks","keys_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-fathead/keys{/key_id}","collaborators_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-fathead/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-fathead/teams","hooks_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-fathead/hooks","issue_events_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-fathead/issues/events{/number}","events_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-fathead/events","assignees_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-fathead/assignees{/user}","branches_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-fathead/branches{/branch}","tags_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-fathead/tags","blobs_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-fathead/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-fathead/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-fathead/git/refs{/sha}","trees_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-fathead/git/trees{/sha}","statuses_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-fathead/statuses/{sha}","languages_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-fathead/languages","stargazers_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-fathead/stargazers","contributors_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-fathead/contributors","subscribers_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-fathead/subscribers","subscription_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-fathead/subscription","commits_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-fathead/commits{/sha}","git_commits_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-fathead/git/commits{/sha}","comments_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-fathead/comments{/number}","issue_comment_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-fathead/issues/comments{/number}","contents_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-fathead/contents/{+path}","compare_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-fathead/compare/{base}...{head}","merges_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-fathead/merges","archive_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-fathead/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-fathead/downloads","issues_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-fathead/issues{/number}","pulls_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-fathead/pulls{/number}","milestones_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-fathead/milestones{/number}","notifications_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-fathead/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-fathead/labels{/name}","releases_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-fathead/releases{/id}","deployments_url":"https://api.github.com/repos/duckduckgo/zeroclickinfo-fathead/deployments","created_at":"2011-07-04T23:42:33Z","updated_at":"2016-06-19T14:34:16Z","pushed_at":"2016-06-21T22:11:47Z","git_url":"git://github.com/duckduckgo/zeroclickinfo-fathead.git","ssh_url":"git@github.com:duckduckgo/zeroclickinfo-fathead.git","clone_url":"https://github.com/duckduckgo/zeroclickinfo-fathead.git","svn_url":"https://github.com/duckduckgo/zeroclickinfo-fathead","homepage":"http://duckduckhack.com/","size":3764,"stargazers_count":147,"watchers_count":147,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":232,"mirror_url":null,"open_issues_count":50,"forks":232,"open_issues":50,"watchers":147,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/duckduckgo/zeroclickinfo-fathead/pulls/210"},"html":{"href":"https://github.com/duckduckgo/zeroclickinfo-fathead/pull/210"},"issue":{"href":"https://api.github.com/repos/duckduckgo/zeroclickinfo-fathead/issues/210"},"comments":{"href":"https://api.github.com/repos/duckduckgo/zeroclickinfo-fathead/issues/210/comments"},"review_comments":{"href":"https://api.github.com/repos/duckduckgo/zeroclickinfo-fathead/pulls/210/comments"},"review_comment":{"href":"https://api.github.com/repos/duckduckgo/zeroclickinfo-fathead/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/duckduckgo/zeroclickinfo-fathead/pulls/210/commits"},"statuses":{"href":"https://api.github.com/repos/duckduckgo/zeroclickinfo-fathead/statuses/1496dbda235e9b713ca458aebe93d6797b1911c4"}}}}
{"actor":{"display_login":"milmazz"}}