prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  [RFC] Support multidoc yaml files
  **Is your feature request related to a problem? Please describe.**
  Sometimes it can be difficult or impossible to pass multiple files with config fragments. yaml support multiple documents in one file and `safe_load_all` from pyaml api loads that accordingly. It is standard yaml feature, it would be nice to support it and make in usable in cases when passing one file (composited from more files) would be easier.
  
  **Describe the solution you'd like**
  Support `safe_load_all` as yaml loader.
  
  **Describe alternatives you've considered**
  Passing multiple files will do the work, however it doesn't have to be always straightforward.
  
  **Additional context**
  I have prepared a patch
  
  
  </issue>
  <code>
  [start of dynaconf/loaders/yaml_loader.py]
  1 from __future__ import annotations
  2 
  3 import sys
  4 from pathlib import Path
  5 from typing import TextIO
  6 from warnings import warn
  7 
  8 from dynaconf import default_settings
  9 from dynaconf.constants import YAML_EXTENSIONS
  10 from dynaconf.loaders.base import BaseLoader
  11 from dynaconf.utils import object_merge
  12 from dynaconf.utils.parse_conf import try_to_encode
  13 from dynaconf.vendor.ruamel import yaml
  14 
  15 # Add support for Dynaconf Lazy values to YAML dumper
  16 yaml.SafeDumper.yaml_representers[
  17     None
  18 ] = lambda self, data: yaml.representer.SafeRepresenter.represent_str(
  19     self, try_to_encode(data)
  20 )
  21 
  22 
  23 def load(obj, env=None, silent=True, key=None, filename=None, validate=False):
  24     """
  25     Reads and loads in to "obj" a single key or all keys from source file.
  26 
  27     :param obj: the settings instance
  28     :param env: settings current env default='development'
  29     :param silent: if errors should raise
  30     :param key: if defined load a single key, else load all in env
  31     :param filename: Optional custom filename to load
  32     :return: None
  33     """
  34     # Resolve the loaders
  35     # https://github.com/yaml/pyyaml/wiki/PyYAML-yaml.load(input)-Deprecation
  36     # Possible values are `safe_load, full_load, unsafe_load, load`
  37     yaml_reader = getattr(
  38         yaml, obj.get("YAML_LOADER_FOR_DYNACONF"), yaml.safe_load
  39     )
  40     if yaml_reader.__name__ == "unsafe_load":  # pragma: no cover
  41         warn(
  42             "yaml.unsafe_load is deprecated."
  43             " Please read https://msg.pyyaml.org/load for full details."
  44             " Try to use full_load or safe_load."
  45         )
  46 
  47     loader = BaseLoader(
  48         obj=obj,
  49         env=env,
  50         identifier="yaml",
  51         extensions=YAML_EXTENSIONS,
  52         file_reader=yaml_reader,
  53         string_reader=yaml_reader,
  54         validate=validate,
  55     )
  56     loader.load(
  57         filename=filename,
  58         key=key,
  59         silent=silent,
  60     )
  61 
  62 
  63 def write(settings_path, settings_data, merge=True):
  64     """Write data to a settings file.
  65 
  66     :param settings_path: the filepath
  67     :param settings_data: a dictionary with data
  68     :param merge: boolean if existing file should be merged with new data
  69     :param stdout: boolean if should output to stdout instead of file
  70     """
  71     settings_path = Path(settings_path)
  72     if settings_path.exists() and merge:  # pragma: no cover
  73         with open(
  74             str(settings_path), encoding=default_settings.ENCODING_FOR_DYNACONF
  75         ) as open_file:
  76             object_merge(yaml.safe_load(open_file), settings_data)
  77 
  78     with open(
  79         str(settings_path),
  80         "w",
  81         encoding=default_settings.ENCODING_FOR_DYNACONF,
  82     ) as open_file:
  83         yaml.dump(
  84             settings_data,
  85             open_file,
  86             Dumper=yaml.dumper.SafeDumper,
  87             explicit_start=True,
  88             indent=2,
  89             default_flow_style=False,
  90         )
  91
  [end of dynaconf/loaders/yaml_loader.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/dynaconf/loaders/yaml_loader.py b/dynaconf/loaders/yaml_loader.py
  --- a/dynaconf/loaders/yaml_loader.py
  +++ b/dynaconf/loaders/yaml_loader.py
  @@ -20,6 +20,41 @@
   )
   
   
  +class AllLoader(BaseLoader):
  +    """YAML Loader to load multi doc files"""
  +
  +    @staticmethod
  +    def _assign_data(data, source_file, content):
  +        """Helper to iterate through all docs in a file"""
  +        content = tuple(content)
  +        if len(content) == 1:
  +            data[source_file] = content[0]
  +        elif len(content) > 1:
  +            for i, doc in enumerate(content):
  +                data[f"{source_file}[{i}]"] = doc
  +
  +    def get_source_data(self, files):
  +        data = {}
  +        for source_file in files:
  +            if source_file.endswith(self.extensions):
  +                try:
  +                    with open(source_file, **self.opener_params) as open_file:
  +                        content = self.file_reader(open_file)
  +                        self.obj._loaded_files.append(source_file)
  +                        self._assign_data(data, source_file, content)
  +                except OSError as e:
  +                    if ".local." not in source_file:
  +                        warn(
  +                            f"{self.identifier}_loader: {source_file} "
  +                            f":{str(e)}"
  +                        )
  +            else:
  +                # for tests it is possible to pass string
  +                content = self.string_reader(source_file)
  +                self._assign_data(data, source_file, content)
  +        return data
  +
  +
   def load(obj, env=None, silent=True, key=None, filename=None, validate=False):
       """
       Reads and loads in to "obj" a single key or all keys from source file.
  @@ -33,7 +68,8 @@
       """
       # Resolve the loaders
       # https://github.com/yaml/pyyaml/wiki/PyYAML-yaml.load(input)-Deprecation
  -    # Possible values are `safe_load, full_load, unsafe_load, load`
  +    # Possible values are:
  +    #   `safe_load, full_load, unsafe_load, load, safe_load_all`
       yaml_reader = getattr(
           yaml, obj.get("YAML_LOADER_FOR_DYNACONF"), yaml.safe_load
       )
  @@ -44,7 +80,11 @@
               " Try to use full_load or safe_load."
           )
   
  -    loader = BaseLoader(
  +    _loader = BaseLoader
  +    if yaml_reader.__name__.endswith("_all"):
  +        _loader = AllLoader
  +
  +    loader = _loader(
           obj=obj,
           env=env,
           identifier="yaml",
  
verification_info: {"golden_diff": "diff --git a/dynaconf/loaders/yaml_loader.py b/dynaconf/loaders/yaml_loader.py\n--- a/dynaconf/loaders/yaml_loader.py\n+++ b/dynaconf/loaders/yaml_loader.py\n@@ -20,6 +20,41 @@\n )\n \n \n+class AllLoader(BaseLoader):\n+    \"\"\"YAML Loader to load multi doc files\"\"\"\n+\n+    @staticmethod\n+    def _assign_data(data, source_file, content):\n+        \"\"\"Helper to iterate through all docs in a file\"\"\"\n+        content = tuple(content)\n+        if len(content) == 1:\n+            data[source_file] = content[0]\n+        elif len(content) > 1:\n+            for i, doc in enumerate(content):\n+                data[f\"{source_file}[{i}]\"] = doc\n+\n+    def get_source_data(self, files):\n+        data = {}\n+        for source_file in files:\n+            if source_file.endswith(self.extensions):\n+                try:\n+                    with open(source_file, **self.opener_params) as open_file:\n+                        content = self.file_reader(open_file)\n+                        self.obj._loaded_files.append(source_file)\n+                        self._assign_data(data, source_file, content)\n+                except OSError as e:\n+                    if \".local.\" not in source_file:\n+                        warn(\n+                            f\"{self.identifier}_loader: {source_file} \"\n+                            f\":{str(e)}\"\n+                        )\n+            else:\n+                # for tests it is possible to pass string\n+                content = self.string_reader(source_file)\n+                self._assign_data(data, source_file, content)\n+        return data\n+\n+\n def load(obj, env=None, silent=True, key=None, filename=None, validate=False):\n     \"\"\"\n     Reads and loads in to \"obj\" a single key or all keys from source file.\n@@ -33,7 +68,8 @@\n     \"\"\"\n     # Resolve the loaders\n     # https://github.com/yaml/pyyaml/wiki/PyYAML-yaml.load(input)-Deprecation\n-    # Possible values are `safe_load, full_load, unsafe_load, load`\n+    # Possible values are:\n+    #   `safe_load, full_load, unsafe_load, load, safe_load_all`\n     yaml_reader = getattr(\n         yaml, obj.get(\"YAML_LOADER_FOR_DYNACONF\"), yaml.safe_load\n     )\n@@ -44,7 +80,11 @@\n             \" Try to use full_load or safe_load.\"\n         )\n \n-    loader = BaseLoader(\n+    _loader = BaseLoader\n+    if yaml_reader.__name__.endswith(\"_all\"):\n+        _loader = AllLoader\n+\n+    loader = _loader(\n         obj=obj,\n         env=env,\n         identifier=\"yaml\",\n", "issue": "[RFC] Support multidoc yaml files\n**Is your feature request related to a problem? Please describe.**\r\nSometimes it can be difficult or impossible to pass multiple files with config fragments. yaml support multiple documents in one file and `safe_load_all` from pyaml api loads that accordingly. It is standard yaml feature, it would be nice to support it and make in usable in cases when passing one file (composited from more files) would be easier.\r\n\r\n**Describe the solution you'd like**\r\nSupport `safe_load_all` as yaml loader.\r\n\r\n**Describe alternatives you've considered**\r\nPassing multiple files will do the work, however it doesn't have to be always straightforward.\r\n\r\n**Additional context**\r\nI have prepared a patch\r\n\n", "before_files": [{"content": "from __future__ import annotations\n\nimport sys\nfrom pathlib import Path\nfrom typing import TextIO\nfrom warnings import warn\n\nfrom dynaconf import default_settings\nfrom dynaconf.constants import YAML_EXTENSIONS\nfrom dynaconf.loaders.base import BaseLoader\nfrom dynaconf.utils import object_merge\nfrom dynaconf.utils.parse_conf import try_to_encode\nfrom dynaconf.vendor.ruamel import yaml\n\n# Add support for Dynaconf Lazy values to YAML dumper\nyaml.SafeDumper.yaml_representers[\n    None\n] = lambda self, data: yaml.representer.SafeRepresenter.represent_str(\n    self, try_to_encode(data)\n)\n\n\ndef load(obj, env=None, silent=True, key=None, filename=None, validate=False):\n    \"\"\"\n    Reads and loads in to \"obj\" a single key or all keys from source file.\n\n    :param obj: the settings instance\n    :param env: settings current env default='development'\n    :param silent: if errors should raise\n    :param key: if defined load a single key, else load all in env\n    :param filename: Optional custom filename to load\n    :return: None\n    \"\"\"\n    # Resolve the loaders\n    # https://github.com/yaml/pyyaml/wiki/PyYAML-yaml.load(input)-Deprecation\n    # Possible values are `safe_load, full_load, unsafe_load, load`\n    yaml_reader = getattr(\n        yaml, obj.get(\"YAML_LOADER_FOR_DYNACONF\"), yaml.safe_load\n    )\n    if yaml_reader.__name__ == \"unsafe_load\":  # pragma: no cover\n        warn(\n            \"yaml.unsafe_load is deprecated.\"\n            \" Please read https://msg.pyyaml.org/load for full details.\"\n            \" Try to use full_load or safe_load.\"\n        )\n\n    loader = BaseLoader(\n        obj=obj,\n        env=env,\n        identifier=\"yaml\",\n        extensions=YAML_EXTENSIONS,\n        file_reader=yaml_reader,\n        string_reader=yaml_reader,\n        validate=validate,\n    )\n    loader.load(\n        filename=filename,\n        key=key,\n        silent=silent,\n    )\n\n\ndef write(settings_path, settings_data, merge=True):\n    \"\"\"Write data to a settings file.\n\n    :param settings_path: the filepath\n    :param settings_data: a dictionary with data\n    :param merge: boolean if existing file should be merged with new data\n    :param stdout: boolean if should output to stdout instead of file\n    \"\"\"\n    settings_path = Path(settings_path)\n    if settings_path.exists() and merge:  # pragma: no cover\n        with open(\n            str(settings_path), encoding=default_settings.ENCODING_FOR_DYNACONF\n        ) as open_file:\n            object_merge(yaml.safe_load(open_file), settings_data)\n\n    with open(\n        str(settings_path),\n        \"w\",\n        encoding=default_settings.ENCODING_FOR_DYNACONF,\n    ) as open_file:\n        yaml.dump(\n            settings_data,\n            open_file,\n            Dumper=yaml.dumper.SafeDumper,\n            explicit_start=True,\n            indent=2,\n            default_flow_style=False,\n        )\n", "path": "dynaconf/loaders/yaml_loader.py"}]}