prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Build fails with IPython 3.0
  Trying to use ipython notebooks with the current dev version of IPython (3.0.0) fails building with some warnings etc. because the `nbformat` interface has changed a little:
  
  ```
  ...WARNING: UserWarning: .../ipython-dev/IPython/nbformat/current.py:19: IPython.nbformat.current is deprecated.
  
  - use IPython.nbformat for read/write/validate public API
  - use IPython.nbformat.vX directly to composing notebooks of a particular version
  ...
  ... WARNING: UserWarning: .../ipython-dev/IPython/nbformat/current.py:75: reads_json is deprecated, use reads
  ...
  AttributeError: cells
  ```
  
  This is fairly easily fixed and I will send a PR shortly.
  
  
  </issue>
  <code>
  [start of nikola/plugins/compile/ipynb/__init__.py]
  1 # -*- coding: utf-8 -*-
  2 
  3 # Copyright © 2013-2015 Damián Avila and others.
  4 
  5 # Permission is hereby granted, free of charge, to any
  6 # person obtaining a copy of this software and associated
  7 # documentation files (the "Software"), to deal in the
  8 # Software without restriction, including without limitation
  9 # the rights to use, copy, modify, merge, publish,
  10 # distribute, sublicense, and/or sell copies of the
  11 # Software, and to permit persons to whom the Software is
  12 # furnished to do so, subject to the following conditions:
  13 #
  14 # The above copyright notice and this permission notice
  15 # shall be included in all copies or substantial portions of
  16 # the Software.
  17 #
  18 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
  19 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  20 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  21 # PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
  22 # OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
  23 # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  24 # OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  25 # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  26 
  27 """Implementation of compile_html based on nbconvert."""
  28 
  29 from __future__ import unicode_literals, print_function
  30 import io
  31 import os
  32 
  33 try:
  34     from IPython.nbconvert.exporters import HTMLExporter
  35     from IPython.nbformat import current as nbformat
  36     from IPython.config import Config
  37     flag = True
  38 except ImportError:
  39     flag = None
  40 
  41 from nikola.plugin_categories import PageCompiler
  42 from nikola.utils import makedirs, req_missing
  43 
  44 
  45 class CompileIPynb(PageCompiler):
  46     """Compile IPynb into HTML."""
  47 
  48     name = "ipynb"
  49     supports_onefile = False
  50     demote_headers = True
  51 
  52     def compile_html(self, source, dest, is_two_file=True):
  53         if flag is None:
  54             req_missing(['ipython>=1.1.0'], 'build this site (compile ipynb)')
  55         makedirs(os.path.dirname(dest))
  56         HTMLExporter.default_template = 'basic'
  57         c = Config(self.site.config['IPYNB_CONFIG'])
  58         exportHtml = HTMLExporter(config=c)
  59         with io.open(dest, "w+", encoding="utf8") as out_file:
  60             with io.open(source, "r", encoding="utf8") as in_file:
  61                 nb = in_file.read()
  62                 nb_json = nbformat.reads_json(nb)
  63             (body, resources) = exportHtml.from_notebook_node(nb_json)
  64             out_file.write(body)
  65 
  66     def create_post(self, path, **kw):
  67         content = kw.pop('content', None)
  68         onefile = kw.pop('onefile', False)
  69         # is_page is not needed to create the file
  70         kw.pop('is_page', False)
  71 
  72         makedirs(os.path.dirname(path))
  73         if onefile:
  74             raise Exception('The one-file format is not supported by this compiler.')
  75         with io.open(path, "w+", encoding="utf8") as fd:
  76             if not content.startswith("Write your"):
  77                 fd.write(content)
  78             else:
  79                 fd.write("""{
  80  "metadata": {
  81   "name": ""
  82  },
  83  "nbformat": 3,
  84  "nbformat_minor": 0,
  85  "worksheets": [
  86   {
  87    "cells": [
  88     {
  89      "cell_type": "code",
  90      "collapsed": false,
  91      "input": [],
  92      "language": "python",
  93      "metadata": {},
  94      "outputs": []
  95     }
  96    ],
  97    "metadata": {}
  98   }
  99  ]
  100 }""")
  101
  [end of nikola/plugins/compile/ipynb/__init__.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/nikola/plugins/compile/ipynb/__init__.py b/nikola/plugins/compile/ipynb/__init__.py
  --- a/nikola/plugins/compile/ipynb/__init__.py
  +++ b/nikola/plugins/compile/ipynb/__init__.py
  @@ -31,8 +31,15 @@
   import os
   
   try:
  +    import IPython
       from IPython.nbconvert.exporters import HTMLExporter
  -    from IPython.nbformat import current as nbformat
  +    if IPython.version_info[0] >= 3:     # API changed with 3.0.0
  +        from IPython import nbformat
  +        current_nbformat = nbformat.current_nbformat
  +    else:
  +        import IPython.nbformat.current as nbformat
  +        current_nbformat = 'json'
  +
       from IPython.config import Config
       flag = True
   except ImportError:
  @@ -58,8 +65,7 @@
           exportHtml = HTMLExporter(config=c)
           with io.open(dest, "w+", encoding="utf8") as out_file:
               with io.open(source, "r", encoding="utf8") as in_file:
  -                nb = in_file.read()
  -                nb_json = nbformat.reads_json(nb)
  +                nb_json = nbformat.read(in_file, current_nbformat)
               (body, resources) = exportHtml.from_notebook_node(nb_json)
               out_file.write(body)
  
verification_info: {"golden_diff": "diff --git a/nikola/plugins/compile/ipynb/__init__.py b/nikola/plugins/compile/ipynb/__init__.py\n--- a/nikola/plugins/compile/ipynb/__init__.py\n+++ b/nikola/plugins/compile/ipynb/__init__.py\n@@ -31,8 +31,15 @@\n import os\n \n try:\n+    import IPython\n     from IPython.nbconvert.exporters import HTMLExporter\n-    from IPython.nbformat import current as nbformat\n+    if IPython.version_info[0] >= 3:     # API changed with 3.0.0\n+        from IPython import nbformat\n+        current_nbformat = nbformat.current_nbformat\n+    else:\n+        import IPython.nbformat.current as nbformat\n+        current_nbformat = 'json'\n+\n     from IPython.config import Config\n     flag = True\n except ImportError:\n@@ -58,8 +65,7 @@\n         exportHtml = HTMLExporter(config=c)\n         with io.open(dest, \"w+\", encoding=\"utf8\") as out_file:\n             with io.open(source, \"r\", encoding=\"utf8\") as in_file:\n-                nb = in_file.read()\n-                nb_json = nbformat.reads_json(nb)\n+                nb_json = nbformat.read(in_file, current_nbformat)\n             (body, resources) = exportHtml.from_notebook_node(nb_json)\n             out_file.write(body)\n", "issue": "Build fails with IPython 3.0\nTrying to use ipython notebooks with the current dev version of IPython (3.0.0) fails building with some warnings etc. because the `nbformat` interface has changed a little:\n\n```\n...WARNING: UserWarning: .../ipython-dev/IPython/nbformat/current.py:19: IPython.nbformat.current is deprecated.\n\n- use IPython.nbformat for read/write/validate public API\n- use IPython.nbformat.vX directly to composing notebooks of a particular version\n...\n... WARNING: UserWarning: .../ipython-dev/IPython/nbformat/current.py:75: reads_json is deprecated, use reads\n...\nAttributeError: cells\n```\n\nThis is fairly easily fixed and I will send a PR shortly.\n\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n\n# Copyright \u00a9 2013-2015 Dami\u00e1n Avila and others.\n\n# Permission is hereby granted, free of charge, to any\n# person obtaining a copy of this software and associated\n# documentation files (the \"Software\"), to deal in the\n# Software without restriction, including without limitation\n# the rights to use, copy, modify, merge, publish,\n# distribute, sublicense, and/or sell copies of the\n# Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n#\n# The above copyright notice and this permission notice\n# shall be included in all copies or substantial portions of\n# the Software.\n#\n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY\n# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE\n# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR\n# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS\n# OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR\n# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n\"\"\"Implementation of compile_html based on nbconvert.\"\"\"\n\nfrom __future__ import unicode_literals, print_function\nimport io\nimport os\n\ntry:\n    from IPython.nbconvert.exporters import HTMLExporter\n    from IPython.nbformat import current as nbformat\n    from IPython.config import Config\n    flag = True\nexcept ImportError:\n    flag = None\n\nfrom nikola.plugin_categories import PageCompiler\nfrom nikola.utils import makedirs, req_missing\n\n\nclass CompileIPynb(PageCompiler):\n    \"\"\"Compile IPynb into HTML.\"\"\"\n\n    name = \"ipynb\"\n    supports_onefile = False\n    demote_headers = True\n\n    def compile_html(self, source, dest, is_two_file=True):\n        if flag is None:\n            req_missing(['ipython>=1.1.0'], 'build this site (compile ipynb)')\n        makedirs(os.path.dirname(dest))\n        HTMLExporter.default_template = 'basic'\n        c = Config(self.site.config['IPYNB_CONFIG'])\n        exportHtml = HTMLExporter(config=c)\n        with io.open(dest, \"w+\", encoding=\"utf8\") as out_file:\n            with io.open(source, \"r\", encoding=\"utf8\") as in_file:\n                nb = in_file.read()\n                nb_json = nbformat.reads_json(nb)\n            (body, resources) = exportHtml.from_notebook_node(nb_json)\n            out_file.write(body)\n\n    def create_post(self, path, **kw):\n        content = kw.pop('content', None)\n        onefile = kw.pop('onefile', False)\n        # is_page is not needed to create the file\n        kw.pop('is_page', False)\n\n        makedirs(os.path.dirname(path))\n        if onefile:\n            raise Exception('The one-file format is not supported by this compiler.')\n        with io.open(path, \"w+\", encoding=\"utf8\") as fd:\n            if not content.startswith(\"Write your\"):\n                fd.write(content)\n            else:\n                fd.write(\"\"\"{\n \"metadata\": {\n  \"name\": \"\"\n },\n \"nbformat\": 3,\n \"nbformat_minor\": 0,\n \"worksheets\": [\n  {\n   \"cells\": [\n    {\n     \"cell_type\": \"code\",\n     \"collapsed\": false,\n     \"input\": [],\n     \"language\": \"python\",\n     \"metadata\": {},\n     \"outputs\": []\n    }\n   ],\n   \"metadata\": {}\n  }\n ]\n}\"\"\")\n", "path": "nikola/plugins/compile/ipynb/__init__.py"}]}