{"action":"created","comment":{"url":"https://api.github.com/repos/phageParser/phageParser/pulls/comments/116071272","pull_request_review_id":37665855,"id":116071272,"diff_hunk":"@@ -0,0 +1,152 @@\n+import os\n+import time\n+import datetime\n+import functools\n+import zlib\n+import requests\n+import re\n+from tqdm import tqdm\n+\"\"\"\n+Decorator for downloading or updating files required for a function.\n+\"\"\"\n+def reqfile(func=None, path=None, url=None):\n+    if not func:\n+        return functools.partial(fetch_factory, path=path, url=url)\n+    @functools.wraps(test_func)\n+    def wrapper(*args, **kwargs):\n+        fetch(path, url)\n+        return func(*args, **kwargs)\n+    return wrapper\n+\n+\"\"\"\n+Downloads a file from url to a given path.\n+Also shows a progress bar to keep track.\n+\"\"\"\n+def downfile(path, url):\n+    r = requests.get(url, stream=True)\n+    r.raise_for_status()\n+    total_size = int(r.headers.get('content-length', 0))\n+    with open(path, 'wb') as f:\n+        chunk_size = 64*1024\n+        pbar = tqdm(total=total_size, unit='B', unit_scale=True)\n+        for data in r.iter_content(chunk_size):\n+            f.write(data)\n+            pbar.update(chunk_size)\n+\n+\"\"\"\n+Checks a given path for file and downloads if a url is given or file name\n+is an accession id. Also downloads the file if the remote location has a\n+more recent version. Gives an IOError if path does not exist and an accession id\n+can not be found.\n+    Usage:\n+        fetch('NC_000853.txt')\n+        fetch('DRDatabase.txt', 'http://crispr.i2bc.paris-saclay.fr/crispr/BLAST/DR/DRdatabase')","path":"fetch.py","position":null,"original_position":43,"commit_id":"c1a783848be8036fe339f6f8d687e58afcbfa3b5","original_commit_id":"4d9403c4c6d0472fb08184c7c6f7b0001c31a223","user":{"login":"cemyld","id":6137137,"avatar_url":"https://avatars3.githubusercontent.com/u/6137137?v=3","gravatar_id":"","url":"https://api.github.com/users/cemyld","html_url":"https://github.com/cemyld","followers_url":"https://api.github.com/users/cemyld/followers","following_url":"https://api.github.com/users/cemyld/following{/other_user}","gists_url":"https://api.github.com/users/cemyld/gists{/gist_id}","starred_url":"https://api.github.com/users/cemyld/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cemyld/subscriptions","organizations_url":"https://api.github.com/users/cemyld/orgs","repos_url":"https://api.github.com/users/cemyld/repos","events_url":"https://api.github.com/users/cemyld/events{/privacy}","received_events_url":"https://api.github.com/users/cemyld/received_events","type":"User","site_admin":false},"body":"Updated documentation for clarifying usage.","created_at":"2017-05-11T18:43:13Z","updated_at":"2017-05-11T18:43:13Z","html_url":"https://github.com/phageParser/phageParser/pull/143#discussion_r116071272","pull_request_url":"https://api.github.com/repos/phageParser/phageParser/pulls/143","_links":{"self":{"href":"https://api.github.com/repos/phageParser/phageParser/pulls/comments/116071272"},"html":{"href":"https://github.com/phageParser/phageParser/pull/143#discussion_r116071272"},"pull_request":{"href":"https://api.github.com/repos/phageParser/phageParser/pulls/143"}}},"pull_request":{"url":"https://api.github.com/repos/phageParser/phageParser/pulls/143","id":120157050,"html_url":"https://github.com/phageParser/phageParser/pull/143","diff_url":"https://github.com/phageParser/phageParser/pull/143.diff","patch_url":"https://github.com/phageParser/phageParser/pull/143.patch","issue_url":"https://api.github.com/repos/phageParser/phageParser/issues/143","number":143,"state":"open","locked":false,"title":"Filechecker and downloader","user":{"login":"cemyld","id":6137137,"avatar_url":"https://avatars3.githubusercontent.com/u/6137137?v=3","gravatar_id":"","url":"https://api.github.com/users/cemyld","html_url":"https://github.com/cemyld","followers_url":"https://api.github.com/users/cemyld/followers","following_url":"https://api.github.com/users/cemyld/following{/other_user}","gists_url":"https://api.github.com/users/cemyld/gists{/gist_id}","starred_url":"https://api.github.com/users/cemyld/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cemyld/subscriptions","organizations_url":"https://api.github.com/users/cemyld/orgs","repos_url":"https://api.github.com/users/cemyld/repos","events_url":"https://api.github.com/users/cemyld/events{/privacy}","received_events_url":"https://api.github.com/users/cemyld/received_events","type":"User","site_admin":false},"body":"Resolves #136 and also adds a function for downloading or updating general files from a given url or files with names that correspond to an accession id.","created_at":"2017-05-11T17:10:27Z","updated_at":"2017-05-11T18:43:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cf051e6fd0e7b1481d9443f23f6c783c60042993","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/phageParser/phageParser/pulls/143/commits","review_comments_url":"https://api.github.com/repos/phageParser/phageParser/pulls/143/comments","review_comment_url":"https://api.github.com/repos/phageParser/phageParser/pulls/comments{/number}","comments_url":"https://api.github.com/repos/phageParser/phageParser/issues/143/comments","statuses_url":"https://api.github.com/repos/phageParser/phageParser/statuses/c1a783848be8036fe339f6f8d687e58afcbfa3b5","head":{"label":"cemyld:filechecker","ref":"filechecker","sha":"c1a783848be8036fe339f6f8d687e58afcbfa3b5","user":{"login":"cemyld","id":6137137,"avatar_url":"https://avatars3.githubusercontent.com/u/6137137?v=3","gravatar_id":"","url":"https://api.github.com/users/cemyld","html_url":"https://github.com/cemyld","followers_url":"https://api.github.com/users/cemyld/followers","following_url":"https://api.github.com/users/cemyld/following{/other_user}","gists_url":"https://api.github.com/users/cemyld/gists{/gist_id}","starred_url":"https://api.github.com/users/cemyld/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cemyld/subscriptions","organizations_url":"https://api.github.com/users/cemyld/orgs","repos_url":"https://api.github.com/users/cemyld/repos","events_url":"https://api.github.com/users/cemyld/events{/privacy}","received_events_url":"https://api.github.com/users/cemyld/received_events","type":"User","site_admin":false},"repo":{"id":85874519,"name":"phageParser","full_name":"cemyld/phageParser","owner":{"login":"cemyld","id":6137137,"avatar_url":"https://avatars3.githubusercontent.com/u/6137137?v=3","gravatar_id":"","url":"https://api.github.com/users/cemyld","html_url":"https://github.com/cemyld","followers_url":"https://api.github.com/users/cemyld/followers","following_url":"https://api.github.com/users/cemyld/following{/other_user}","gists_url":"https://api.github.com/users/cemyld/gists{/gist_id}","starred_url":"https://api.github.com/users/cemyld/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cemyld/subscriptions","organizations_url":"https://api.github.com/users/cemyld/orgs","repos_url":"https://api.github.com/users/cemyld/repos","events_url":"https://api.github.com/users/cemyld/events{/privacy}","received_events_url":"https://api.github.com/users/cemyld/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/cemyld/phageParser","description":"A project to extract CRISPR information from open genetic data.","fork":true,"url":"https://api.github.com/repos/cemyld/phageParser","forks_url":"https://api.github.com/repos/cemyld/phageParser/forks","keys_url":"https://api.github.com/repos/cemyld/phageParser/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cemyld/phageParser/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cemyld/phageParser/teams","hooks_url":"https://api.github.com/repos/cemyld/phageParser/hooks","issue_events_url":"https://api.github.com/repos/cemyld/phageParser/issues/events{/number}","events_url":"https://api.github.com/repos/cemyld/phageParser/events","assignees_url":"https://api.github.com/repos/cemyld/phageParser/assignees{/user}","branches_url":"https://api.github.com/repos/cemyld/phageParser/branches{/branch}","tags_url":"https://api.github.com/repos/cemyld/phageParser/tags","blobs_url":"https://api.github.com/repos/cemyld/phageParser/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cemyld/phageParser/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cemyld/phageParser/git/refs{/sha}","trees_url":"https://api.github.com/repos/cemyld/phageParser/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cemyld/phageParser/statuses/{sha}","languages_url":"https://api.github.com/repos/cemyld/phageParser/languages","stargazers_url":"https://api.github.com/repos/cemyld/phageParser/stargazers","contributors_url":"https://api.github.com/repos/cemyld/phageParser/contributors","subscribers_url":"https://api.github.com/repos/cemyld/phageParser/subscribers","subscription_url":"https://api.github.com/repos/cemyld/phageParser/subscription","commits_url":"https://api.github.com/repos/cemyld/phageParser/commits{/sha}","git_commits_url":"https://api.github.com/repos/cemyld/phageParser/git/commits{/sha}","comments_url":"https://api.github.com/repos/cemyld/phageParser/comments{/number}","issue_comment_url":"https://api.github.com/repos/cemyld/phageParser/issues/comments{/number}","contents_url":"https://api.github.com/repos/cemyld/phageParser/contents/{+path}","compare_url":"https://api.github.com/repos/cemyld/phageParser/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cemyld/phageParser/merges","archive_url":"https://api.github.com/repos/cemyld/phageParser/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cemyld/phageParser/downloads","issues_url":"https://api.github.com/repos/cemyld/phageParser/issues{/number}","pulls_url":"https://api.github.com/repos/cemyld/phageParser/pulls{/number}","milestones_url":"https://api.github.com/repos/cemyld/phageParser/milestones{/number}","notifications_url":"https://api.github.com/repos/cemyld/phageParser/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cemyld/phageParser/labels{/name}","releases_url":"https://api.github.com/repos/cemyld/phageParser/releases{/id}","deployments_url":"https://api.github.com/repos/cemyld/phageParser/deployments","created_at":"2017-03-22T20:47:16Z","updated_at":"2017-03-22T20:47:18Z","pushed_at":"2017-05-11T18:42:24Z","git_url":"git://github.com/cemyld/phageParser.git","ssh_url":"git@github.com:cemyld/phageParser.git","clone_url":"https://github.com/cemyld/phageParser.git","svn_url":"https://github.com/cemyld/phageParser","homepage":"","size":23625,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"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":"phageParser:master","ref":"master","sha":"c1df51058b6f61bef12ba108df1149a5eae112f3","user":{"login":"phageParser","id":26488538,"avatar_url":"https://avatars0.githubusercontent.com/u/26488538?v=3","gravatar_id":"","url":"https://api.github.com/users/phageParser","html_url":"https://github.com/phageParser","followers_url":"https://api.github.com/users/phageParser/followers","following_url":"https://api.github.com/users/phageParser/following{/other_user}","gists_url":"https://api.github.com/users/phageParser/gists{/gist_id}","starred_url":"https://api.github.com/users/phageParser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phageParser/subscriptions","organizations_url":"https://api.github.com/users/phageParser/orgs","repos_url":"https://api.github.com/users/phageParser/repos","events_url":"https://api.github.com/users/phageParser/events{/privacy}","received_events_url":"https://api.github.com/users/phageParser/received_events","type":"Organization","site_admin":false},"repo":{"id":23163423,"name":"phageParser","full_name":"phageParser/phageParser","owner":{"login":"phageParser","id":26488538,"avatar_url":"https://avatars0.githubusercontent.com/u/26488538?v=3","gravatar_id":"","url":"https://api.github.com/users/phageParser","html_url":"https://github.com/phageParser","followers_url":"https://api.github.com/users/phageParser/followers","following_url":"https://api.github.com/users/phageParser/following{/other_user}","gists_url":"https://api.github.com/users/phageParser/gists{/gist_id}","starred_url":"https://api.github.com/users/phageParser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phageParser/subscriptions","organizations_url":"https://api.github.com/users/phageParser/orgs","repos_url":"https://api.github.com/users/phageParser/repos","events_url":"https://api.github.com/users/phageParser/events{/privacy}","received_events_url":"https://api.github.com/users/phageParser/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/phageParser/phageParser","description":"A project to extract CRISPR information from open genetic data.","fork":false,"url":"https://api.github.com/repos/phageParser/phageParser","forks_url":"https://api.github.com/repos/phageParser/phageParser/forks","keys_url":"https://api.github.com/repos/phageParser/phageParser/keys{/key_id}","collaborators_url":"https://api.github.com/repos/phageParser/phageParser/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/phageParser/phageParser/teams","hooks_url":"https://api.github.com/repos/phageParser/phageParser/hooks","issue_events_url":"https://api.github.com/repos/phageParser/phageParser/issues/events{/number}","events_url":"https://api.github.com/repos/phageParser/phageParser/events","assignees_url":"https://api.github.com/repos/phageParser/phageParser/assignees{/user}","branches_url":"https://api.github.com/repos/phageParser/phageParser/branches{/branch}","tags_url":"https://api.github.com/repos/phageParser/phageParser/tags","blobs_url":"https://api.github.com/repos/phageParser/phageParser/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/phageParser/phageParser/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/phageParser/phageParser/git/refs{/sha}","trees_url":"https://api.github.com/repos/phageParser/phageParser/git/trees{/sha}","statuses_url":"https://api.github.com/repos/phageParser/phageParser/statuses/{sha}","languages_url":"https://api.github.com/repos/phageParser/phageParser/languages","stargazers_url":"https://api.github.com/repos/phageParser/phageParser/stargazers","contributors_url":"https://api.github.com/repos/phageParser/phageParser/contributors","subscribers_url":"https://api.github.com/repos/phageParser/phageParser/subscribers","subscription_url":"https://api.github.com/repos/phageParser/phageParser/subscription","commits_url":"https://api.github.com/repos/phageParser/phageParser/commits{/sha}","git_commits_url":"https://api.github.com/repos/phageParser/phageParser/git/commits{/sha}","comments_url":"https://api.github.com/repos/phageParser/phageParser/comments{/number}","issue_comment_url":"https://api.github.com/repos/phageParser/phageParser/issues/comments{/number}","contents_url":"https://api.github.com/repos/phageParser/phageParser/contents/{+path}","compare_url":"https://api.github.com/repos/phageParser/phageParser/compare/{base}...{head}","merges_url":"https://api.github.com/repos/phageParser/phageParser/merges","archive_url":"https://api.github.com/repos/phageParser/phageParser/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/phageParser/phageParser/downloads","issues_url":"https://api.github.com/repos/phageParser/phageParser/issues{/number}","pulls_url":"https://api.github.com/repos/phageParser/phageParser/pulls{/number}","milestones_url":"https://api.github.com/repos/phageParser/phageParser/milestones{/number}","notifications_url":"https://api.github.com/repos/phageParser/phageParser/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/phageParser/phageParser/labels{/name}","releases_url":"https://api.github.com/repos/phageParser/phageParser/releases{/id}","deployments_url":"https://api.github.com/repos/phageParser/phageParser/deployments","created_at":"2014-08-20T20:38:26Z","updated_at":"2017-05-10T15:26:18Z","pushed_at":"2017-05-11T18:42:25Z","git_url":"git://github.com/phageParser/phageParser.git","ssh_url":"git@github.com:phageParser/phageParser.git","clone_url":"https://github.com/phageParser/phageParser.git","svn_url":"https://github.com/phageParser/phageParser","homepage":"","size":23616,"stargazers_count":52,"watchers_count":52,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":51,"mirror_url":null,"open_issues_count":18,"forks":51,"open_issues":18,"watchers":52,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/phageParser/phageParser/pulls/143"},"html":{"href":"https://github.com/phageParser/phageParser/pull/143"},"issue":{"href":"https://api.github.com/repos/phageParser/phageParser/issues/143"},"comments":{"href":"https://api.github.com/repos/phageParser/phageParser/issues/143/comments"},"review_comments":{"href":"https://api.github.com/repos/phageParser/phageParser/pulls/143/comments"},"review_comment":{"href":"https://api.github.com/repos/phageParser/phageParser/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/phageParser/phageParser/pulls/143/commits"},"statuses":{"href":"https://api.github.com/repos/phageParser/phageParser/statuses/c1a783848be8036fe339f6f8d687e58afcbfa3b5"}}}}
{"actor":{"display_login":"cemyld"}}