{"action":"created","comment":{"url":"https://api.github.com/repos/peterbe/hashin/pulls/comments/92245304","pull_request_review_id":12757263,"id":92245304,"diff_hunk":"@@ -317,6 +295,75 @@ def add_hashes(releases, algorithm, verbose=False):\n         found['hash'] = pip.commands.hash._hash_of_file(filename, algorithm)\n         if verbose:\n             _verbose(\"  Hash\", found['hash'])\n+        yield {\n+            \"url\": url,\n+            \"hash\": found[\"hash\"]\n+        }\n+\n+\n+def get_package_hashes(package, version=None, algorithm=DEFAULT_ALGORITHM, python_versions=(),\n+                       verbose=False):\n+    \"\"\"\n+    Gets the hashes for the given package.\n+\n+    >>> get_package_hashes('hashin')\n+    {\n+        \"package\": \"hashin\",\n+        \"version\": \"0.10\",\n+        \"hashes\": [\n+            {\n+                'url': 'https://pypi.python.org/packages/[...]',\n+                'hash': '45d1c5d2237a3b4f78b4198709fb2ecf[...]'\n+            },\n+            {\n+                'url': 'https://pypi.python.org/packages/[...]',\n+                'hash': '0d63bf4c115154781846ecf573049324[...]'\n+            },\n+            {\n+                'url': 'https://pypi.python.org/packages/[...]',\n+                'hash': 'c32e6d9fb09dc36ab9222c4606a1f43a[...]'\n+            }\n+        ]\n+    }\n+    \"\"\"\n+    data = get_package_data(package, verbose)\n+    if not version:\n+        version = get_latest_version(data)\n+        assert version\n+        if verbose:\n+            _verbose(\"Latest version for\", version)\n+\n+    # Independent of how you like to case type it, pick the correct\n+    # name from the PyPI index.\n+    package = data['info']['name']\n+\n+    try:\n+        releases = data['releases'][version]\n+    except KeyError:\n+        raise PackageError('No data found for version {0}'.format(version))\n+\n+    if python_versions:\n+        releases = filter_releases(releases, python_versions)\n+\n+    if not releases:\n+        if python_versions:\n+            raise PackageError(\n+                \"No releases could be found for {0} matching Python versions {1}\"\n+                .format(version, python_versions)\n+            )\n+        else:\n+            raise PackageError(\n+                \"No releases could be found for {0}\".format(version, python_versions)","path":"hashin.py","position":149,"original_position":149,"commit_id":"0140f076dbc87f439879a0fa2ee8700a25a0b242","original_commit_id":"0140f076dbc87f439879a0fa2ee8700a25a0b242","user":{"login":"peterbe","id":26739,"avatar_url":"https://avatars.githubusercontent.com/u/26739?v=3","gravatar_id":"","url":"https://api.github.com/users/peterbe","html_url":"https://github.com/peterbe","followers_url":"https://api.github.com/users/peterbe/followers","following_url":"https://api.github.com/users/peterbe/following{/other_user}","gists_url":"https://api.github.com/users/peterbe/gists{/gist_id}","starred_url":"https://api.github.com/users/peterbe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peterbe/subscriptions","organizations_url":"https://api.github.com/users/peterbe/orgs","repos_url":"https://api.github.com/users/peterbe/repos","events_url":"https://api.github.com/users/peterbe/events{/privacy}","received_events_url":"https://api.github.com/users/peterbe/received_events","type":"User","site_admin":false},"body":"No need for `python_versions` here. ","created_at":"2016-12-13T19:22:14Z","updated_at":"2016-12-13T19:30:25Z","html_url":"https://github.com/peterbe/hashin/pull/31#discussion_r92245304","pull_request_url":"https://api.github.com/repos/peterbe/hashin/pulls/31","_links":{"self":{"href":"https://api.github.com/repos/peterbe/hashin/pulls/comments/92245304"},"html":{"href":"https://github.com/peterbe/hashin/pull/31#discussion_r92245304"},"pull_request":{"href":"https://api.github.com/repos/peterbe/hashin/pulls/31"}}},"pull_request":{"url":"https://api.github.com/repos/peterbe/hashin/pulls/31","id":96707454,"html_url":"https://github.com/peterbe/hashin/pull/31","diff_url":"https://github.com/peterbe/hashin/pull/31.diff","patch_url":"https://github.com/peterbe/hashin/pull/31.patch","issue_url":"https://api.github.com/repos/peterbe/hashin/issues/31","number":31,"state":"open","locked":false,"title":"make hashin work as a library","user":{"login":"jayfk","id":2930472,"avatar_url":"https://avatars.githubusercontent.com/u/2930472?v=3","gravatar_id":"","url":"https://api.github.com/users/jayfk","html_url":"https://github.com/jayfk","followers_url":"https://api.github.com/users/jayfk/followers","following_url":"https://api.github.com/users/jayfk/following{/other_user}","gists_url":"https://api.github.com/users/jayfk/gists{/gist_id}","starred_url":"https://api.github.com/users/jayfk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jayfk/subscriptions","organizations_url":"https://api.github.com/users/jayfk/orgs","repos_url":"https://api.github.com/users/jayfk/repos","events_url":"https://api.github.com/users/jayfk/events{/privacy}","received_events_url":"https://api.github.com/users/jayfk/received_events","type":"User","site_admin":false},"body":"I've refactored the code so that `hashin` can be used as a library (#29).\r\n\r\n```python\r\nimport hashin\r\nhashin.get_package_hashes('hashin')\r\n```\r\n\r\n```\r\n    {\r\n        \"package\": \"hashin\",\r\n        \"version\": \"0.10\",\r\n        \"hashes\": [\r\n            {\r\n                'url': 'https://pypi.python.org/packages/[...]',\r\n                'hash': '45d1c5d2237a3b4f78b4198709fb2ecf[...]'\r\n            },\r\n            {\r\n                'url': 'https://pypi.python.org/packages/[...]',\r\n                'hash': '0d63bf4c115154781846ecf573049324[...]'\r\n            },\r\n            {\r\n                'url': 'https://pypi.python.org/packages/[...]',\r\n                'hash': 'c32e6d9fb09dc36ab9222c4606a1f43a[...]'\r\n            }\r\n        ]\r\n    }\r\n```","created_at":"2016-12-06T11:33:35Z","updated_at":"2016-12-13T19:30:25Z","closed_at":null,"merged_at":null,"merge_commit_sha":"abadb123907bba9088fc056fcf83aa839c246a6f","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/peterbe/hashin/pulls/31/commits","review_comments_url":"https://api.github.com/repos/peterbe/hashin/pulls/31/comments","review_comment_url":"https://api.github.com/repos/peterbe/hashin/pulls/comments{/number}","comments_url":"https://api.github.com/repos/peterbe/hashin/issues/31/comments","statuses_url":"https://api.github.com/repos/peterbe/hashin/statuses/0140f076dbc87f439879a0fa2ee8700a25a0b242","head":{"label":"jayfk:master","ref":"master","sha":"0140f076dbc87f439879a0fa2ee8700a25a0b242","user":{"login":"jayfk","id":2930472,"avatar_url":"https://avatars.githubusercontent.com/u/2930472?v=3","gravatar_id":"","url":"https://api.github.com/users/jayfk","html_url":"https://github.com/jayfk","followers_url":"https://api.github.com/users/jayfk/followers","following_url":"https://api.github.com/users/jayfk/following{/other_user}","gists_url":"https://api.github.com/users/jayfk/gists{/gist_id}","starred_url":"https://api.github.com/users/jayfk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jayfk/subscriptions","organizations_url":"https://api.github.com/users/jayfk/orgs","repos_url":"https://api.github.com/users/jayfk/repos","events_url":"https://api.github.com/users/jayfk/events{/privacy}","received_events_url":"https://api.github.com/users/jayfk/received_events","type":"User","site_admin":false},"repo":{"id":75724987,"name":"hashin","full_name":"jayfk/hashin","owner":{"login":"jayfk","id":2930472,"avatar_url":"https://avatars.githubusercontent.com/u/2930472?v=3","gravatar_id":"","url":"https://api.github.com/users/jayfk","html_url":"https://github.com/jayfk","followers_url":"https://api.github.com/users/jayfk/followers","following_url":"https://api.github.com/users/jayfk/following{/other_user}","gists_url":"https://api.github.com/users/jayfk/gists{/gist_id}","starred_url":"https://api.github.com/users/jayfk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jayfk/subscriptions","organizations_url":"https://api.github.com/users/jayfk/orgs","repos_url":"https://api.github.com/users/jayfk/repos","events_url":"https://api.github.com/users/jayfk/events{/privacy}","received_events_url":"https://api.github.com/users/jayfk/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jayfk/hashin","description":"Helping you write hashed entries for packages in your requirements.txt","fork":true,"url":"https://api.github.com/repos/jayfk/hashin","forks_url":"https://api.github.com/repos/jayfk/hashin/forks","keys_url":"https://api.github.com/repos/jayfk/hashin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jayfk/hashin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jayfk/hashin/teams","hooks_url":"https://api.github.com/repos/jayfk/hashin/hooks","issue_events_url":"https://api.github.com/repos/jayfk/hashin/issues/events{/number}","events_url":"https://api.github.com/repos/jayfk/hashin/events","assignees_url":"https://api.github.com/repos/jayfk/hashin/assignees{/user}","branches_url":"https://api.github.com/repos/jayfk/hashin/branches{/branch}","tags_url":"https://api.github.com/repos/jayfk/hashin/tags","blobs_url":"https://api.github.com/repos/jayfk/hashin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jayfk/hashin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jayfk/hashin/git/refs{/sha}","trees_url":"https://api.github.com/repos/jayfk/hashin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jayfk/hashin/statuses/{sha}","languages_url":"https://api.github.com/repos/jayfk/hashin/languages","stargazers_url":"https://api.github.com/repos/jayfk/hashin/stargazers","contributors_url":"https://api.github.com/repos/jayfk/hashin/contributors","subscribers_url":"https://api.github.com/repos/jayfk/hashin/subscribers","subscription_url":"https://api.github.com/repos/jayfk/hashin/subscription","commits_url":"https://api.github.com/repos/jayfk/hashin/commits{/sha}","git_commits_url":"https://api.github.com/repos/jayfk/hashin/git/commits{/sha}","comments_url":"https://api.github.com/repos/jayfk/hashin/comments{/number}","issue_comment_url":"https://api.github.com/repos/jayfk/hashin/issues/comments{/number}","contents_url":"https://api.github.com/repos/jayfk/hashin/contents/{+path}","compare_url":"https://api.github.com/repos/jayfk/hashin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jayfk/hashin/merges","archive_url":"https://api.github.com/repos/jayfk/hashin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jayfk/hashin/downloads","issues_url":"https://api.github.com/repos/jayfk/hashin/issues{/number}","pulls_url":"https://api.github.com/repos/jayfk/hashin/pulls{/number}","milestones_url":"https://api.github.com/repos/jayfk/hashin/milestones{/number}","notifications_url":"https://api.github.com/repos/jayfk/hashin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jayfk/hashin/labels{/name}","releases_url":"https://api.github.com/repos/jayfk/hashin/releases{/id}","deployments_url":"https://api.github.com/repos/jayfk/hashin/deployments","created_at":"2016-12-06T11:28:03Z","updated_at":"2016-12-06T11:28:04Z","pushed_at":"2016-12-06T14:28:31Z","git_url":"git://github.com/jayfk/hashin.git","ssh_url":"git@github.com:jayfk/hashin.git","clone_url":"https://github.com/jayfk/hashin.git","svn_url":"https://github.com/jayfk/hashin","homepage":"https://www.peterbe.com/plog/hashin","size":42,"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":"peterbe:master","ref":"master","sha":"6549e7a0cf88f62c5c38a2ac3a5b3ea069415f34","user":{"login":"peterbe","id":26739,"avatar_url":"https://avatars.githubusercontent.com/u/26739?v=3","gravatar_id":"","url":"https://api.github.com/users/peterbe","html_url":"https://github.com/peterbe","followers_url":"https://api.github.com/users/peterbe/followers","following_url":"https://api.github.com/users/peterbe/following{/other_user}","gists_url":"https://api.github.com/users/peterbe/gists{/gist_id}","starred_url":"https://api.github.com/users/peterbe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peterbe/subscriptions","organizations_url":"https://api.github.com/users/peterbe/orgs","repos_url":"https://api.github.com/users/peterbe/repos","events_url":"https://api.github.com/users/peterbe/events{/privacy}","received_events_url":"https://api.github.com/users/peterbe/received_events","type":"User","site_admin":false},"repo":{"id":50450913,"name":"hashin","full_name":"peterbe/hashin","owner":{"login":"peterbe","id":26739,"avatar_url":"https://avatars.githubusercontent.com/u/26739?v=3","gravatar_id":"","url":"https://api.github.com/users/peterbe","html_url":"https://github.com/peterbe","followers_url":"https://api.github.com/users/peterbe/followers","following_url":"https://api.github.com/users/peterbe/following{/other_user}","gists_url":"https://api.github.com/users/peterbe/gists{/gist_id}","starred_url":"https://api.github.com/users/peterbe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peterbe/subscriptions","organizations_url":"https://api.github.com/users/peterbe/orgs","repos_url":"https://api.github.com/users/peterbe/repos","events_url":"https://api.github.com/users/peterbe/events{/privacy}","received_events_url":"https://api.github.com/users/peterbe/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/peterbe/hashin","description":"Helping you write hashed entries for packages in your requirements.txt","fork":false,"url":"https://api.github.com/repos/peterbe/hashin","forks_url":"https://api.github.com/repos/peterbe/hashin/forks","keys_url":"https://api.github.com/repos/peterbe/hashin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/peterbe/hashin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/peterbe/hashin/teams","hooks_url":"https://api.github.com/repos/peterbe/hashin/hooks","issue_events_url":"https://api.github.com/repos/peterbe/hashin/issues/events{/number}","events_url":"https://api.github.com/repos/peterbe/hashin/events","assignees_url":"https://api.github.com/repos/peterbe/hashin/assignees{/user}","branches_url":"https://api.github.com/repos/peterbe/hashin/branches{/branch}","tags_url":"https://api.github.com/repos/peterbe/hashin/tags","blobs_url":"https://api.github.com/repos/peterbe/hashin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/peterbe/hashin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/peterbe/hashin/git/refs{/sha}","trees_url":"https://api.github.com/repos/peterbe/hashin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/peterbe/hashin/statuses/{sha}","languages_url":"https://api.github.com/repos/peterbe/hashin/languages","stargazers_url":"https://api.github.com/repos/peterbe/hashin/stargazers","contributors_url":"https://api.github.com/repos/peterbe/hashin/contributors","subscribers_url":"https://api.github.com/repos/peterbe/hashin/subscribers","subscription_url":"https://api.github.com/repos/peterbe/hashin/subscription","commits_url":"https://api.github.com/repos/peterbe/hashin/commits{/sha}","git_commits_url":"https://api.github.com/repos/peterbe/hashin/git/commits{/sha}","comments_url":"https://api.github.com/repos/peterbe/hashin/comments{/number}","issue_comment_url":"https://api.github.com/repos/peterbe/hashin/issues/comments{/number}","contents_url":"https://api.github.com/repos/peterbe/hashin/contents/{+path}","compare_url":"https://api.github.com/repos/peterbe/hashin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/peterbe/hashin/merges","archive_url":"https://api.github.com/repos/peterbe/hashin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/peterbe/hashin/downloads","issues_url":"https://api.github.com/repos/peterbe/hashin/issues{/number}","pulls_url":"https://api.github.com/repos/peterbe/hashin/pulls{/number}","milestones_url":"https://api.github.com/repos/peterbe/hashin/milestones{/number}","notifications_url":"https://api.github.com/repos/peterbe/hashin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/peterbe/hashin/labels{/name}","releases_url":"https://api.github.com/repos/peterbe/hashin/releases{/id}","deployments_url":"https://api.github.com/repos/peterbe/hashin/deployments","created_at":"2016-01-26T18:49:10Z","updated_at":"2016-12-06T10:23:06Z","pushed_at":"2016-12-06T14:28:31Z","git_url":"git://github.com/peterbe/hashin.git","ssh_url":"git@github.com:peterbe/hashin.git","clone_url":"https://github.com/peterbe/hashin.git","svn_url":"https://github.com/peterbe/hashin","homepage":"https://www.peterbe.com/plog/hashin","size":42,"stargazers_count":31,"watchers_count":31,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":7,"forks":9,"open_issues":7,"watchers":31,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/peterbe/hashin/pulls/31"},"html":{"href":"https://github.com/peterbe/hashin/pull/31"},"issue":{"href":"https://api.github.com/repos/peterbe/hashin/issues/31"},"comments":{"href":"https://api.github.com/repos/peterbe/hashin/issues/31/comments"},"review_comments":{"href":"https://api.github.com/repos/peterbe/hashin/pulls/31/comments"},"review_comment":{"href":"https://api.github.com/repos/peterbe/hashin/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/peterbe/hashin/pulls/31/commits"},"statuses":{"href":"https://api.github.com/repos/peterbe/hashin/statuses/0140f076dbc87f439879a0fa2ee8700a25a0b242"}}}}
{"actor":{"display_login":"peterbe"}}