import os
import sys
import shutil


if sys.version_info.major == 2:
    FileNotFoundError = OSError


def ensure_path_exists(dir_path):
    """
    Make sure that a path exists
    """
    if not os.path.exists(dir_path):
        os.mkdir(dir_path)
        return True
    return False


def remove_file_if_exists(path):
    if os.path.isfile(path):
        os.remove(path)
        return True
    return False


def remove_dir_if_exists(path):
    if os.path.isdir(path):
        shutil.rmtree(path)
        return True
    return False


def is_executable_available(program):
    def is_exe(fpath):
        return os.path.isfile(fpath) and os.access(fpath, os.X_OK)

    fpath = os.path.dirname(program)
    if fpath:
        if is_exe(program):
            return True
    else:
        for path in os.environ["PATH"].split(os.pathsep):
            path = path.strip('"')
            exe_file = os.path.join(path, program)
            if is_exe(exe_file):
                return True

    return False


def is_same_path(p1, p2):
    n_p1 = os.path.abspath(os.path.expanduser(p1))
    n_p2 = os.path.abspath(os.path.expanduser(p2))

    try:
        return os.path.samefile(n_p1, n_p2)
    except FileNotFoundError:
        return n_p1 == n_p2

@@ -28,16 +28,29 @@
  shutil%0A
+import errno%0A
 %0A%0Aif sys
@@ -109,16 +109,223 @@
 Error%0A%0A%0A
+def mkdir(path):%0A    try:%0A        os.makedirs(path)%0A    except OSError as exc:  # Python %3E2.5%0A        if exc.errno == errno.EEXIST and os.path.isdir(path):%0A            pass%0A        else:%0A            raise%0A%0A%0A
 def ensu
@@ -436,24 +436,24 @@
 _path):%0A
+
         
 os.mkdir
@@ -444,19 +444,16 @@
         
-os.
 mkdir(di

fix ensure_path_exists utility function