
from quilt.utils import Process

class Patch(object):

    def __init__(self, cwd, patch_file, backup=False, prefix=None):
        cmd = ["patch"]
        if backup:
            cmd.append("--backup")
        if prefix:
            cmd.append("--prefix")
            cmd.append(prefix)
        cmd.append("-i")
        cmd.append(patch_file)

        Process(cmd).run(cwd=cwd)


import os

from quilt.utils import Process

class Patch(object):

    def __init__(self, cwd, patch_file, backup=False, prefix=None):
        cmd = ["patch"]
        if backup:
            cmd.append("--backup")
        if prefix:
            cmd.append("--prefix")
            if not prefix[-1] == os.sep:
                prefix += os.sep
            cmd.append(prefix)
        cmd.append("-i")
        cmd.append(patch_file)

        Process(cmd).run(cwd=cwd)

Patch parameter --prefix does need a path seperator
Patch parameter --prefix does need a path seperator

The --prefix parameter of the patch command needs a path seperator at
the end to store the backup in a directory.

+ 
+ import os
  
  from quilt.utils import Process
  
  class Patch(object):
  
      def __init__(self, cwd, patch_file, backup=False, prefix=None):
          cmd = ["patch"]
          if backup:
              cmd.append("--backup")
          if prefix:
              cmd.append("--prefix")
+             if not prefix[-1] == os.sep:
+                 prefix += os.sep
              cmd.append(prefix)
          cmd.append("-i")
          cmd.append(patch_file)
  
          Process(cmd).run(cwd=cwd)
  
Patch parameter --prefix does need a path seperator
## Code Before:

from quilt.utils import Process

class Patch(object):

    def __init__(self, cwd, patch_file, backup=False, prefix=None):
        cmd = ["patch"]
        if backup:
            cmd.append("--backup")
        if prefix:
            cmd.append("--prefix")
            cmd.append(prefix)
        cmd.append("-i")
        cmd.append(patch_file)

        Process(cmd).run(cwd=cwd)

## Instruction:
Patch parameter --prefix does need a path seperator
## Code After:

import os

from quilt.utils import Process

class Patch(object):

    def __init__(self, cwd, patch_file, backup=False, prefix=None):
        cmd = ["patch"]
        if backup:
            cmd.append("--backup")
        if prefix:
            cmd.append("--prefix")
            if not prefix[-1] == os.sep:
                prefix += os.sep
            cmd.append(prefix)
        cmd.append("-i")
        cmd.append(patch_file)

        Process(cmd).run(cwd=cwd)
