prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  docs: source: New File source tutorial
  The question of how to make a new data source came up [recently](https://gitter.im/dffml/community?at=5e0e4bfbfd580457e7b3e26a). We should have multiple tutorials for sources.
  
  We're going to use https://github.com/intel/dffml/issues/551 as the example for this tutorial, so that issue needs to be closed first.
  
  You'll want to make a
  
  `docs/tutorials/sources/index.rst`
  
  Then take this exist tutorial and move it under
  
  `docs/tutoirials/sources/complex.rst`
  
  You're new one will go under 
  
  `sources/file.rst`
  
  Te idea here is just to explain how you can write a source which reads data from some new filetype, with our example being the `.ini`
  
  Try to follow the new model tutorial format, where we do `literalinclude` and `:lines:` to talk about individual sections of the files we're writing.
  
  </issue>
  <code>
  [start of dffml/source/ini.py]
  1 from configparser import ConfigParser
  2 
  3 from ..base import config
  4 from ..record import Record
  5 from .file import FileSource
  6 from .memory import MemorySource
  7 from ..util.data import parser_helper
  8 from ..util.entrypoint import entrypoint
  9 
  10 
  11 @config
  12 class INISourceConfig:
  13     filename: str
  14     readwrite: bool = False
  15     allowempty: bool = False
  16 
  17 
  18 @entrypoint("ini")
  19 class INISource(FileSource, MemorySource):
  20     """
  21     Source to read files in .ini format.
  22     """
  23 
  24     CONFIG = INISourceConfig
  25 
  26     async def load_fd(self, ifile):
  27         # Creating an instance of configparser
  28         parser = ConfigParser()
  29         # Read from a file object
  30         parser.read_file(ifile)
  31         # Get all the sections present in the file
  32         sections = parser.sections()
  33 
  34         self.mem = {}
  35 
  36         # Go over each section
  37         for section in sections:
  38             # Get data under each section as a dict
  39             temp_dict = {}
  40             for k, v in parser.items(section):
  41                 temp_dict[k] = parser_helper(v)
  42             # Each section used as a record
  43             self.mem[str(section)] = Record(
  44                 str(section), data={"features": temp_dict},
  45             )
  46 
  47         self.logger.debug("%r loaded %d sections", self, len(self.mem))
  48 
  49     async def dump_fd(self, fd):
  50         # Create an instance of configparser
  51         parser = ConfigParser()
  52 
  53         # Go over each section and record in mem
  54         for section, record in self.mem.items():
  55             # Get each section data as a dict
  56             section_data = record.features()
  57             if section not in parser.keys():
  58                 # If section does not exist add new section
  59                 parser.add_section(section)
  60             # Set section data
  61             parser[section] = section_data
  62 
  63         # Write to the fileobject
  64         parser.write(fd)
  65 
  66         self.logger.debug("%r saved %d sections", self, len(self.mem))
  67
  [end of dffml/source/ini.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/dffml/source/ini.py b/dffml/source/ini.py
  --- a/dffml/source/ini.py
  +++ b/dffml/source/ini.py
  @@ -23,11 +23,11 @@
   
       CONFIG = INISourceConfig
   
  -    async def load_fd(self, ifile):
  +    async def load_fd(self, fileobj):
           # Creating an instance of configparser
           parser = ConfigParser()
           # Read from a file object
  -        parser.read_file(ifile)
  +        parser.read_file(fileobj)
           # Get all the sections present in the file
           sections = parser.sections()
   
  @@ -46,7 +46,7 @@
   
           self.logger.debug("%r loaded %d sections", self, len(self.mem))
   
  -    async def dump_fd(self, fd):
  +    async def dump_fd(self, fileobj):
           # Create an instance of configparser
           parser = ConfigParser()
   
  @@ -61,6 +61,6 @@
               parser[section] = section_data
   
           # Write to the fileobject
  -        parser.write(fd)
  +        parser.write(fileobj)
   
           self.logger.debug("%r saved %d sections", self, len(self.mem))
  
verification_info: {"golden_diff": "diff --git a/dffml/source/ini.py b/dffml/source/ini.py\n--- a/dffml/source/ini.py\n+++ b/dffml/source/ini.py\n@@ -23,11 +23,11 @@\n \n     CONFIG = INISourceConfig\n \n-    async def load_fd(self, ifile):\n+    async def load_fd(self, fileobj):\n         # Creating an instance of configparser\n         parser = ConfigParser()\n         # Read from a file object\n-        parser.read_file(ifile)\n+        parser.read_file(fileobj)\n         # Get all the sections present in the file\n         sections = parser.sections()\n \n@@ -46,7 +46,7 @@\n \n         self.logger.debug(\"%r loaded %d sections\", self, len(self.mem))\n \n-    async def dump_fd(self, fd):\n+    async def dump_fd(self, fileobj):\n         # Create an instance of configparser\n         parser = ConfigParser()\n \n@@ -61,6 +61,6 @@\n             parser[section] = section_data\n \n         # Write to the fileobject\n-        parser.write(fd)\n+        parser.write(fileobj)\n \n         self.logger.debug(\"%r saved %d sections\", self, len(self.mem))\n", "issue": "docs: source: New File source tutorial\nThe question of how to make a new data source came up [recently](https://gitter.im/dffml/community?at=5e0e4bfbfd580457e7b3e26a). We should have multiple tutorials for sources.\r\n\r\nWe're going to use https://github.com/intel/dffml/issues/551 as the example for this tutorial, so that issue needs to be closed first.\r\n\r\nYou'll want to make a\r\n\r\n`docs/tutorials/sources/index.rst`\r\n\r\nThen take this exist tutorial and move it under\r\n\r\n`docs/tutoirials/sources/complex.rst`\r\n\r\nYou're new one will go under \r\n\r\n`sources/file.rst`\r\n\r\nTe idea here is just to explain how you can write a source which reads data from some new filetype, with our example being the `.ini`\r\n\r\nTry to follow the new model tutorial format, where we do `literalinclude` and `:lines:` to talk about individual sections of the files we're writing.\n", "before_files": [{"content": "from configparser import ConfigParser\n\nfrom ..base import config\nfrom ..record import Record\nfrom .file import FileSource\nfrom .memory import MemorySource\nfrom ..util.data import parser_helper\nfrom ..util.entrypoint import entrypoint\n\n\n@config\nclass INISourceConfig:\n    filename: str\n    readwrite: bool = False\n    allowempty: bool = False\n\n\n@entrypoint(\"ini\")\nclass INISource(FileSource, MemorySource):\n    \"\"\"\n    Source to read files in .ini format.\n    \"\"\"\n\n    CONFIG = INISourceConfig\n\n    async def load_fd(self, ifile):\n        # Creating an instance of configparser\n        parser = ConfigParser()\n        # Read from a file object\n        parser.read_file(ifile)\n        # Get all the sections present in the file\n        sections = parser.sections()\n\n        self.mem = {}\n\n        # Go over each section\n        for section in sections:\n            # Get data under each section as a dict\n            temp_dict = {}\n            for k, v in parser.items(section):\n                temp_dict[k] = parser_helper(v)\n            # Each section used as a record\n            self.mem[str(section)] = Record(\n                str(section), data={\"features\": temp_dict},\n            )\n\n        self.logger.debug(\"%r loaded %d sections\", self, len(self.mem))\n\n    async def dump_fd(self, fd):\n        # Create an instance of configparser\n        parser = ConfigParser()\n\n        # Go over each section and record in mem\n        for section, record in self.mem.items():\n            # Get each section data as a dict\n            section_data = record.features()\n            if section not in parser.keys():\n                # If section does not exist add new section\n                parser.add_section(section)\n            # Set section data\n            parser[section] = section_data\n\n        # Write to the fileobject\n        parser.write(fd)\n\n        self.logger.debug(\"%r saved %d sections\", self, len(self.mem))\n", "path": "dffml/source/ini.py"}]}