Cria novos components

This commit is contained in:
LeoMortari
2025-10-20 17:56:36 -03:00
parent 2b99d2ad78
commit b090f7c2cb
38 changed files with 1391 additions and 1024 deletions

38
video_render/utils.py Normal file
View File

@@ -0,0 +1,38 @@
from __future__ import annotations
import re
import unicodedata
from pathlib import Path
from typing import Iterable
def sanitize_filename(name: str) -> str:
normalized = unicodedata.normalize("NFKD", name)
ascii_text = normalized.encode("ASCII", "ignore").decode()
ascii_text = ascii_text.lower()
ascii_text = ascii_text.replace(" ", "_")
ascii_text = re.sub(r"[^a-z0-9_\-\.]", "", ascii_text)
ascii_text = re.sub(r"_+", "_", ascii_text)
return ascii_text.strip("_") or "video"
def ensure_workspace(root: Path, folder_name: str) -> Path:
workspace = root / folder_name
workspace.mkdir(parents=True, exist_ok=True)
return workspace
def remove_paths(paths: Iterable[Path]) -> None:
for path in paths:
if not path.exists():
continue
if path.is_file() or path.is_symlink():
path.unlink(missing_ok=True)
else:
for child in sorted(path.rglob("*"), reverse=True):
if child.is_file() or child.is_symlink():
child.unlink(missing_ok=True)
elif child.is_dir():
child.rmdir()
path.rmdir()