import shutil
import os


def make_dirs(path):
    if os.path.exists(path):
        return
    try:
        os.makedirs(path)
    except OSError as e:
        raise OSError


def resolve_path_from_symbolic_links(symbolic_link, relative_path):
    if not os.path.islink(symbolic_link) or os.path.isabs(relative_path):
        return
    return os.path.abspath(os.path.join(symbolic_link, relative_path))


def move(src, dest):
    try:
        shutil.move(src, dest)
    except IOError:
        raise


def remove_directory(path, safe=False):
    if safe:
        try:
            os.removedirs(path)
        except OSError:
            raise
    else:
        shutil.rmtree(path)
import shutil
import os
import subprocess


def make_dirs(path):
    if os.path.exists(path):
        return
    try:
        os.makedirs(path)
    except OSError as e:
        raise OSError


def resolve_path_from_symbolic_links(symbolic_link, relative_path):
    if not os.path.islink(symbolic_link) or os.path.isabs(relative_path):
        return
    return os.path.abspath(os.path.join(symbolic_link, relative_path))


def move(src, dest):
    try:
        shutil.move(src, dest)
    except IOError:
        raise


def remove_directory(path, safe=False):
    if safe:
        try:
            os.removedirs(path)
        except OSError:
            raise
    else:
        shutil.rmtree(path)


def source(script_name):
    print subprocess.PIPE
    pipe = subprocess.Popen(". %s; env" % script_name, stdout=subprocess.PIPE, shell=True)
    output = pipe.communicate()[0]
    output = filter(lambda l: len(l.split("=")) == 2, output.splitlines())
    env = dict((line.split("=", 1) for line in output))
    os.environ.update(env)
implement source bash builtin wrapper