prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  YAML fails reading files with tuples
  Example file:
  
  ```
  foo: !!python/tuple
  - 1
  - 2
  - 3
  ```
  
  Error:
  
  ```
  ConstructorError: could not determine a constructor for the tag 'tag:yaml.org,2002:python/tuple'·
  ```
  
  </issue>
  <code>
  [start of visidata/loaders/yaml.py]
  1 from itertools import chain
  2 
  3 from visidata import VisiData, Progress, JsonSheet, vd
  4 
  5 
  6 @VisiData.api
  7 def open_yml(vd, p):
  8     return YamlSheet(p.name, source=p)
  9 
  10 VisiData.open_yaml = VisiData.open_yml
  11 
  12 class YamlSheet(JsonSheet):
  13     def iterload(self):
  14         yaml = vd.importExternal('yaml', 'PyYAML')
  15         with self.source.open_text() as fp:
  16             documents = yaml.safe_load_all(fp)
  17 
  18             self.columns = []
  19             self._knownKeys.clear()
  20 
  21             # Peek at the document stream to determine how to best DWIM.
  22             #
  23             # This code is a bit verbose because it avoids slurping the generator
  24             # all at once into memory.
  25             try:
  26                 first = next(documents)
  27             except StopIteration:
  28                 # Empty file‽
  29                 yield None
  30                 return
  31 
  32             try:
  33                 second = next(documents)
  34             except StopIteration:
  35                 if isinstance(first, list):
  36                     # A file with a single YAML list: yield one row per list item.
  37                     yield from Progress(first)
  38                 else:
  39                     # A file with a single YAML non-list value, e.g a dict.
  40                     yield first
  41             else:
  42                 # A file containing multiple YAML documents: yield one row per document.
  43                 yield from Progress(chain([first, second], documents), total=0)
  44
  [end of visidata/loaders/yaml.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/visidata/loaders/yaml.py b/visidata/loaders/yaml.py
  --- a/visidata/loaders/yaml.py
  +++ b/visidata/loaders/yaml.py
  @@ -12,8 +12,18 @@
   class YamlSheet(JsonSheet):
       def iterload(self):
           yaml = vd.importExternal('yaml', 'PyYAML')
  +
  +        class PrettySafeLoader(yaml.SafeLoader):
  +            def construct_python_tuple(self, node):
  +                return tuple(self.construct_sequence(node))
  +
  +        PrettySafeLoader.add_constructor(
  +            u'tag:yaml.org,2002:python/tuple',
  +            PrettySafeLoader.construct_python_tuple
  +        )
  +
           with self.source.open_text() as fp:
  -            documents = yaml.safe_load_all(fp)
  +            documents = yaml.load_all(fp, PrettySafeLoader)
   
               self.columns = []
               self._knownKeys.clear()
  
verification_info: {"golden_diff": "diff --git a/visidata/loaders/yaml.py b/visidata/loaders/yaml.py\n--- a/visidata/loaders/yaml.py\n+++ b/visidata/loaders/yaml.py\n@@ -12,8 +12,18 @@\n class YamlSheet(JsonSheet):\n     def iterload(self):\n         yaml = vd.importExternal('yaml', 'PyYAML')\n+\n+        class PrettySafeLoader(yaml.SafeLoader):\n+            def construct_python_tuple(self, node):\n+                return tuple(self.construct_sequence(node))\n+\n+        PrettySafeLoader.add_constructor(\n+            u'tag:yaml.org,2002:python/tuple',\n+            PrettySafeLoader.construct_python_tuple\n+        )\n+\n         with self.source.open_text() as fp:\n-            documents = yaml.safe_load_all(fp)\n+            documents = yaml.load_all(fp, PrettySafeLoader)\n \n             self.columns = []\n             self._knownKeys.clear()\n", "issue": "YAML fails reading files with tuples\nExample file:\r\n\r\n```\r\nfoo: !!python/tuple\r\n- 1\r\n- 2\r\n- 3\r\n```\r\n\r\nError:\r\n\r\n```\r\nConstructorError: could not determine a constructor for the tag 'tag:yaml.org,2002:python/tuple'\u00b7\r\n```\n", "before_files": [{"content": "from itertools import chain\n\nfrom visidata import VisiData, Progress, JsonSheet, vd\n\n\n@VisiData.api\ndef open_yml(vd, p):\n    return YamlSheet(p.name, source=p)\n\nVisiData.open_yaml = VisiData.open_yml\n\nclass YamlSheet(JsonSheet):\n    def iterload(self):\n        yaml = vd.importExternal('yaml', 'PyYAML')\n        with self.source.open_text() as fp:\n            documents = yaml.safe_load_all(fp)\n\n            self.columns = []\n            self._knownKeys.clear()\n\n            # Peek at the document stream to determine how to best DWIM.\n            #\n            # This code is a bit verbose because it avoids slurping the generator\n            # all at once into memory.\n            try:\n                first = next(documents)\n            except StopIteration:\n                # Empty file\u203d\n                yield None\n                return\n\n            try:\n                second = next(documents)\n            except StopIteration:\n                if isinstance(first, list):\n                    # A file with a single YAML list: yield one row per list item.\n                    yield from Progress(first)\n                else:\n                    # A file with a single YAML non-list value, e.g a dict.\n                    yield first\n            else:\n                # A file containing multiple YAML documents: yield one row per document.\n                yield from Progress(chain([first, second], documents), total=0)\n", "path": "visidata/loaders/yaml.py"}]}