prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Not compatible with ruamel.yaml 0.16
  Fails with,
  
  ```
  Traceback (most recent call last):
  
    File "/home/travis/miniconda/bin/conda-smithy", line 10, in <module>
  
      sys.exit(main())
  
    File "/home/travis/miniconda/lib/python3.7/site-packages/conda_smithy/cli.py", line 470, in main
  
      args.subcommand_func(args)
  
    File "/home/travis/miniconda/lib/python3.7/site-packages/conda_smithy/cli.py", line 217, in __call__
  
      args.feedstock_directory, owner, repo
  
    File "/home/travis/miniconda/lib/python3.7/site-packages/conda_smithy/ci_register.py", line 351, in travis_token_update_conda_forge_config
  
      ] = travis_encrypt_binstar_token(slug, item)
  
    File "/home/travis/miniconda/lib/python3.7/contextlib.py", line 119, in __exit__
  
      next(self.gen)
  
    File "/home/travis/miniconda/lib/python3.7/site-packages/conda_smithy/utils.py", line 92, in update_conda_forge_config
  
      fh.write(yaml.dump(code))
  
    File "/home/travis/miniconda/lib/python3.7/site-packages/ruamel/yaml/main.py", line 448, in dump
  
      raise TypeError('Need a stream argument when not dumping from context manager')
  
  TypeError: Need a stream argument when not dumping from context manager
  ```
  
  cc @ocefpaf, @scopatz
  
  </issue>
  <code>
  [start of conda_smithy/utils.py]
  1 import shutil
  2 import tempfile
  3 import jinja2
  4 import datetime
  5 import time
  6 import os
  7 import sys
  8 from collections import defaultdict
  9 from contextlib import contextmanager
  10 
  11 import ruamel.yaml
  12 
  13 
  14 # define global yaml API
  15 # roundrip-loader and allowing duplicate keys
  16 # for handling # [filter] / # [not filter]
  17 yaml = ruamel.yaml.YAML(typ="rt")
  18 yaml.allow_duplicate_keys = True
  19 
  20 
  21 @contextmanager
  22 def tmp_directory():
  23     tmp_dir = tempfile.mkdtemp("_recipe")
  24     yield tmp_dir
  25     shutil.rmtree(tmp_dir)
  26 
  27 
  28 class NullUndefined(jinja2.Undefined):
  29     def __unicode__(self):
  30         return self._undefined_name
  31 
  32     def __getattr__(self, name):
  33         return "{}.{}".format(self, name)
  34 
  35     def __getitem__(self, name):
  36         return '{}["{}"]'.format(self, name)
  37 
  38 
  39 class MockOS(dict):
  40     def __init__(self):
  41         self.environ = defaultdict(lambda: "")
  42         self.sep = "/"
  43 
  44 
  45 def render_meta_yaml(text):
  46     env = jinja2.Environment(undefined=NullUndefined)
  47 
  48     # stub out cb3 jinja2 functions - they are not important for linting
  49     #    if we don't stub them out, the ruamel.yaml load fails to interpret them
  50     #    we can't just use conda-build's api.render functionality, because it would apply selectors
  51     env.globals.update(
  52         dict(
  53             compiler=lambda x: x + "_compiler_stub",
  54             pin_subpackage=lambda *args, **kwargs: "subpackage_stub",
  55             pin_compatible=lambda *args, **kwargs: "compatible_pin_stub",
  56             cdt=lambda *args, **kwargs: "cdt_stub",
  57             load_file_regex=lambda *args, **kwargs: defaultdict(lambda: ""),
  58             datetime=datetime,
  59             time=time,
  60             target_platform="linux-64",
  61         )
  62     )
  63     mockos = MockOS()
  64     py_ver = "3.7"
  65     context = {"os": mockos, "environ": mockos.environ, "PY_VER": py_ver}
  66     content = env.from_string(text).render(context)
  67     return content
  68 
  69 
  70 @contextmanager
  71 def update_conda_forge_config(feedstock_directory):
  72     """Utility method used to update conda forge configuration files
  73 
  74     Uage:
  75     >>> with update_conda_forge_config(somepath) as cfg:
  76     ...     cfg['foo'] = 'bar'
  77     """
  78     forge_yaml = os.path.join(feedstock_directory, "conda-forge.yml")
  79     if os.path.exists(forge_yaml):
  80         with open(forge_yaml, "r") as fh:
  81             code = yaml.load(fh)
  82     else:
  83         code = {}
  84 
  85     # Code could come in as an empty list.
  86     if not code:
  87         code = {}
  88 
  89     yield code
  90 
  91     with open(forge_yaml, "w") as fh:
  92         fh.write(yaml.dump(code))
  93
  [end of conda_smithy/utils.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/conda_smithy/utils.py b/conda_smithy/utils.py
  --- a/conda_smithy/utils.py
  +++ b/conda_smithy/utils.py
  @@ -88,5 +88,4 @@
   
       yield code
   
  -    with open(forge_yaml, "w") as fh:
  -        fh.write(yaml.dump(code))
  +    yaml.dump(code, forge_yaml)
  
verification_info: {"golden_diff": "diff --git a/conda_smithy/utils.py b/conda_smithy/utils.py\n--- a/conda_smithy/utils.py\n+++ b/conda_smithy/utils.py\n@@ -88,5 +88,4 @@\n \n     yield code\n \n-    with open(forge_yaml, \"w\") as fh:\n-        fh.write(yaml.dump(code))\n+    yaml.dump(code, forge_yaml)\n", "issue": "Not compatible with ruamel.yaml 0.16\nFails with,\r\n\r\n```\r\nTraceback (most recent call last):\r\n\r\n  File \"/home/travis/miniconda/bin/conda-smithy\", line 10, in <module>\r\n\r\n    sys.exit(main())\r\n\r\n  File \"/home/travis/miniconda/lib/python3.7/site-packages/conda_smithy/cli.py\", line 470, in main\r\n\r\n    args.subcommand_func(args)\r\n\r\n  File \"/home/travis/miniconda/lib/python3.7/site-packages/conda_smithy/cli.py\", line 217, in __call__\r\n\r\n    args.feedstock_directory, owner, repo\r\n\r\n  File \"/home/travis/miniconda/lib/python3.7/site-packages/conda_smithy/ci_register.py\", line 351, in travis_token_update_conda_forge_config\r\n\r\n    ] = travis_encrypt_binstar_token(slug, item)\r\n\r\n  File \"/home/travis/miniconda/lib/python3.7/contextlib.py\", line 119, in __exit__\r\n\r\n    next(self.gen)\r\n\r\n  File \"/home/travis/miniconda/lib/python3.7/site-packages/conda_smithy/utils.py\", line 92, in update_conda_forge_config\r\n\r\n    fh.write(yaml.dump(code))\r\n\r\n  File \"/home/travis/miniconda/lib/python3.7/site-packages/ruamel/yaml/main.py\", line 448, in dump\r\n\r\n    raise TypeError('Need a stream argument when not dumping from context manager')\r\n\r\nTypeError: Need a stream argument when not dumping from context manager\r\n```\r\n\r\ncc @ocefpaf, @scopatz\n", "before_files": [{"content": "import shutil\nimport tempfile\nimport jinja2\nimport datetime\nimport time\nimport os\nimport sys\nfrom collections import defaultdict\nfrom contextlib import contextmanager\n\nimport ruamel.yaml\n\n\n# define global yaml API\n# roundrip-loader and allowing duplicate keys\n# for handling # [filter] / # [not filter]\nyaml = ruamel.yaml.YAML(typ=\"rt\")\nyaml.allow_duplicate_keys = True\n\n\n@contextmanager\ndef tmp_directory():\n    tmp_dir = tempfile.mkdtemp(\"_recipe\")\n    yield tmp_dir\n    shutil.rmtree(tmp_dir)\n\n\nclass NullUndefined(jinja2.Undefined):\n    def __unicode__(self):\n        return self._undefined_name\n\n    def __getattr__(self, name):\n        return \"{}.{}\".format(self, name)\n\n    def __getitem__(self, name):\n        return '{}[\"{}\"]'.format(self, name)\n\n\nclass MockOS(dict):\n    def __init__(self):\n        self.environ = defaultdict(lambda: \"\")\n        self.sep = \"/\"\n\n\ndef render_meta_yaml(text):\n    env = jinja2.Environment(undefined=NullUndefined)\n\n    # stub out cb3 jinja2 functions - they are not important for linting\n    #    if we don't stub them out, the ruamel.yaml load fails to interpret them\n    #    we can't just use conda-build's api.render functionality, because it would apply selectors\n    env.globals.update(\n        dict(\n            compiler=lambda x: x + \"_compiler_stub\",\n            pin_subpackage=lambda *args, **kwargs: \"subpackage_stub\",\n            pin_compatible=lambda *args, **kwargs: \"compatible_pin_stub\",\n            cdt=lambda *args, **kwargs: \"cdt_stub\",\n            load_file_regex=lambda *args, **kwargs: defaultdict(lambda: \"\"),\n            datetime=datetime,\n            time=time,\n            target_platform=\"linux-64\",\n        )\n    )\n    mockos = MockOS()\n    py_ver = \"3.7\"\n    context = {\"os\": mockos, \"environ\": mockos.environ, \"PY_VER\": py_ver}\n    content = env.from_string(text).render(context)\n    return content\n\n\n@contextmanager\ndef update_conda_forge_config(feedstock_directory):\n    \"\"\"Utility method used to update conda forge configuration files\n\n    Uage:\n    >>> with update_conda_forge_config(somepath) as cfg:\n    ...     cfg['foo'] = 'bar'\n    \"\"\"\n    forge_yaml = os.path.join(feedstock_directory, \"conda-forge.yml\")\n    if os.path.exists(forge_yaml):\n        with open(forge_yaml, \"r\") as fh:\n            code = yaml.load(fh)\n    else:\n        code = {}\n\n    # Code could come in as an empty list.\n    if not code:\n        code = {}\n\n    yield code\n\n    with open(forge_yaml, \"w\") as fh:\n        fh.write(yaml.dump(code))\n", "path": "conda_smithy/utils.py"}]}