File size: 673 Bytes
859f17b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
"""Utility helpers for the Hugging Face Space deployment.

Call these functions from ``app.py`` if you want extra setup beyond the basic
snapshot download (for example copying files into specific folders).  This file
is optional; include or edit it as needed for your workflow.
"""

from __future__ import annotations

import shutil
from pathlib import Path


def copy_if_missing(src: Path, dst: Path) -> None:
    """Copy ``src`` into ``dst`` if the destination path does not yet exist."""
    if dst.exists():
        return
    dst.parent.mkdir(parents=True, exist_ok=True)
    if src.is_dir():
        shutil.copytree(src, dst)
    else:
        shutil.copy2(src, dst)