{"action":"created","comment":{"url":"https://api.github.com/repos/lakshbhasin/network_simulator/pulls/comments/42944409","id":42944409,"diff_hunk":"@@ -0,0 +1,79 @@\n+\"\"\"This module contains all device definitions.\n+\n+.. autosummary::\n+    Host\n+    Router\n+\"\"\"\n+\n+# Imports go here.\n+# e.g.    from .common import ACK_PACKET_SIZE_BITS\n+\n+class Device(object):\n+    \"\"\"Representation of a device (Host or Router).\n+\n+    :param str name: name of this device from the input file.\n+    :param str address: IP address of this device.\n+    :ivar str name: name of this device from the input file.\n+    :ivar str address: IP address of this device.\n+    \"\"\"\n+    # TODO(team): Do we need a \"name\" here?\n+    def __init__(self, name=None, address=None):\n+        self.name = name\n+        self.address = address\n+\n+    def __eq__(self, other):\n+        return self.address == other.address\n+\n+    def __neq__(self, other):\n+        return not __neq__(self, other)\n+\n+    # TODO(team): More event subclasses to come?\n+\n+class Host(Device):\n+    \"\"\"Representation of a host.\n+    A host sends :class:`Packets <.Packet>` through a :class:`.Link` to a\n+    :class:`.Router` or a :class:`.Host`.\n+\n+    :param dict flows: :class:`Flows <.Flow>` from this :class:`.Host`.\n+    :param link: :class:`Link` connected to this :class:`.Host`.\n+    :ivar dict flows: :class:`Flows <.Flow>` from this :class:`.Host`.\n+    :ivar link: :class:`Link` connected to this :class:`.Host`.\n+    \"\"\"\n+    def __init__(self, name=None, address=None, flows={}, link=None):\n+        Device.__init__(self, name, address)\n+        self.flows = flows\n+        self.link = link\n+\n+    def __str__(self):\n+        return 'A host at IP address: ' + self.address\n+\n+    # TODO(team): More event subclasses to come?\n+\n+class Router(Device):\n+    \"\"\"Representation of a router.\n+    A router routes :class:`Packets <.Packet>` through the network to their\n+    destinations, which are :class:`Hosts <.Host>`.\n+\n+    :ivar dict routing_table: a routing table hashmap from Host to connected\n+        :class:`Links <.Link>`.\n+    :ivar dict old_routing_table: same as routing_table, except this is an\n+        archived version from previous update event (wait until next update\n+        event to repeat).\n+    :ivar dict device_distances: a hashmap from (:class:`.Device`,\n+        :class:`.Device`) sets to the cost to travel between those two\n+        :class:`Devices <.Device>` (in seconds).\n+    :ivar list links: all :class:`Links <.Link>` connected to this\n+        :class:`.Router`.\n+    \"\"\"\n+    def __init__(self, name=None, address=None, routing_table={},\n+                 old_routing_table={}, device_distances={}, links=[]):\n+        Device.__init__(self, name, address)\n+        self.routing_table = routing_table\n+        self.old_routing_table = old_routing_table\n+        self.device_distances = device_distances\n+        self.links = links\n+\n+    def __str__(self):","path":"network_simulator/device.py","position":76,"original_position":76,"commit_id":"d909913ef0d05308003438ddc823e10289c8b2a4","original_commit_id":"d909913ef0d05308003438ddc823e10289c8b2a4","user":{"login":"lakshbhasin","id":1183879,"avatar_url":"https://avatars.githubusercontent.com/u/1183879?v=3","gravatar_id":"","url":"https://api.github.com/users/lakshbhasin","html_url":"https://github.com/lakshbhasin","followers_url":"https://api.github.com/users/lakshbhasin/followers","following_url":"https://api.github.com/users/lakshbhasin/following{/other_user}","gists_url":"https://api.github.com/users/lakshbhasin/gists{/gist_id}","starred_url":"https://api.github.com/users/lakshbhasin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lakshbhasin/subscriptions","organizations_url":"https://api.github.com/users/lakshbhasin/orgs","repos_url":"https://api.github.com/users/lakshbhasin/repos","events_url":"https://api.github.com/users/lakshbhasin/events{/privacy}","received_events_url":"https://api.github.com/users/lakshbhasin/received_events","type":"User","site_admin":false},"body":"Use __repr__ instead of __str__.","created_at":"2015-10-25T12:47:24Z","updated_at":"2015-10-25T12:47:24Z","html_url":"https://github.com/lakshbhasin/network_simulator/pull/1#discussion_r42944409","pull_request_url":"https://api.github.com/repos/lakshbhasin/network_simulator/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/lakshbhasin/network_simulator/pulls/comments/42944409"},"html":{"href":"https://github.com/lakshbhasin/network_simulator/pull/1#discussion_r42944409"},"pull_request":{"href":"https://api.github.com/repos/lakshbhasin/network_simulator/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/lakshbhasin/network_simulator/pulls/1","id":48677661,"html_url":"https://github.com/lakshbhasin/network_simulator/pull/1","diff_url":"https://github.com/lakshbhasin/network_simulator/pull/1.diff","patch_url":"https://github.com/lakshbhasin/network_simulator/pull/1.patch","issue_url":"https://api.github.com/repos/lakshbhasin/network_simulator/issues/1","number":1,"state":"open","locked":false,"title":"Set up basic setuptools framework, common.py, and Device class.","user":{"login":"lakshbhasin","id":1183879,"avatar_url":"https://avatars.githubusercontent.com/u/1183879?v=3","gravatar_id":"","url":"https://api.github.com/users/lakshbhasin","html_url":"https://github.com/lakshbhasin","followers_url":"https://api.github.com/users/lakshbhasin/followers","following_url":"https://api.github.com/users/lakshbhasin/following{/other_user}","gists_url":"https://api.github.com/users/lakshbhasin/gists{/gist_id}","starred_url":"https://api.github.com/users/lakshbhasin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lakshbhasin/subscriptions","organizations_url":"https://api.github.com/users/lakshbhasin/orgs","repos_url":"https://api.github.com/users/lakshbhasin/repos","events_url":"https://api.github.com/users/lakshbhasin/events{/privacy}","received_events_url":"https://api.github.com/users/lakshbhasin/received_events","type":"User","site_admin":false},"body":"Not sure if we would like to split the Device file into host.py\r\nand router.py as planned. Asking for a code review. README\r\nmodified according to changes.","created_at":"2015-10-25T12:39:17Z","updated_at":"2015-10-25T12:47:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0ff39b76bb17d20bcaa089eed7ca847c66810326","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/lakshbhasin/network_simulator/pulls/1/commits","review_comments_url":"https://api.github.com/repos/lakshbhasin/network_simulator/pulls/1/comments","review_comment_url":"https://api.github.com/repos/lakshbhasin/network_simulator/pulls/comments{/number}","comments_url":"https://api.github.com/repos/lakshbhasin/network_simulator/issues/1/comments","statuses_url":"https://api.github.com/repos/lakshbhasin/network_simulator/statuses/d909913ef0d05308003438ddc823e10289c8b2a4","head":{"label":"lakshbhasin:sharon-basic-device-class","ref":"sharon-basic-device-class","sha":"d909913ef0d05308003438ddc823e10289c8b2a4","user":{"login":"lakshbhasin","id":1183879,"avatar_url":"https://avatars.githubusercontent.com/u/1183879?v=3","gravatar_id":"","url":"https://api.github.com/users/lakshbhasin","html_url":"https://github.com/lakshbhasin","followers_url":"https://api.github.com/users/lakshbhasin/followers","following_url":"https://api.github.com/users/lakshbhasin/following{/other_user}","gists_url":"https://api.github.com/users/lakshbhasin/gists{/gist_id}","starred_url":"https://api.github.com/users/lakshbhasin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lakshbhasin/subscriptions","organizations_url":"https://api.github.com/users/lakshbhasin/orgs","repos_url":"https://api.github.com/users/lakshbhasin/repos","events_url":"https://api.github.com/users/lakshbhasin/events{/privacy}","received_events_url":"https://api.github.com/users/lakshbhasin/received_events","type":"User","site_admin":false},"repo":{"id":44171299,"name":"network_simulator","full_name":"lakshbhasin/network_simulator","owner":{"login":"lakshbhasin","id":1183879,"avatar_url":"https://avatars.githubusercontent.com/u/1183879?v=3","gravatar_id":"","url":"https://api.github.com/users/lakshbhasin","html_url":"https://github.com/lakshbhasin","followers_url":"https://api.github.com/users/lakshbhasin/followers","following_url":"https://api.github.com/users/lakshbhasin/following{/other_user}","gists_url":"https://api.github.com/users/lakshbhasin/gists{/gist_id}","starred_url":"https://api.github.com/users/lakshbhasin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lakshbhasin/subscriptions","organizations_url":"https://api.github.com/users/lakshbhasin/orgs","repos_url":"https://api.github.com/users/lakshbhasin/repos","events_url":"https://api.github.com/users/lakshbhasin/events{/privacy}","received_events_url":"https://api.github.com/users/lakshbhasin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/lakshbhasin/network_simulator","description":"A network simulator for the project portion of CS 143","fork":false,"url":"https://api.github.com/repos/lakshbhasin/network_simulator","forks_url":"https://api.github.com/repos/lakshbhasin/network_simulator/forks","keys_url":"https://api.github.com/repos/lakshbhasin/network_simulator/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lakshbhasin/network_simulator/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lakshbhasin/network_simulator/teams","hooks_url":"https://api.github.com/repos/lakshbhasin/network_simulator/hooks","issue_events_url":"https://api.github.com/repos/lakshbhasin/network_simulator/issues/events{/number}","events_url":"https://api.github.com/repos/lakshbhasin/network_simulator/events","assignees_url":"https://api.github.com/repos/lakshbhasin/network_simulator/assignees{/user}","branches_url":"https://api.github.com/repos/lakshbhasin/network_simulator/branches{/branch}","tags_url":"https://api.github.com/repos/lakshbhasin/network_simulator/tags","blobs_url":"https://api.github.com/repos/lakshbhasin/network_simulator/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lakshbhasin/network_simulator/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lakshbhasin/network_simulator/git/refs{/sha}","trees_url":"https://api.github.com/repos/lakshbhasin/network_simulator/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lakshbhasin/network_simulator/statuses/{sha}","languages_url":"https://api.github.com/repos/lakshbhasin/network_simulator/languages","stargazers_url":"https://api.github.com/repos/lakshbhasin/network_simulator/stargazers","contributors_url":"https://api.github.com/repos/lakshbhasin/network_simulator/contributors","subscribers_url":"https://api.github.com/repos/lakshbhasin/network_simulator/subscribers","subscription_url":"https://api.github.com/repos/lakshbhasin/network_simulator/subscription","commits_url":"https://api.github.com/repos/lakshbhasin/network_simulator/commits{/sha}","git_commits_url":"https://api.github.com/repos/lakshbhasin/network_simulator/git/commits{/sha}","comments_url":"https://api.github.com/repos/lakshbhasin/network_simulator/comments{/number}","issue_comment_url":"https://api.github.com/repos/lakshbhasin/network_simulator/issues/comments{/number}","contents_url":"https://api.github.com/repos/lakshbhasin/network_simulator/contents/{+path}","compare_url":"https://api.github.com/repos/lakshbhasin/network_simulator/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lakshbhasin/network_simulator/merges","archive_url":"https://api.github.com/repos/lakshbhasin/network_simulator/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lakshbhasin/network_simulator/downloads","issues_url":"https://api.github.com/repos/lakshbhasin/network_simulator/issues{/number}","pulls_url":"https://api.github.com/repos/lakshbhasin/network_simulator/pulls{/number}","milestones_url":"https://api.github.com/repos/lakshbhasin/network_simulator/milestones{/number}","notifications_url":"https://api.github.com/repos/lakshbhasin/network_simulator/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lakshbhasin/network_simulator/labels{/name}","releases_url":"https://api.github.com/repos/lakshbhasin/network_simulator/releases{/id}","created_at":"2015-10-13T11:21:24Z","updated_at":"2015-10-13T11:21:24Z","pushed_at":"2015-10-25T12:39:17Z","git_url":"git://github.com/lakshbhasin/network_simulator.git","ssh_url":"git@github.com:lakshbhasin/network_simulator.git","clone_url":"https://github.com/lakshbhasin/network_simulator.git","svn_url":"https://github.com/lakshbhasin/network_simulator","homepage":null,"size":144,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"lakshbhasin:master","ref":"master","sha":"f97c32dd8015b7db329340ced5c6bf64935155ca","user":{"login":"lakshbhasin","id":1183879,"avatar_url":"https://avatars.githubusercontent.com/u/1183879?v=3","gravatar_id":"","url":"https://api.github.com/users/lakshbhasin","html_url":"https://github.com/lakshbhasin","followers_url":"https://api.github.com/users/lakshbhasin/followers","following_url":"https://api.github.com/users/lakshbhasin/following{/other_user}","gists_url":"https://api.github.com/users/lakshbhasin/gists{/gist_id}","starred_url":"https://api.github.com/users/lakshbhasin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lakshbhasin/subscriptions","organizations_url":"https://api.github.com/users/lakshbhasin/orgs","repos_url":"https://api.github.com/users/lakshbhasin/repos","events_url":"https://api.github.com/users/lakshbhasin/events{/privacy}","received_events_url":"https://api.github.com/users/lakshbhasin/received_events","type":"User","site_admin":false},"repo":{"id":44171299,"name":"network_simulator","full_name":"lakshbhasin/network_simulator","owner":{"login":"lakshbhasin","id":1183879,"avatar_url":"https://avatars.githubusercontent.com/u/1183879?v=3","gravatar_id":"","url":"https://api.github.com/users/lakshbhasin","html_url":"https://github.com/lakshbhasin","followers_url":"https://api.github.com/users/lakshbhasin/followers","following_url":"https://api.github.com/users/lakshbhasin/following{/other_user}","gists_url":"https://api.github.com/users/lakshbhasin/gists{/gist_id}","starred_url":"https://api.github.com/users/lakshbhasin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lakshbhasin/subscriptions","organizations_url":"https://api.github.com/users/lakshbhasin/orgs","repos_url":"https://api.github.com/users/lakshbhasin/repos","events_url":"https://api.github.com/users/lakshbhasin/events{/privacy}","received_events_url":"https://api.github.com/users/lakshbhasin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/lakshbhasin/network_simulator","description":"A network simulator for the project portion of CS 143","fork":false,"url":"https://api.github.com/repos/lakshbhasin/network_simulator","forks_url":"https://api.github.com/repos/lakshbhasin/network_simulator/forks","keys_url":"https://api.github.com/repos/lakshbhasin/network_simulator/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lakshbhasin/network_simulator/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lakshbhasin/network_simulator/teams","hooks_url":"https://api.github.com/repos/lakshbhasin/network_simulator/hooks","issue_events_url":"https://api.github.com/repos/lakshbhasin/network_simulator/issues/events{/number}","events_url":"https://api.github.com/repos/lakshbhasin/network_simulator/events","assignees_url":"https://api.github.com/repos/lakshbhasin/network_simulator/assignees{/user}","branches_url":"https://api.github.com/repos/lakshbhasin/network_simulator/branches{/branch}","tags_url":"https://api.github.com/repos/lakshbhasin/network_simulator/tags","blobs_url":"https://api.github.com/repos/lakshbhasin/network_simulator/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lakshbhasin/network_simulator/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lakshbhasin/network_simulator/git/refs{/sha}","trees_url":"https://api.github.com/repos/lakshbhasin/network_simulator/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lakshbhasin/network_simulator/statuses/{sha}","languages_url":"https://api.github.com/repos/lakshbhasin/network_simulator/languages","stargazers_url":"https://api.github.com/repos/lakshbhasin/network_simulator/stargazers","contributors_url":"https://api.github.com/repos/lakshbhasin/network_simulator/contributors","subscribers_url":"https://api.github.com/repos/lakshbhasin/network_simulator/subscribers","subscription_url":"https://api.github.com/repos/lakshbhasin/network_simulator/subscription","commits_url":"https://api.github.com/repos/lakshbhasin/network_simulator/commits{/sha}","git_commits_url":"https://api.github.com/repos/lakshbhasin/network_simulator/git/commits{/sha}","comments_url":"https://api.github.com/repos/lakshbhasin/network_simulator/comments{/number}","issue_comment_url":"https://api.github.com/repos/lakshbhasin/network_simulator/issues/comments{/number}","contents_url":"https://api.github.com/repos/lakshbhasin/network_simulator/contents/{+path}","compare_url":"https://api.github.com/repos/lakshbhasin/network_simulator/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lakshbhasin/network_simulator/merges","archive_url":"https://api.github.com/repos/lakshbhasin/network_simulator/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lakshbhasin/network_simulator/downloads","issues_url":"https://api.github.com/repos/lakshbhasin/network_simulator/issues{/number}","pulls_url":"https://api.github.com/repos/lakshbhasin/network_simulator/pulls{/number}","milestones_url":"https://api.github.com/repos/lakshbhasin/network_simulator/milestones{/number}","notifications_url":"https://api.github.com/repos/lakshbhasin/network_simulator/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lakshbhasin/network_simulator/labels{/name}","releases_url":"https://api.github.com/repos/lakshbhasin/network_simulator/releases{/id}","created_at":"2015-10-13T11:21:24Z","updated_at":"2015-10-13T11:21:24Z","pushed_at":"2015-10-25T12:39:17Z","git_url":"git://github.com/lakshbhasin/network_simulator.git","ssh_url":"git@github.com:lakshbhasin/network_simulator.git","clone_url":"https://github.com/lakshbhasin/network_simulator.git","svn_url":"https://github.com/lakshbhasin/network_simulator","homepage":null,"size":144,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/lakshbhasin/network_simulator/pulls/1"},"html":{"href":"https://github.com/lakshbhasin/network_simulator/pull/1"},"issue":{"href":"https://api.github.com/repos/lakshbhasin/network_simulator/issues/1"},"comments":{"href":"https://api.github.com/repos/lakshbhasin/network_simulator/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/lakshbhasin/network_simulator/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/lakshbhasin/network_simulator/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/lakshbhasin/network_simulator/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/lakshbhasin/network_simulator/statuses/d909913ef0d05308003438ddc823e10289c8b2a4"}}}}