def mklink(self, source, target, force=None):
        linked = False

        if not os.path.exists(source):
            raise SymlinkError(
                "symlink source \"{0}\" does not exist".format(
                    collapseuser(source)
                )
            )

        try:
            os.symlink(source, target)
            linked = True
            tty.puts("symlinked {0} -> {1}".format(
                tty.color(collapseuser(target), tty.MAGENTA),
                collapseuser(source)
            ))
        except __HOLE__ as e:
            if e.errno != errno.EEXIST:
                raise

            if os.path.islink(target):
                if os.path.samefile(
                    os.path.realpath(target),
                    os.path.realpath(source)
                ):
                    linked = True
                    tty.putdebug("Already linked: {0} -> {1}".format(
                        tty.color(collapseuser(target), tty.MAGENTA),
                        collapseuser(source)
                    ), self.debug)
                else:
                    fmt = "Linked to wrong target: {0} -> {1} (instead of {2})"
                    tty.puterr(fmt.format(
                        tty.color(target, tty.MAGENTA),
                        os.path.realpath(collapseuser(target)),
                        os.path.realpath(collapseuser(source))
                    ), warning=force)
            else:
                tty.puterr("{0} symlink target already exists at: {1}".format(
                    collapseuser(source),
                    collapseuser(target)
                ), warning=force)

        if not linked and force:
            try:
                osx.move_to_trash(target)
                print(tty.progress("Moved {0} to trash").format(target))
            except OSError as e:
                tty.puterr("Error moving {0} to trash: {1}".format(
                    target, str(e))
                )
                return False
            return self.mklink(source, target, force)

        return linked
dataset/ETHPy150Open msanders/cider/cider/core.py/Cider.mklink