prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  nikola no longer has all-nocdn.*
  I started using `nikola` today for a gallery. The generated pages make reference to `all-nocdn.css` and `all-nocdn.js`, but they're not (longer?) part of `nikola`'s code:
  
  ``` bash
  mdione@diablo:~/src/projects/nikola$ git remote show origin
  * remote origin
    Fetch URL: https://github.com/getnikola/nikola.git
    Push  URL: https://github.com/getnikola/nikola.git
    HEAD branch: master
  mdione@diablo:~/src/projects/nikola$ git branch
  * master
  mdione@diablo:~/src/projects/nikola$ git pull
  Already up-to-date.
  mdione@diablo:~/src/projects/nikola$ find . -name all-nocdn.*
  mdione@diablo:~/src/projects/nikola$
  ```
  
  I just copied those files from and old attempt to use `nikola` and the site works. This happens with both versions `7.6.0-3` from Debian and from `master`, as you can see above.
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `nikola/plugins/task/bundles.py`
  Content:
  ```
  1 # -*- coding: utf-8 -*-
  2 
  3 # Copyright © 2012-2015 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 """Bundle assets using WebAssets."""
  28 
  29 from __future__ import unicode_literals
  30 
  31 import os
  32 
  33 try:
  34     import webassets
  35 except ImportError:
  36     webassets = None  # NOQA
  37 
  38 from nikola.plugin_categories import LateTask
  39 from nikola import utils
  40 
  41 
  42 class BuildBundles(LateTask):
  43 
  44     """Bundle assets using WebAssets."""
  45 
  46     name = "create_bundles"
  47 
  48     def set_site(self, site):
  49         """Set Nikola site."""
  50         self.logger = utils.get_logger('bundles', utils.STDERR_HANDLER)
  51         if webassets is None and site.config['USE_BUNDLES']:
  52             utils.req_missing(['webassets'], 'USE_BUNDLES', optional=True)
  53             self.logger.warn('Setting USE_BUNDLES to False.')
  54             site.config['USE_BUNDLES'] = False
  55         super(BuildBundles, self).set_site(site)
  56 
  57     def gen_tasks(self):
  58         """Bundle assets using WebAssets."""
  59         kw = {
  60             'filters': self.site.config['FILTERS'],
  61             'output_folder': self.site.config['OUTPUT_FOLDER'],
  62             'cache_folder': self.site.config['CACHE_FOLDER'],
  63             'theme_bundles': get_theme_bundles(self.site.THEMES),
  64             'themes': self.site.THEMES,
  65             'files_folders': self.site.config['FILES_FOLDERS'],
  66             'code_color_scheme': self.site.config['CODE_COLOR_SCHEME'],
  67         }
  68 
  69         def build_bundle(output, inputs):
  70             out_dir = os.path.join(kw['output_folder'],
  71                                    os.path.dirname(output))
  72             inputs = [os.path.relpath(i, out_dir) for i in inputs if os.path.isfile(i)]
  73             cache_dir = os.path.join(kw['cache_folder'], 'webassets')
  74             utils.makedirs(cache_dir)
  75             env = webassets.Environment(out_dir, os.path.dirname(output),
  76                                         cache=cache_dir)
  77             if inputs:
  78                 bundle = webassets.Bundle(*inputs, output=os.path.basename(output))
  79                 env.register(output, bundle)
  80                 # This generates the file
  81                 try:
  82                     env[output].urls()
  83                 except Exception as e:
  84                     self.logger.error("Failed to build bundles.")
  85                     self.logger.exception(e)
  86                     self.logger.notice("Try running ``nikola clean`` and building again.")
  87             else:
  88                 with open(os.path.join(out_dir, os.path.basename(output)), 'wb+'):
  89                     pass  # Create empty file
  90 
  91         yield self.group_task()
  92         if (webassets is not None and self.site.config['USE_BUNDLES'] is not
  93                 False):
  94             for name, _files in kw['theme_bundles'].items():
  95                 output_path = os.path.join(kw['output_folder'], name)
  96                 dname = os.path.dirname(name)
  97                 files = []
  98                 for fname in _files:
  99                     # paths are relative to dirname
  100                     files.append(os.path.join(dname, fname))
  101                 file_dep = [os.path.join(kw['output_folder'], fname)
  102                             for fname in files if
  103                             utils.get_asset_path(fname, self.site.THEMES, self.site.config['FILES_FOLDERS']) or fname == os.path.join('assets', 'css', 'code.css')]
  104                 # code.css will be generated by us if it does not exist in
  105                 # FILES_FOLDERS or theme assets.  It is guaranteed that the
  106                 # generation will happen before this task.
  107                 task = {
  108                     'file_dep': list(file_dep),
  109                     'task_dep': ['copy_assets', 'copy_files'],
  110                     'basename': str(self.name),
  111                     'name': str(output_path),
  112                     'actions': [(build_bundle, (name, file_dep))],
  113                     'targets': [output_path],
  114                     'uptodate': [
  115                         utils.config_changed({
  116                             1: kw,
  117                             2: file_dep
  118                         }, 'nikola.plugins.task.bundles')],
  119                     'clean': True,
  120                 }
  121                 yield utils.apply_filters(task, kw['filters'])
  122 
  123 
  124 def get_theme_bundles(themes):
  125     """Given a theme chain, return the bundle definitions."""
  126     bundles = {}
  127     for theme_name in themes:
  128         bundles_path = os.path.join(
  129             utils.get_theme_path(theme_name), 'bundles')
  130         if os.path.isfile(bundles_path):
  131             with open(bundles_path) as fd:
  132                 for line in fd:
  133                     try:
  134                         name, files = line.split('=')
  135                         files = [f.strip() for f in files.split(',')]
  136                         bundles[name.strip().replace('/', os.sep)] = files
  137                     except ValueError:
  138                         # for empty lines
  139                         pass
  140                 break
  141     return bundles
  142
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/nikola/plugins/task/bundles.py b/nikola/plugins/task/bundles.py
  --- a/nikola/plugins/task/bundles.py
  +++ b/nikola/plugins/task/bundles.py
  @@ -52,6 +52,7 @@
               utils.req_missing(['webassets'], 'USE_BUNDLES', optional=True)
               self.logger.warn('Setting USE_BUNDLES to False.')
               site.config['USE_BUNDLES'] = False
  +            site._GLOBAL_CONTEXT['use_bundles'] = False
           super(BuildBundles, self).set_site(site)
   
       def gen_tasks(self):
  
verification_info: {"golden_diff": "diff --git a/nikola/plugins/task/bundles.py b/nikola/plugins/task/bundles.py\n--- a/nikola/plugins/task/bundles.py\n+++ b/nikola/plugins/task/bundles.py\n@@ -52,6 +52,7 @@\n             utils.req_missing(['webassets'], 'USE_BUNDLES', optional=True)\n             self.logger.warn('Setting USE_BUNDLES to False.')\n             site.config['USE_BUNDLES'] = False\n+            site._GLOBAL_CONTEXT['use_bundles'] = False\n         super(BuildBundles, self).set_site(site)\n \n     def gen_tasks(self):\n", "issue": "nikola no longer has all-nocdn.*\nI started using `nikola` today for a gallery. The generated pages make reference to `all-nocdn.css` and `all-nocdn.js`, but they're not (longer?) part of `nikola`'s code:\n\n``` bash\nmdione@diablo:~/src/projects/nikola$ git remote show origin\n* remote origin\n  Fetch URL: https://github.com/getnikola/nikola.git\n  Push  URL: https://github.com/getnikola/nikola.git\n  HEAD branch: master\nmdione@diablo:~/src/projects/nikola$ git branch\n* master\nmdione@diablo:~/src/projects/nikola$ git pull\nAlready up-to-date.\nmdione@diablo:~/src/projects/nikola$ find . -name all-nocdn.*\nmdione@diablo:~/src/projects/nikola$\n```\n\nI just copied those files from and old attempt to use `nikola` and the site works. This happens with both versions `7.6.0-3` from Debian and from `master`, as you can see above.\n\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n\n# Copyright \u00a9 2012-2015 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\n\"\"\"Bundle assets using WebAssets.\"\"\"\n\nfrom __future__ import unicode_literals\n\nimport os\n\ntry:\n    import webassets\nexcept ImportError:\n    webassets = None  # NOQA\n\nfrom nikola.plugin_categories import LateTask\nfrom nikola import utils\n\n\nclass BuildBundles(LateTask):\n\n    \"\"\"Bundle assets using WebAssets.\"\"\"\n\n    name = \"create_bundles\"\n\n    def set_site(self, site):\n        \"\"\"Set Nikola site.\"\"\"\n        self.logger = utils.get_logger('bundles', utils.STDERR_HANDLER)\n        if webassets is None and site.config['USE_BUNDLES']:\n            utils.req_missing(['webassets'], 'USE_BUNDLES', optional=True)\n            self.logger.warn('Setting USE_BUNDLES to False.')\n            site.config['USE_BUNDLES'] = False\n        super(BuildBundles, self).set_site(site)\n\n    def gen_tasks(self):\n        \"\"\"Bundle assets using WebAssets.\"\"\"\n        kw = {\n            'filters': self.site.config['FILTERS'],\n            'output_folder': self.site.config['OUTPUT_FOLDER'],\n            'cache_folder': self.site.config['CACHE_FOLDER'],\n            'theme_bundles': get_theme_bundles(self.site.THEMES),\n            'themes': self.site.THEMES,\n            'files_folders': self.site.config['FILES_FOLDERS'],\n            'code_color_scheme': self.site.config['CODE_COLOR_SCHEME'],\n        }\n\n        def build_bundle(output, inputs):\n            out_dir = os.path.join(kw['output_folder'],\n                                   os.path.dirname(output))\n            inputs = [os.path.relpath(i, out_dir) for i in inputs if os.path.isfile(i)]\n            cache_dir = os.path.join(kw['cache_folder'], 'webassets')\n            utils.makedirs(cache_dir)\n            env = webassets.Environment(out_dir, os.path.dirname(output),\n                                        cache=cache_dir)\n            if inputs:\n                bundle = webassets.Bundle(*inputs, output=os.path.basename(output))\n                env.register(output, bundle)\n                # This generates the file\n                try:\n                    env[output].urls()\n                except Exception as e:\n                    self.logger.error(\"Failed to build bundles.\")\n                    self.logger.exception(e)\n                    self.logger.notice(\"Try running ``nikola clean`` and building again.\")\n            else:\n                with open(os.path.join(out_dir, os.path.basename(output)), 'wb+'):\n                    pass  # Create empty file\n\n        yield self.group_task()\n        if (webassets is not None and self.site.config['USE_BUNDLES'] is not\n                False):\n            for name, _files in kw['theme_bundles'].items():\n                output_path = os.path.join(kw['output_folder'], name)\n                dname = os.path.dirname(name)\n                files = []\n                for fname in _files:\n                    # paths are relative to dirname\n                    files.append(os.path.join(dname, fname))\n                file_dep = [os.path.join(kw['output_folder'], fname)\n                            for fname in files if\n                            utils.get_asset_path(fname, self.site.THEMES, self.site.config['FILES_FOLDERS']) or fname == os.path.join('assets', 'css', 'code.css')]\n                # code.css will be generated by us if it does not exist in\n                # FILES_FOLDERS or theme assets.  It is guaranteed that the\n                # generation will happen before this task.\n                task = {\n                    'file_dep': list(file_dep),\n                    'task_dep': ['copy_assets', 'copy_files'],\n                    'basename': str(self.name),\n                    'name': str(output_path),\n                    'actions': [(build_bundle, (name, file_dep))],\n                    'targets': [output_path],\n                    'uptodate': [\n                        utils.config_changed({\n                            1: kw,\n                            2: file_dep\n                        }, 'nikola.plugins.task.bundles')],\n                    'clean': True,\n                }\n                yield utils.apply_filters(task, kw['filters'])\n\n\ndef get_theme_bundles(themes):\n    \"\"\"Given a theme chain, return the bundle definitions.\"\"\"\n    bundles = {}\n    for theme_name in themes:\n        bundles_path = os.path.join(\n            utils.get_theme_path(theme_name), 'bundles')\n        if os.path.isfile(bundles_path):\n            with open(bundles_path) as fd:\n                for line in fd:\n                    try:\n                        name, files = line.split('=')\n                        files = [f.strip() for f in files.split(',')]\n                        bundles[name.strip().replace('/', os.sep)] = files\n                    except ValueError:\n                        # for empty lines\n                        pass\n                break\n    return bundles\n", "path": "nikola/plugins/task/bundles.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\n\n# Copyright \u00a9 2012-2015 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\n\"\"\"Bundle assets using WebAssets.\"\"\"\n\nfrom __future__ import unicode_literals\n\nimport os\n\ntry:\n    import webassets\nexcept ImportError:\n    webassets = None  # NOQA\n\nfrom nikola.plugin_categories import LateTask\nfrom nikola import utils\n\n\nclass BuildBundles(LateTask):\n\n    \"\"\"Bundle assets using WebAssets.\"\"\"\n\n    name = \"create_bundles\"\n\n    def set_site(self, site):\n        \"\"\"Set Nikola site.\"\"\"\n        self.logger = utils.get_logger('bundles', utils.STDERR_HANDLER)\n        if webassets is None and site.config['USE_BUNDLES']:\n            utils.req_missing(['webassets'], 'USE_BUNDLES', optional=True)\n            self.logger.warn('Setting USE_BUNDLES to False.')\n            site.config['USE_BUNDLES'] = False\n            site._GLOBAL_CONTEXT['use_bundles'] = False\n        super(BuildBundles, self).set_site(site)\n\n    def gen_tasks(self):\n        \"\"\"Bundle assets using WebAssets.\"\"\"\n        kw = {\n            'filters': self.site.config['FILTERS'],\n            'output_folder': self.site.config['OUTPUT_FOLDER'],\n            'cache_folder': self.site.config['CACHE_FOLDER'],\n            'theme_bundles': get_theme_bundles(self.site.THEMES),\n            'themes': self.site.THEMES,\n            'files_folders': self.site.config['FILES_FOLDERS'],\n            'code_color_scheme': self.site.config['CODE_COLOR_SCHEME'],\n        }\n\n        def build_bundle(output, inputs):\n            out_dir = os.path.join(kw['output_folder'],\n                                   os.path.dirname(output))\n            inputs = [os.path.relpath(i, out_dir) for i in inputs if os.path.isfile(i)]\n            cache_dir = os.path.join(kw['cache_folder'], 'webassets')\n            utils.makedirs(cache_dir)\n            env = webassets.Environment(out_dir, os.path.dirname(output),\n                                        cache=cache_dir)\n            if inputs:\n                bundle = webassets.Bundle(*inputs, output=os.path.basename(output))\n                env.register(output, bundle)\n                # This generates the file\n                try:\n                    env[output].urls()\n                except Exception as e:\n                    self.logger.error(\"Failed to build bundles.\")\n                    self.logger.exception(e)\n                    self.logger.notice(\"Try running ``nikola clean`` and building again.\")\n            else:\n                with open(os.path.join(out_dir, os.path.basename(output)), 'wb+'):\n                    pass  # Create empty file\n\n        yield self.group_task()\n        if (webassets is not None and self.site.config['USE_BUNDLES'] is not\n                False):\n            for name, _files in kw['theme_bundles'].items():\n                output_path = os.path.join(kw['output_folder'], name)\n                dname = os.path.dirname(name)\n                files = []\n                for fname in _files:\n                    # paths are relative to dirname\n                    files.append(os.path.join(dname, fname))\n                file_dep = [os.path.join(kw['output_folder'], fname)\n                            for fname in files if\n                            utils.get_asset_path(fname, self.site.THEMES, self.site.config['FILES_FOLDERS']) or fname == os.path.join('assets', 'css', 'code.css')]\n                # code.css will be generated by us if it does not exist in\n                # FILES_FOLDERS or theme assets.  It is guaranteed that the\n                # generation will happen before this task.\n                task = {\n                    'file_dep': list(file_dep),\n                    'task_dep': ['copy_assets', 'copy_files'],\n                    'basename': str(self.name),\n                    'name': str(output_path),\n                    'actions': [(build_bundle, (name, file_dep))],\n                    'targets': [output_path],\n                    'uptodate': [\n                        utils.config_changed({\n                            1: kw,\n                            2: file_dep\n                        }, 'nikola.plugins.task.bundles')],\n                    'clean': True,\n                }\n                yield utils.apply_filters(task, kw['filters'])\n\n\ndef get_theme_bundles(themes):\n    \"\"\"Given a theme chain, return the bundle definitions.\"\"\"\n    bundles = {}\n    for theme_name in themes:\n        bundles_path = os.path.join(\n            utils.get_theme_path(theme_name), 'bundles')\n        if os.path.isfile(bundles_path):\n            with open(bundles_path) as fd:\n                for line in fd:\n                    try:\n                        name, files = line.split('=')\n                        files = [f.strip() for f in files.split(',')]\n                        bundles[name.strip().replace('/', os.sep)] = files\n                    except ValueError:\n                        # for empty lines\n                        pass\n                break\n    return bundles\n", "path": "nikola/plugins/task/bundles.py"}]}