GitHub PullRequestReviewCommentEvent at 2014-10-22 20:07:28
Repository: ipython
Actor: takluyver
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/ipython/ipython/pulls/comments/19240548","id":19240548,"diff_hunk":"@@ -0,0 +1,125 @@\n+\"\"\"Base classes and utilities for readers and writers.\"\"\"\n+\n+# Copyright (c) IPython Development Team.\n+# Distributed under the terms of the Modified BSD License.\n+\n+from IPython.utils import py3compat\n+from IPython.utils.py3compat import unicode_type, string_types\n+\n+# output keys that are likely to have multiline values\n+_multiline_outputs = {\n+    'text/plain',\n+    'text/html',\n+    'image/svg+xml',\n+    'text/latex',\n+    'application/javascript',\n+}\n+\n+\n+# FIXME: workaround for old splitlines()\n+def _join_lines(lines):\n+    \"\"\"join lines that have been written by splitlines()\n+\n+    Has logic to protect against `splitlines()`, which\n+    should have been `splitlines(True)`\n+    \"\"\"\n+    if lines and lines[0].endswith(('\\n', '\\r')):\n+        # created by splitlines(True)\n+        return u''.join(lines)\n+    else:\n+        # created by splitlines()\n+        return u'\\n'.join(lines)\n+\n+\n+def rejoin_lines(nb):\n+    \"\"\"rejoin multiline text into strings\n+\n+    For reversing effects of ``split_lines(nb)``.\n+\n+    This only rejoins lines that have been split, so if text objects were not split\n+    they will pass through unchanged.\n+\n+    Used when reading JSON files that may have been passed through split_lines.\n+    \"\"\"\n+    for cell in nb.cells:\n+        if 'source' in cell and isinstance(cell.source, list):\n+            cell.source = _join_lines(cell.source)\n+        if cell.get('cell_type', None) == 'code':\n+            for output in cell.get('outputs', []):\n+                output_type = output.get('output_type', '')\n+                if output_type in {'execute_result', 'display_data'}:\n+                    for key, value in output.get('data', {}).items():\n+                        if key != 'application/json' and isinstance(value, list):\n+                            output.data[key] = _join_lines(value)\n+                elif output_type:\n+                    if isinstance(output.get('text', ''), list):\n+                        output.text = _join_lines(output.text)\n+    return nb\n+\n+\n+def split_lines(nb):\n+    \"\"\"split likely multiline text into lists of strings\n+\n+    For file output more friendly to line-based VCS. ``rejoin_lines(nb)`` will\n+    reverse the effects of ``split_lines(nb)``.\n+\n+    Used when writing JSON files.\n+    \"\"\"\n+    for cell in nb.cells:\n+        source = cell.get('source', None)\n+        if isinstance(source, string_types):\n+            cell['source'] = source.splitlines(True)\n+\n+        if cell.cell_type == 'code':\n+            for output in cell.outputs:\n+                if output.output_type in {'execute_result', 'display_data'}:\n+                    for key, value in output.data.items():\n+                        if key != 'application/json' and isinstance(value, string_types):\n+                            output.data[key] = value.splitlines(True)\n+                elif output.output_type == 'stream':\n+                    if isinstance(output.text, string_types):\n+                        output.text = output.text.splitlines(True)\n+    return nb\n+\n+\n+def strip_transient(nb):\n+    \"\"\"Strip transient values that shouldn't be stored in files.\n+\n+    This should be called in *both* read and write.","path":"IPython/nbformat/v4/rwbase.py","position":88,"original_position":88,"commit_id":"2a397d32f60e6a7fb6d48e33ae27d325133a0070","original_commit_id":"2a397d32f60e6a7fb6d48e33ae27d325133a0070","user":{"login":"takluyver","id":327925,"avatar_url":"https://avatars.githubusercontent.com/u/327925?v=2","gravatar_id":"","url":"https://api.github.com/users/takluyver","html_url":"https://github.com/takluyver","followers_url":"https://api.github.com/users/takluyver/followers","following_url":"https://api.github.com/users/takluyver/following{/other_user}","gists_url":"https://api.github.com/users/takluyver/gists{/gist_id}","starred_url":"https://api.github.com/users/takluyver/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/takluyver/subscriptions","organizations_url":"https://api.github.com/users/takluyver/orgs","repos_url":"https://api.github.com/users/takluyver/repos","events_url":"https://api.github.com/users/takluyver/events{/privacy}","received_events_url":"https://api.github.com/users/takluyver/received_events","type":"User","site_admin":false},"body":"Why on read?","created_at":"2014-10-22T20:07:28Z","updated_at":"2014-10-22T20:07:28Z","html_url":"https://github.com/ipython/ipython/pull/6045#discussion_r19240548","pull_request_url":"https://api.github.com/repos/ipython/ipython/pulls/6045","_links":{"self":{"href":"https://api.github.com/repos/ipython/ipython/pulls/comments/19240548"},"html":{"href":"https://github.com/ipython/ipython/pull/6045#discussion_r19240548"},"pull_request":{"href":"https://api.github.com/repos/ipython/ipython/pulls/6045"}}},"pull_request":{"url":"https://api.github.com/repos/ipython/ipython/pulls/6045","id":17620404,"html_url":"https://github.com/ipython/ipython/pull/6045","diff_url":"https://github.com/ipython/ipython/pull/6045.diff","patch_url":"https://github.com/ipython/ipython/pull/6045.patch","issue_url":"https://api.github.com/repos/ipython/ipython/issues/6045","number":6045,"state":"open","locked":false,"title":"nbformat v4","user":{"login":"minrk","id":151929,"avatar_url":"https://avatars.githubusercontent.com/u/151929?v=2","gravatar_id":"","url":"https://api.github.com/users/minrk","html_url":"https://github.com/minrk","followers_url":"https://api.github.com/users/minrk/followers","following_url":"https://api.github.com/users/minrk/following{/other_user}","gists_url":"https://api.github.com/users/minrk/gists{/gist_id}","starred_url":"https://api.github.com/users/minrk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/minrk/subscriptions","organizations_url":"https://api.github.com/users/minrk/orgs","repos_url":"https://api.github.com/users/minrk/repos","events_url":"https://api.github.com/users/minrk/events{/privacy}","received_events_url":"https://api.github.com/users/minrk/received_events","type":"User","site_admin":false},"body":"Still quite a bit to do, but the implemented parts of v4 are working pretty well. I did find and fix some things while testing the validation. Both v3 and v4 have a Draft 4 jsonschema, and use the standard jsonschema format for references, so jsonpointer is no longer used.\r\n\r\ncloses #5074 \r\n\r\nTODO in separate PRs:\r\n\r\n- backport v4->v3 to 2.x\r\n- what to do when uploading old notebooks (upgrade on upload, or leave alone and upgrade on open)?\r\n\r\n\r\n- [x] add convert 3<->4\r\n- [x] make v4 current\r\n- [x] update stream messages to `name, text`\r\n- [x] move display_data.png to display_data.data['image/png']\r\n- [x] what's new\r\n- [x] decide on UI for downgrade\r\n- [x] upgrade existing example notebooks","created_at":"2014-06-25T22:23:56Z","updated_at":"2014-10-22T20:07:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4d7db27a5c226b4fbf926f3de0d57bfae9d6db3e","assignee":null,"milestone":{"url":"https://api.github.com/repos/ipython/ipython/milestones/13","labels_url":"https://api.github.com/repos/ipython/ipython/milestones/13/labels","id":532467,"number":13,"title":"3.0","description":"IPython 3.0 Summer/Fall","creator":{"login":"Carreau","id":335567,"avatar_url":"https://avatars.githubusercontent.com/u/335567?v=2","gravatar_id":"","url":"https://api.github.com/users/Carreau","html_url":"https://github.com/Carreau","followers_url":"https://api.github.com/users/Carreau/followers","following_url":"https://api.github.com/users/Carreau/following{/other_user}","gists_url":"https://api.github.com/users/Carreau/gists{/gist_id}","starred_url":"https://api.github.com/users/Carreau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Carreau/subscriptions","organizations_url":"https://api.github.com/users/Carreau/orgs","repos_url":"https://api.github.com/users/Carreau/repos","events_url":"https://api.github.com/users/Carreau/events{/privacy}","received_events_url":"https://api.github.com/users/Carreau/received_events","type":"User","site_admin":false},"open_issues":251,"closed_issues":506,"state":"open","created_at":"2014-01-10T13:22:15Z","updated_at":"2014-10-22T18:23:01Z","due_on":null},"commits_url":"https://api.github.com/repos/ipython/ipython/pulls/6045/commits","review_comments_url":"https://api.github.com/repos/ipython/ipython/pulls/6045/comments","review_comment_url":"https://api.github.com/repos/ipython/ipython/pulls/comments/{number}","comments_url":"https://api.github.com/repos/ipython/ipython/issues/6045/comments","statuses_url":"https://api.github.com/repos/ipython/ipython/statuses/2a397d32f60e6a7fb6d48e33ae27d325133a0070","head":{"label":"minrk:nbformat4","ref":"nbformat4","sha":"2a397d32f60e6a7fb6d48e33ae27d325133a0070","user":{"login":"minrk","id":151929,"avatar_url":"https://avatars.githubusercontent.com/u/151929?v=2","gravatar_id":"","url":"https://api.github.com/users/minrk","html_url":"https://github.com/minrk","followers_url":"https://api.github.com/users/minrk/followers","following_url":"https://api.github.com/users/minrk/following{/other_user}","gists_url":"https://api.github.com/users/minrk/gists{/gist_id}","starred_url":"https://api.github.com/users/minrk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/minrk/subscriptions","organizations_url":"https://api.github.com/users/minrk/orgs","repos_url":"https://api.github.com/users/minrk/repos","events_url":"https://api.github.com/users/minrk/events{/privacy}","received_events_url":"https://api.github.com/users/minrk/received_events","type":"User","site_admin":false},"repo":{"id":659446,"name":"ipython","full_name":"minrk/ipython","owner":{"login":"minrk","id":151929,"avatar_url":"https://avatars.githubusercontent.com/u/151929?v=2","gravatar_id":"","url":"https://api.github.com/users/minrk","html_url":"https://github.com/minrk","followers_url":"https://api.github.com/users/minrk/followers","following_url":"https://api.github.com/users/minrk/following{/other_user}","gists_url":"https://api.github.com/users/minrk/gists{/gist_id}","starred_url":"https://api.github.com/users/minrk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/minrk/subscriptions","organizations_url":"https://api.github.com/users/minrk/orgs","repos_url":"https://api.github.com/users/minrk/repos","events_url":"https://api.github.com/users/minrk/events{/privacy}","received_events_url":"https://api.github.com/users/minrk/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/minrk/ipython","description":"","fork":true,"url":"https://api.github.com/repos/minrk/ipython","forks_url":"https://api.github.com/repos/minrk/ipython/forks","keys_url":"https://api.github.com/repos/minrk/ipython/keys{/key_id}","collaborators_url":"https://api.github.com/repos/minrk/ipython/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/minrk/ipython/teams","hooks_url":"https://api.github.com/repos/minrk/ipython/hooks","issue_events_url":"https://api.github.com/repos/minrk/ipython/issues/events{/number}","events_url":"https://api.github.com/repos/minrk/ipython/events","assignees_url":"https://api.github.com/repos/minrk/ipython/assignees{/user}","branches_url":"https://api.github.com/repos/minrk/ipython/branches{/branch}","tags_url":"https://api.github.com/repos/minrk/ipython/tags","blobs_url":"https://api.github.com/repos/minrk/ipython/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/minrk/ipython/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/minrk/ipython/git/refs{/sha}","trees_url":"https://api.github.com/repos/minrk/ipython/git/trees{/sha}","statuses_url":"https://api.github.com/repos/minrk/ipython/statuses/{sha}","languages_url":"https://api.github.com/repos/minrk/ipython/languages","stargazers_url":"https://api.github.com/repos/minrk/ipython/stargazers","contributors_url":"https://api.github.com/repos/minrk/ipython/contributors","subscribers_url":"https://api.github.com/repos/minrk/ipython/subscribers","subscription_url":"https://api.github.com/repos/minrk/ipython/subscription","commits_url":"https://api.github.com/repos/minrk/ipython/commits{/sha}","git_commits_url":"https://api.github.com/repos/minrk/ipython/git/commits{/sha}","comments_url":"https://api.github.com/repos/minrk/ipython/comments{/number}","issue_comment_url":"https://api.github.com/repos/minrk/ipython/issues/comments/{number}","contents_url":"https://api.github.com/repos/minrk/ipython/contents/{+path}","compare_url":"https://api.github.com/repos/minrk/ipython/compare/{base}...{head}","merges_url":"https://api.github.com/repos/minrk/ipython/merges","archive_url":"https://api.github.com/repos/minrk/ipython/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/minrk/ipython/downloads","issues_url":"https://api.github.com/repos/minrk/ipython/issues{/number}","pulls_url":"https://api.github.com/repos/minrk/ipython/pulls{/number}","milestones_url":"https://api.github.com/repos/minrk/ipython/milestones{/number}","notifications_url":"https://api.github.com/repos/minrk/ipython/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/minrk/ipython/labels{/name}","releases_url":"https://api.github.com/repos/minrk/ipython/releases{/id}","created_at":"2010-05-10T18:37:01Z","updated_at":"2014-08-30T01:59:05Z","pushed_at":"2014-10-22T18:17:34Z","git_url":"git://github.com/minrk/ipython.git","ssh_url":"git@github.com:minrk/ipython.git","clone_url":"https://github.com/minrk/ipython.git","svn_url":"https://github.com/minrk/ipython","homepage":"","size":76515,"stargazers_count":16,"watchers_count":16,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":16,"default_branch":"master"}},"base":{"label":"ipython:master","ref":"master","sha":"ba9c97481eda20043bd5547563e00ff5c98773d1","user":{"login":"ipython","id":230453,"avatar_url":"https://avatars.githubusercontent.com/u/230453?v=2","gravatar_id":"","url":"https://api.github.com/users/ipython","html_url":"https://github.com/ipython","followers_url":"https://api.github.com/users/ipython/followers","following_url":"https://api.github.com/users/ipython/following{/other_user}","gists_url":"https://api.github.com/users/ipython/gists{/gist_id}","starred_url":"https://api.github.com/users/ipython/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ipython/subscriptions","organizations_url":"https://api.github.com/users/ipython/orgs","repos_url":"https://api.github.com/users/ipython/repos","events_url":"https://api.github.com/users/ipython/events{/privacy}","received_events_url":"https://api.github.com/users/ipython/received_events","type":"Organization","site_admin":false},"repo":{"id":658518,"name":"ipython","full_name":"ipython/ipython","owner":{"login":"ipython","id":230453,"avatar_url":"https://avatars.githubusercontent.com/u/230453?v=2","gravatar_id":"","url":"https://api.github.com/users/ipython","html_url":"https://github.com/ipython","followers_url":"https://api.github.com/users/ipython/followers","following_url":"https://api.github.com/users/ipython/following{/other_user}","gists_url":"https://api.github.com/users/ipython/gists{/gist_id}","starred_url":"https://api.github.com/users/ipython/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ipython/subscriptions","organizations_url":"https://api.github.com/users/ipython/orgs","repos_url":"https://api.github.com/users/ipython/repos","events_url":"https://api.github.com/users/ipython/events{/privacy}","received_events_url":"https://api.github.com/users/ipython/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ipython/ipython","description":"Official repository for IPython itself. Other repos in the IPython organization contain things like the website, documentation builds, etc.","fork":false,"url":"https://api.github.com/repos/ipython/ipython","forks_url":"https://api.github.com/repos/ipython/ipython/forks","keys_url":"https://api.github.com/repos/ipython/ipython/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ipython/ipython/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ipython/ipython/teams","hooks_url":"https://api.github.com/repos/ipython/ipython/hooks","issue_events_url":"https://api.github.com/repos/ipython/ipython/issues/events{/number}","events_url":"https://api.github.com/repos/ipython/ipython/events","assignees_url":"https://api.github.com/repos/ipython/ipython/assignees{/user}","branches_url":"https://api.github.com/repos/ipython/ipython/branches{/branch}","tags_url":"https://api.github.com/repos/ipython/ipython/tags","blobs_url":"https://api.github.com/repos/ipython/ipython/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ipython/ipython/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ipython/ipython/git/refs{/sha}","trees_url":"https://api.github.com/repos/ipython/ipython/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ipython/ipython/statuses/{sha}","languages_url":"https://api.github.com/repos/ipython/ipython/languages","stargazers_url":"https://api.github.com/repos/ipython/ipython/stargazers","contributors_url":"https://api.github.com/repos/ipython/ipython/contributors","subscribers_url":"https://api.github.com/repos/ipython/ipython/subscribers","subscription_url":"https://api.github.com/repos/ipython/ipython/subscription","commits_url":"https://api.github.com/repos/ipython/ipython/commits{/sha}","git_commits_url":"https://api.github.com/repos/ipython/ipython/git/commits{/sha}","comments_url":"https://api.github.com/repos/ipython/ipython/comments{/number}","issue_comment_url":"https://api.github.com/repos/ipython/ipython/issues/comments/{number}","contents_url":"https://api.github.com/repos/ipython/ipython/contents/{+path}","compare_url":"https://api.github.com/repos/ipython/ipython/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ipython/ipython/merges","archive_url":"https://api.github.com/repos/ipython/ipython/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ipython/ipython/downloads","issues_url":"https://api.github.com/repos/ipython/ipython/issues{/number}","pulls_url":"https://api.github.com/repos/ipython/ipython/pulls{/number}","milestones_url":"https://api.github.com/repos/ipython/ipython/milestones{/number}","notifications_url":"https://api.github.com/repos/ipython/ipython/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ipython/ipython/labels{/name}","releases_url":"https://api.github.com/repos/ipython/ipython/releases{/id}","created_at":"2010-05-10T04:46:06Z","updated_at":"2014-10-22T17:18:15Z","pushed_at":"2014-10-22T18:57:38Z","git_url":"git://github.com/ipython/ipython.git","ssh_url":"git@github.com:ipython/ipython.git","clone_url":"https://github.com/ipython/ipython.git","svn_url":"https://github.com/ipython/ipython","homepage":"http://ipython.org","size":125774,"stargazers_count":5027,"watchers_count":5027,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1460,"mirror_url":null,"open_issues_count":869,"forks":1460,"open_issues":869,"watchers":5027,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ipython/ipython/pulls/6045"},"html":{"href":"https://github.com/ipython/ipython/pull/6045"},"issue":{"href":"https://api.github.com/repos/ipython/ipython/issues/6045"},"comments":{"href":"https://api.github.com/repos/ipython/ipython/issues/6045/comments"},"review_comments":{"href":"https://api.github.com/repos/ipython/ipython/pulls/6045/comments"},"review_comment":{"href":"https://api.github.com/repos/ipython/ipython/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/ipython/ipython/pulls/6045/commits"},"statuses":{"href":"https://api.github.com/repos/ipython/ipython/statuses/2a397d32f60e6a7fb6d48e33ae27d325133a0070"}}}}