24 lines
822 B
Python
24 lines
822 B
Python
"""Paths and process helpers shared by UE, Blender launchers and plain Python."""
|
|
import os
|
|
from pathlib import Path
|
|
import re
|
|
import shutil
|
|
|
|
PROJECT = Path(__file__).resolve().parents[3]
|
|
GENERATED = "/Game/Workshop/Generated"
|
|
|
|
|
|
def slug(value):
|
|
if not re.fullmatch(r"[A-Za-z][A-Za-z0-9_]*", value):
|
|
raise ValueError("Nazwa musi zaczynac sie litera i zawierac tylko litery ASCII, cyfry lub _.")
|
|
return value
|
|
|
|
|
|
def executable(name, explicit=None):
|
|
candidate = explicit or os.environ.get("WORKSHOP_" + name.upper()) or shutil.which(name)
|
|
if candidate and Path(candidate).is_file():
|
|
return str(Path(candidate).resolve())
|
|
raise FileNotFoundError(
|
|
f"Nie znaleziono {name}. Dodaj program do PATH lub ustaw WORKSHOP_{name.upper()} "
|
|
"na pelna sciezke do pliku wykonywalnego.")
|