prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  :args seems to break with {} in list.
  I am working on a repo with some hooks for my company: https://github.com/marick/pre-commit-hooks
  
  There is a hook that works fine with this `.pre-commit-config.yaml`:
  
  ``` yaml
  -   repo: /Users/marick/src/pre-commit-hooks
      sha: d6dee96f56bf9290f7ebb852c4252c50b8f6215d
      stages: [commit, push]
      hooks:
      -   id: prohibit-suspicious-patterns
          args: ["AKIA[[:alnum]]", --]
  ```
  
  However, it I change the first arg by adding `{1}`:
  
  ``` yaml
          args: ["AKIA[[:alnum]]{1}", --]
  ```
  
  ... I get this:
  
  ```
  prohibit suspicious patterns..................................................................
  An unexpected error has occurred: IndexError: tuple index out of range
  Check the log at ~/.pre-commit/pre-commit.log
  ```
  
  The contents of `pre-commit.log`:
  
  ```
  An unexpected error has occurred: IndexError: tuple index out of range
  Traceback (most recent call last):
    File "/usr/local/lib/python2.7/site-packages/pre_commit/error_handler.py", line 36, in error_handler
      yield
    File "/usr/local/lib/python2.7/site-packages/pre_commit/main.py", line 150, in main
      return run(runner, args)
    File "/usr/local/lib/python2.7/site-packages/pre_commit/commands/run.py", line 212, in run
      return _run_hooks(repo_hooks, args, write, environ)
    File "/usr/local/lib/python2.7/site-packages/pre_commit/commands/run.py", line 136, in _run_hooks
      retval |= _run_single_hook(hook, repo, args, write, skips)
    File "/usr/local/lib/python2.7/site-packages/pre_commit/commands/run.py", line 89, in _run_single_hook
      retcode, stdout, stderr = repo.run_hook(hook, filenames)
    File "/usr/local/lib/python2.7/site-packages/pre_commit/repository.py", line 145, in run_hook
      self.cmd_runner, hook, file_args,
    File "/usr/local/lib/python2.7/site-packages/pre_commit/languages/script.py", line 23, in run_hook
      encoding=None,
    File "/usr/local/lib/python2.7/site-packages/pre_commit/prefixed_command_runner.py", line 40, in run
      replaced_cmd = _replace_cmd(cmd, prefix=self.prefix_dir)
    File "/usr/local/lib/python2.7/site-packages/pre_commit/prefixed_command_runner.py", line 11, in _replace_cmd
      return [part.format(**kwargs) for part in cmd]
  IndexError: tuple index out of range
  
  ```
  
  
  </issue>
  <code>
  [start of pre_commit/prefixed_command_runner.py]
  1 from __future__ import unicode_literals
  2 
  3 import os
  4 import os.path
  5 import subprocess
  6 
  7 from pre_commit.util import cmd_output
  8 
  9 
  10 def _replace_cmd(cmd, **kwargs):
  11     return [part.format(**kwargs) for part in cmd]
  12 
  13 
  14 class PrefixedCommandRunner(object):
  15     """A PrefixedCommandRunner allows you to run subprocess commands with
  16     comand substitution.
  17 
  18     For instance:
  19         PrefixedCommandRunner('/tmp/foo').run(['{prefix}foo.sh', 'bar', 'baz'])
  20 
  21     will run ['/tmp/foo/foo.sh', 'bar', 'baz']
  22     """
  23 
  24     def __init__(
  25             self,
  26             prefix_dir,
  27             popen=subprocess.Popen,
  28             makedirs=os.makedirs
  29     ):
  30         self.prefix_dir = prefix_dir.rstrip(os.sep) + os.sep
  31         self.__popen = popen
  32         self.__makedirs = makedirs
  33 
  34     def _create_path_if_not_exists(self):
  35         if not os.path.exists(self.prefix_dir):
  36             self.__makedirs(self.prefix_dir)
  37 
  38     def run(self, cmd, **kwargs):
  39         self._create_path_if_not_exists()
  40         replaced_cmd = _replace_cmd(cmd, prefix=self.prefix_dir)
  41         return cmd_output(*replaced_cmd, __popen=self.__popen, **kwargs)
  42 
  43     def path(self, *parts):
  44         path = os.path.join(self.prefix_dir, *parts)
  45         return os.path.normpath(path)
  46 
  47     def exists(self, *parts):
  48         return os.path.exists(self.path(*parts))
  49 
  50     @classmethod
  51     def from_command_runner(cls, command_runner, path_end):
  52         """Constructs a new command runner from an existing one by appending
  53         `path_end` to the command runner's prefix directory.
  54         """
  55         return cls(
  56             command_runner.path(path_end),
  57             popen=command_runner.__popen,
  58             makedirs=command_runner.__makedirs,
  59         )
  60
  [end of pre_commit/prefixed_command_runner.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/pre_commit/prefixed_command_runner.py b/pre_commit/prefixed_command_runner.py
  --- a/pre_commit/prefixed_command_runner.py
  +++ b/pre_commit/prefixed_command_runner.py
  @@ -7,10 +7,6 @@
   from pre_commit.util import cmd_output
   
   
  -def _replace_cmd(cmd, **kwargs):
  -    return [part.format(**kwargs) for part in cmd]
  -
  -
   class PrefixedCommandRunner(object):
       """A PrefixedCommandRunner allows you to run subprocess commands with
       comand substitution.
  @@ -37,7 +33,9 @@
   
       def run(self, cmd, **kwargs):
           self._create_path_if_not_exists()
  -        replaced_cmd = _replace_cmd(cmd, prefix=self.prefix_dir)
  +        replaced_cmd = [
  +            part.replace('{prefix}', self.prefix_dir) for part in cmd
  +        ]
           return cmd_output(*replaced_cmd, __popen=self.__popen, **kwargs)
   
       def path(self, *parts):
  
verification_info: {"golden_diff": "diff --git a/pre_commit/prefixed_command_runner.py b/pre_commit/prefixed_command_runner.py\n--- a/pre_commit/prefixed_command_runner.py\n+++ b/pre_commit/prefixed_command_runner.py\n@@ -7,10 +7,6 @@\n from pre_commit.util import cmd_output\n \n \n-def _replace_cmd(cmd, **kwargs):\n-    return [part.format(**kwargs) for part in cmd]\n-\n-\n class PrefixedCommandRunner(object):\n     \"\"\"A PrefixedCommandRunner allows you to run subprocess commands with\n     comand substitution.\n@@ -37,7 +33,9 @@\n \n     def run(self, cmd, **kwargs):\n         self._create_path_if_not_exists()\n-        replaced_cmd = _replace_cmd(cmd, prefix=self.prefix_dir)\n+        replaced_cmd = [\n+            part.replace('{prefix}', self.prefix_dir) for part in cmd\n+        ]\n         return cmd_output(*replaced_cmd, __popen=self.__popen, **kwargs)\n \n     def path(self, *parts):\n", "issue": ":args seems to break with {} in list.\nI am working on a repo with some hooks for my company: https://github.com/marick/pre-commit-hooks\n\nThere is a hook that works fine with this `.pre-commit-config.yaml`:\n\n``` yaml\n-   repo: /Users/marick/src/pre-commit-hooks\n    sha: d6dee96f56bf9290f7ebb852c4252c50b8f6215d\n    stages: [commit, push]\n    hooks:\n    -   id: prohibit-suspicious-patterns\n        args: [\"AKIA[[:alnum]]\", --]\n```\n\nHowever, it I change the first arg by adding `{1}`:\n\n``` yaml\n        args: [\"AKIA[[:alnum]]{1}\", --]\n```\n\n... I get this:\n\n```\nprohibit suspicious patterns..................................................................\nAn unexpected error has occurred: IndexError: tuple index out of range\nCheck the log at ~/.pre-commit/pre-commit.log\n```\n\nThe contents of `pre-commit.log`:\n\n```\nAn unexpected error has occurred: IndexError: tuple index out of range\nTraceback (most recent call last):\n  File \"/usr/local/lib/python2.7/site-packages/pre_commit/error_handler.py\", line 36, in error_handler\n    yield\n  File \"/usr/local/lib/python2.7/site-packages/pre_commit/main.py\", line 150, in main\n    return run(runner, args)\n  File \"/usr/local/lib/python2.7/site-packages/pre_commit/commands/run.py\", line 212, in run\n    return _run_hooks(repo_hooks, args, write, environ)\n  File \"/usr/local/lib/python2.7/site-packages/pre_commit/commands/run.py\", line 136, in _run_hooks\n    retval |= _run_single_hook(hook, repo, args, write, skips)\n  File \"/usr/local/lib/python2.7/site-packages/pre_commit/commands/run.py\", line 89, in _run_single_hook\n    retcode, stdout, stderr = repo.run_hook(hook, filenames)\n  File \"/usr/local/lib/python2.7/site-packages/pre_commit/repository.py\", line 145, in run_hook\n    self.cmd_runner, hook, file_args,\n  File \"/usr/local/lib/python2.7/site-packages/pre_commit/languages/script.py\", line 23, in run_hook\n    encoding=None,\n  File \"/usr/local/lib/python2.7/site-packages/pre_commit/prefixed_command_runner.py\", line 40, in run\n    replaced_cmd = _replace_cmd(cmd, prefix=self.prefix_dir)\n  File \"/usr/local/lib/python2.7/site-packages/pre_commit/prefixed_command_runner.py\", line 11, in _replace_cmd\n    return [part.format(**kwargs) for part in cmd]\nIndexError: tuple index out of range\n\n```\n\n", "before_files": [{"content": "from __future__ import unicode_literals\n\nimport os\nimport os.path\nimport subprocess\n\nfrom pre_commit.util import cmd_output\n\n\ndef _replace_cmd(cmd, **kwargs):\n    return [part.format(**kwargs) for part in cmd]\n\n\nclass PrefixedCommandRunner(object):\n    \"\"\"A PrefixedCommandRunner allows you to run subprocess commands with\n    comand substitution.\n\n    For instance:\n        PrefixedCommandRunner('/tmp/foo').run(['{prefix}foo.sh', 'bar', 'baz'])\n\n    will run ['/tmp/foo/foo.sh', 'bar', 'baz']\n    \"\"\"\n\n    def __init__(\n            self,\n            prefix_dir,\n            popen=subprocess.Popen,\n            makedirs=os.makedirs\n    ):\n        self.prefix_dir = prefix_dir.rstrip(os.sep) + os.sep\n        self.__popen = popen\n        self.__makedirs = makedirs\n\n    def _create_path_if_not_exists(self):\n        if not os.path.exists(self.prefix_dir):\n            self.__makedirs(self.prefix_dir)\n\n    def run(self, cmd, **kwargs):\n        self._create_path_if_not_exists()\n        replaced_cmd = _replace_cmd(cmd, prefix=self.prefix_dir)\n        return cmd_output(*replaced_cmd, __popen=self.__popen, **kwargs)\n\n    def path(self, *parts):\n        path = os.path.join(self.prefix_dir, *parts)\n        return os.path.normpath(path)\n\n    def exists(self, *parts):\n        return os.path.exists(self.path(*parts))\n\n    @classmethod\n    def from_command_runner(cls, command_runner, path_end):\n        \"\"\"Constructs a new command runner from an existing one by appending\n        `path_end` to the command runner's prefix directory.\n        \"\"\"\n        return cls(\n            command_runner.path(path_end),\n            popen=command_runner.__popen,\n            makedirs=command_runner.__makedirs,\n        )\n", "path": "pre_commit/prefixed_command_runner.py"}]}