Jennifer Nguyen

Bootwitch

Scientist building AI and research tools
10+ years in immunology research · Building with AI since 2024
Bootwitch / Interactive demo
Simulated session
Files
Terminal
Welcome to Bootwitch.
Projects / bootwitch-cli-code-excerpts-publication

Giving a project its final name

bootwitch-clidevtools-and-workflows

After the templates are prepared, this helper publishes the project directory. It uses the platform’s exclusive rename operation, so a destination that appeared during setup is handled at the final step too.

source · Project overview

def publish(source, target):
    source, target = os.path.abspath(source), os.path.abspath(target)
    if not stat.S_ISDIR(os.lstat(source).st_mode):
        raise ValueError("staging must be a real directory, not a symlink")
    if os.path.realpath(os.path.dirname(source)) != os.path.realpath(os.path.dirname(target)):
        raise ValueError("staging and destination must share a parent directory")
    rename = native_rename()
    if rename(os.fsencode(source), os.fsencode(target)) != 0:
        code = ctypes.get_errno()
        if code in (errno.ENOSYS, errno.EINVAL, errno.ENOTSUP):
            raise OSError(code, "exclusive rename unsupported; refusing unsafe fallback", target)
        raise OSError(code, os.strerror(code), target)

Read the full source · Snapshot 7bce28e8b273.


Project overview · All projects