prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Store custom Kordac templates
  The custom Kordac templates for Markdown conversion need to be stored within the repository.
  Gut instinct is to store these within the `templates` directory under `markdown_templates` and then exclude this folder from the Django template loader (to avoid loading unused templates in serving webpages).
  
  These can then be loaded for Kordac (possibly a Django loader would do the job).
  
  </issue>
  <code>
  [start of csunplugged/utils/BaseLoader.py]
  1 import yaml
  2 import mdx_math
  3 import abc
  4 import sys
  5 from kordac import Kordac
  6 from .check_converter_required_files import check_required_files
  7 
  8 
  9 class BaseLoader():
  10     """Base loader class for individual loaders"""
  11 
  12     def __init__(self, BASE_PATH='', load_log=[]):
  13         if load_log:
  14             self.load_log = load_log
  15         else:
  16             self.load_log = list(load_log)
  17         self.BASE_PATH = BASE_PATH
  18         self.setup_md_to_html_converter()
  19 
  20     def setup_md_to_html_converter(self):
  21         """Create Kordac converter with custom processors, html templates,
  22         and extensions.
  23         """
  24         templates = dict()
  25         templates['scratch'] = '<div><object data="{% autoescape false -%}{{ "{% get_static_prefix %}" }}img/scratch-blocks-{{ hash }}.svg{%- endautoescape %}" type="image/svg+xml" /></div>'  # noqa: E501 Fixed in #77
  26         templates['iframe'] = '<iframe allowtransparency="true" width="485" height="402" src="{{ link }}" frameborder="0" allowfullscreen="true"></iframe>'  # noqa: E501 Fixed in #77
  27         templates['heading'] = '<{{ heading_type }} id="{{ title_slug }}">{{ title }}</{{ heading_type }}>'  # noqa: E501 Fixed in #77
  28         extensions = [
  29             'markdown.extensions.fenced_code',
  30             'markdown.extensions.codehilite',
  31             'markdown.extensions.sane_lists',
  32             'markdown.extensions.tables',
  33             mdx_math.MathExtension(enable_dollar_delimiter=True)
  34         ]
  35         self.converter = Kordac(html_templates=templates, extensions=extensions)
  36         custom_processors = self.converter.processor_defaults()
  37         custom_processors.add('remove-title')
  38         self.converter.update_processors(custom_processors)
  39 
  40     def convert_md_file(self, md_file_path):
  41         """Returns the Kordac object for a given Markdown file
  42 
  43         Args:
  44             file_path: location of md file to convert
  45 
  46         Returns:
  47             Kordac result object
  48         """
  49         content = open(md_file_path, encoding='UTF-8').read()
  50         result = self.converter.convert(content)
  51         check_required_files(result.required_files)
  52         return result
  53 
  54     def log(self, log_message, indent_amount=0):
  55         """Adds the log message to the load log with the specified indent"""
  56         self.load_log.append((log_message, indent_amount))
  57 
  58     def print_load_log(self):
  59         """Output log messages from loader to console"""
  60         for (log, indent_amount) in self.load_log:
  61             indent = '  ' * indent_amount
  62             sys.stdout.write('{indent}{text}\n'.format(indent=indent, text=log))
  63         sys.stdout.write('\n')
  64         self.load_log = []
  65 
  66     def load_yaml_file(self, yaml_file_path):
  67         """Loads and reads yaml file
  68 
  69         Args:
  70             file_path: location of yaml file to read
  71 
  72         Returns:
  73              Either list or string, depending on structure of given yaml file
  74         """
  75         yaml_file = open(yaml_file_path, encoding='UTF-8').read()
  76         return yaml.load(yaml_file)
  77 
  78     @abc.abstractmethod
  79     def load(self):
  80         raise NotImplementedError('subclass does not implement this method')
  81
  [end of csunplugged/utils/BaseLoader.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/csunplugged/utils/BaseLoader.py b/csunplugged/utils/BaseLoader.py
  --- a/csunplugged/utils/BaseLoader.py
  +++ b/csunplugged/utils/BaseLoader.py
  @@ -2,6 +2,9 @@
   import mdx_math
   import abc
   import sys
  +import re
  +import os.path
  +from os import listdir
   from kordac import Kordac
   from .check_converter_required_files import check_required_files
   
  @@ -21,10 +24,7 @@
           """Create Kordac converter with custom processors, html templates,
           and extensions.
           """
  -        templates = dict()
  -        templates['scratch'] = '<div><object data="{% autoescape false -%}{{ "{% get_static_prefix %}" }}img/scratch-blocks-{{ hash }}.svg{%- endautoescape %}" type="image/svg+xml" /></div>'  # noqa: E501 Fixed in #77
  -        templates['iframe'] = '<iframe allowtransparency="true" width="485" height="402" src="{{ link }}" frameborder="0" allowfullscreen="true"></iframe>'  # noqa: E501 Fixed in #77
  -        templates['heading'] = '<{{ heading_type }} id="{{ title_slug }}">{{ title }}</{{ heading_type }}>'  # noqa: E501 Fixed in #77
  +        templates = self.load_template_files()
           extensions = [
               'markdown.extensions.fenced_code',
               'markdown.extensions.codehilite',
  @@ -75,6 +75,19 @@
           yaml_file = open(yaml_file_path, encoding='UTF-8').read()
           return yaml.load(yaml_file)
   
  +    def load_template_files(self):
  +        templates = dict()
  +        template_path = os.path.join(
  +            os.path.dirname(__file__),
  +            'custom_converter_templates/'
  +        )
  +        for file in listdir(template_path):
  +            template_file = re.search(r'(.*?).html$', file)
  +            if template_file:
  +                template_name = template_file.groups()[0]
  +                templates[template_name] = open(template_path + file).read()
  +        return templates
  +
       @abc.abstractmethod
       def load(self):
           raise NotImplementedError('subclass does not implement this method')
  
verification_info: {"golden_diff": "diff --git a/csunplugged/utils/BaseLoader.py b/csunplugged/utils/BaseLoader.py\n--- a/csunplugged/utils/BaseLoader.py\n+++ b/csunplugged/utils/BaseLoader.py\n@@ -2,6 +2,9 @@\n import mdx_math\n import abc\n import sys\n+import re\n+import os.path\n+from os import listdir\n from kordac import Kordac\n from .check_converter_required_files import check_required_files\n \n@@ -21,10 +24,7 @@\n         \"\"\"Create Kordac converter with custom processors, html templates,\n         and extensions.\n         \"\"\"\n-        templates = dict()\n-        templates['scratch'] = '<div><object data=\"{% autoescape false -%}{{ \"{% get_static_prefix %}\" }}img/scratch-blocks-{{ hash }}.svg{%- endautoescape %}\" type=\"image/svg+xml\" /></div>'  # noqa: E501 Fixed in #77\n-        templates['iframe'] = '<iframe allowtransparency=\"true\" width=\"485\" height=\"402\" src=\"{{ link }}\" frameborder=\"0\" allowfullscreen=\"true\"></iframe>'  # noqa: E501 Fixed in #77\n-        templates['heading'] = '<{{ heading_type }} id=\"{{ title_slug }}\">{{ title }}</{{ heading_type }}>'  # noqa: E501 Fixed in #77\n+        templates = self.load_template_files()\n         extensions = [\n             'markdown.extensions.fenced_code',\n             'markdown.extensions.codehilite',\n@@ -75,6 +75,19 @@\n         yaml_file = open(yaml_file_path, encoding='UTF-8').read()\n         return yaml.load(yaml_file)\n \n+    def load_template_files(self):\n+        templates = dict()\n+        template_path = os.path.join(\n+            os.path.dirname(__file__),\n+            'custom_converter_templates/'\n+        )\n+        for file in listdir(template_path):\n+            template_file = re.search(r'(.*?).html$', file)\n+            if template_file:\n+                template_name = template_file.groups()[0]\n+                templates[template_name] = open(template_path + file).read()\n+        return templates\n+\n     @abc.abstractmethod\n     def load(self):\n         raise NotImplementedError('subclass does not implement this method')\n", "issue": "Store custom Kordac templates\nThe custom Kordac templates for Markdown conversion need to be stored within the repository.\r\nGut instinct is to store these within the `templates` directory under `markdown_templates` and then exclude this folder from the Django template loader (to avoid loading unused templates in serving webpages).\r\n\r\nThese can then be loaded for Kordac (possibly a Django loader would do the job).\n", "before_files": [{"content": "import yaml\nimport mdx_math\nimport abc\nimport sys\nfrom kordac import Kordac\nfrom .check_converter_required_files import check_required_files\n\n\nclass BaseLoader():\n    \"\"\"Base loader class for individual loaders\"\"\"\n\n    def __init__(self, BASE_PATH='', load_log=[]):\n        if load_log:\n            self.load_log = load_log\n        else:\n            self.load_log = list(load_log)\n        self.BASE_PATH = BASE_PATH\n        self.setup_md_to_html_converter()\n\n    def setup_md_to_html_converter(self):\n        \"\"\"Create Kordac converter with custom processors, html templates,\n        and extensions.\n        \"\"\"\n        templates = dict()\n        templates['scratch'] = '<div><object data=\"{% autoescape false -%}{{ \"{% get_static_prefix %}\" }}img/scratch-blocks-{{ hash }}.svg{%- endautoescape %}\" type=\"image/svg+xml\" /></div>'  # noqa: E501 Fixed in #77\n        templates['iframe'] = '<iframe allowtransparency=\"true\" width=\"485\" height=\"402\" src=\"{{ link }}\" frameborder=\"0\" allowfullscreen=\"true\"></iframe>'  # noqa: E501 Fixed in #77\n        templates['heading'] = '<{{ heading_type }} id=\"{{ title_slug }}\">{{ title }}</{{ heading_type }}>'  # noqa: E501 Fixed in #77\n        extensions = [\n            'markdown.extensions.fenced_code',\n            'markdown.extensions.codehilite',\n            'markdown.extensions.sane_lists',\n            'markdown.extensions.tables',\n            mdx_math.MathExtension(enable_dollar_delimiter=True)\n        ]\n        self.converter = Kordac(html_templates=templates, extensions=extensions)\n        custom_processors = self.converter.processor_defaults()\n        custom_processors.add('remove-title')\n        self.converter.update_processors(custom_processors)\n\n    def convert_md_file(self, md_file_path):\n        \"\"\"Returns the Kordac object for a given Markdown file\n\n        Args:\n            file_path: location of md file to convert\n\n        Returns:\n            Kordac result object\n        \"\"\"\n        content = open(md_file_path, encoding='UTF-8').read()\n        result = self.converter.convert(content)\n        check_required_files(result.required_files)\n        return result\n\n    def log(self, log_message, indent_amount=0):\n        \"\"\"Adds the log message to the load log with the specified indent\"\"\"\n        self.load_log.append((log_message, indent_amount))\n\n    def print_load_log(self):\n        \"\"\"Output log messages from loader to console\"\"\"\n        for (log, indent_amount) in self.load_log:\n            indent = '  ' * indent_amount\n            sys.stdout.write('{indent}{text}\\n'.format(indent=indent, text=log))\n        sys.stdout.write('\\n')\n        self.load_log = []\n\n    def load_yaml_file(self, yaml_file_path):\n        \"\"\"Loads and reads yaml file\n\n        Args:\n            file_path: location of yaml file to read\n\n        Returns:\n             Either list or string, depending on structure of given yaml file\n        \"\"\"\n        yaml_file = open(yaml_file_path, encoding='UTF-8').read()\n        return yaml.load(yaml_file)\n\n    @abc.abstractmethod\n    def load(self):\n        raise NotImplementedError('subclass does not implement this method')\n", "path": "csunplugged/utils/BaseLoader.py"}]}