prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Never copy/list listings/*.py[co]
  kinda related to invariance
  
  
  </issue>
  <code>
  [start of nikola/plugins/task/listings.py]
  1 # -*- coding: utf-8 -*-
  2 
  3 # Copyright © 2012-2014 Roberto Alsina 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 from __future__ import unicode_literals, print_function
  28 
  29 import os
  30 
  31 from pygments import highlight
  32 from pygments.lexers import get_lexer_for_filename, TextLexer
  33 from pygments.formatters import HtmlFormatter
  34 
  35 from nikola.plugin_categories import Task
  36 from nikola import utils
  37 
  38 
  39 class Listings(Task):
  40     """Render pretty listings."""
  41 
  42     name = "render_listings"
  43 
  44     def set_site(self, site):
  45         site.register_path_handler('listing', self.listing_path)
  46         return super(Listings, self).set_site(site)
  47 
  48     def gen_tasks(self):
  49         """Render pretty code listings."""
  50         kw = {
  51             "default_lang": self.site.config["DEFAULT_LANG"],
  52             "listings_folder": self.site.config["LISTINGS_FOLDER"],
  53             "output_folder": self.site.config["OUTPUT_FOLDER"],
  54             "index_file": self.site.config["INDEX_FILE"],
  55         }
  56 
  57         # Things to ignore in listings
  58         ignored_extensions = (".pyc", ".pyo")
  59 
  60         def render_listing(in_name, out_name, folders=[], files=[]):
  61             if in_name:
  62                 with open(in_name, 'r') as fd:
  63                     try:
  64                         lexer = get_lexer_for_filename(in_name)
  65                     except:
  66                         lexer = TextLexer()
  67                     code = highlight(fd.read(), lexer,
  68                                      HtmlFormatter(cssclass='code',
  69                                                    linenos="table", nowrap=False,
  70                                                    lineanchors=utils.slugify(in_name),
  71                                                    anchorlinenos=True))
  72                 title = os.path.basename(in_name)
  73             else:
  74                 code = ''
  75                 title = ''
  76             crumbs = utils.get_crumbs(os.path.relpath(out_name,
  77                                                       kw['output_folder']),
  78                                       is_file=True)
  79             context = {
  80                 'code': code,
  81                 'title': title,
  82                 'crumbs': crumbs,
  83                 'lang': kw['default_lang'],
  84                 'folders': folders,
  85                 'files': files,
  86                 'description': title,
  87             }
  88             self.site.render_template('listing.tmpl', out_name,
  89                                       context)
  90 
  91         yield self.group_task()
  92 
  93         template_deps = self.site.template_system.template_deps('listing.tmpl')
  94         for root, dirs, files in os.walk(kw['listings_folder']):
  95             # Render all files
  96             out_name = os.path.join(
  97                 kw['output_folder'],
  98                 root, kw['index_file']
  99             )
  100             yield {
  101                 'basename': self.name,
  102                 'name': out_name,
  103                 'file_dep': template_deps,
  104                 'targets': [out_name],
  105                 'actions': [(render_listing, [None, out_name, dirs, files])],
  106                 # This is necessary to reflect changes in blog title,
  107                 # sidebar links, etc.
  108                 'uptodate': [utils.config_changed(
  109                     self.site.GLOBAL_CONTEXT)],
  110                 'clean': True,
  111             }
  112             for f in files:
  113                 ext = os.path.splitext(f)[-1]
  114                 if ext in ignored_extensions:
  115                     continue
  116                 in_name = os.path.join(root, f)
  117                 out_name = os.path.join(
  118                     kw['output_folder'],
  119                     root,
  120                     f) + '.html'
  121                 yield {
  122                     'basename': self.name,
  123                     'name': out_name,
  124                     'file_dep': template_deps + [in_name],
  125                     'targets': [out_name],
  126                     'actions': [(render_listing, [in_name, out_name])],
  127                     # This is necessary to reflect changes in blog title,
  128                     # sidebar links, etc.
  129                     'uptodate': [utils.config_changed(
  130                         self.site.GLOBAL_CONTEXT)],
  131                     'clean': True,
  132                 }
  133 
  134     def listing_path(self, name, lang):
  135         return [_f for _f in [self.site.config['LISTINGS_FOLDER'], name +
  136                               '.html'] if _f]
  137
  [end of nikola/plugins/task/listings.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/task/listings.py b/nikola/plugins/task/listings.py
  --- a/nikola/plugins/task/listings.py
  +++ b/nikola/plugins/task/listings.py
  @@ -92,6 +92,7 @@
   
           template_deps = self.site.template_system.template_deps('listing.tmpl')
           for root, dirs, files in os.walk(kw['listings_folder']):
  +            files = [f for f in files if os.path.splitext(f)[-1] not in ignored_extensions]
               # Render all files
               out_name = os.path.join(
                   kw['output_folder'],
  
verification_info: {"golden_diff": "diff --git a/nikola/plugins/task/listings.py b/nikola/plugins/task/listings.py\n--- a/nikola/plugins/task/listings.py\n+++ b/nikola/plugins/task/listings.py\n@@ -92,6 +92,7 @@\n \n         template_deps = self.site.template_system.template_deps('listing.tmpl')\n         for root, dirs, files in os.walk(kw['listings_folder']):\n+            files = [f for f in files if os.path.splitext(f)[-1] not in ignored_extensions]\n             # Render all files\n             out_name = os.path.join(\n                 kw['output_folder'],\n", "issue": "Never copy/list listings/*.py[co]\nkinda related to invariance\n\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n\n# Copyright \u00a9 2012-2014 Roberto Alsina 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\nfrom __future__ import unicode_literals, print_function\n\nimport os\n\nfrom pygments import highlight\nfrom pygments.lexers import get_lexer_for_filename, TextLexer\nfrom pygments.formatters import HtmlFormatter\n\nfrom nikola.plugin_categories import Task\nfrom nikola import utils\n\n\nclass Listings(Task):\n    \"\"\"Render pretty listings.\"\"\"\n\n    name = \"render_listings\"\n\n    def set_site(self, site):\n        site.register_path_handler('listing', self.listing_path)\n        return super(Listings, self).set_site(site)\n\n    def gen_tasks(self):\n        \"\"\"Render pretty code listings.\"\"\"\n        kw = {\n            \"default_lang\": self.site.config[\"DEFAULT_LANG\"],\n            \"listings_folder\": self.site.config[\"LISTINGS_FOLDER\"],\n            \"output_folder\": self.site.config[\"OUTPUT_FOLDER\"],\n            \"index_file\": self.site.config[\"INDEX_FILE\"],\n        }\n\n        # Things to ignore in listings\n        ignored_extensions = (\".pyc\", \".pyo\")\n\n        def render_listing(in_name, out_name, folders=[], files=[]):\n            if in_name:\n                with open(in_name, 'r') as fd:\n                    try:\n                        lexer = get_lexer_for_filename(in_name)\n                    except:\n                        lexer = TextLexer()\n                    code = highlight(fd.read(), lexer,\n                                     HtmlFormatter(cssclass='code',\n                                                   linenos=\"table\", nowrap=False,\n                                                   lineanchors=utils.slugify(in_name),\n                                                   anchorlinenos=True))\n                title = os.path.basename(in_name)\n            else:\n                code = ''\n                title = ''\n            crumbs = utils.get_crumbs(os.path.relpath(out_name,\n                                                      kw['output_folder']),\n                                      is_file=True)\n            context = {\n                'code': code,\n                'title': title,\n                'crumbs': crumbs,\n                'lang': kw['default_lang'],\n                'folders': folders,\n                'files': files,\n                'description': title,\n            }\n            self.site.render_template('listing.tmpl', out_name,\n                                      context)\n\n        yield self.group_task()\n\n        template_deps = self.site.template_system.template_deps('listing.tmpl')\n        for root, dirs, files in os.walk(kw['listings_folder']):\n            # Render all files\n            out_name = os.path.join(\n                kw['output_folder'],\n                root, kw['index_file']\n            )\n            yield {\n                'basename': self.name,\n                'name': out_name,\n                'file_dep': template_deps,\n                'targets': [out_name],\n                'actions': [(render_listing, [None, out_name, dirs, files])],\n                # This is necessary to reflect changes in blog title,\n                # sidebar links, etc.\n                'uptodate': [utils.config_changed(\n                    self.site.GLOBAL_CONTEXT)],\n                'clean': True,\n            }\n            for f in files:\n                ext = os.path.splitext(f)[-1]\n                if ext in ignored_extensions:\n                    continue\n                in_name = os.path.join(root, f)\n                out_name = os.path.join(\n                    kw['output_folder'],\n                    root,\n                    f) + '.html'\n                yield {\n                    'basename': self.name,\n                    'name': out_name,\n                    'file_dep': template_deps + [in_name],\n                    'targets': [out_name],\n                    'actions': [(render_listing, [in_name, out_name])],\n                    # This is necessary to reflect changes in blog title,\n                    # sidebar links, etc.\n                    'uptodate': [utils.config_changed(\n                        self.site.GLOBAL_CONTEXT)],\n                    'clean': True,\n                }\n\n    def listing_path(self, name, lang):\n        return [_f for _f in [self.site.config['LISTINGS_FOLDER'], name +\n                              '.html'] if _f]\n", "path": "nikola/plugins/task/listings.py"}]}