From 7f9a2cf4879b6ab2d9dd0fd1d447816e34dcbc6f Mon Sep 17 00:00:00 2001 From: Grant Sanderson Date: Wed, 11 Dec 2024 17:15:14 -0600 Subject: [PATCH] Rewrite guarantee_existence using Path --- manimlib/utils/file_ops.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/manimlib/utils/file_ops.py b/manimlib/utils/file_ops.py index 26faa449..20e2152f 100644 --- a/manimlib/utils/file_ops.py +++ b/manimlib/utils/file_ops.py @@ -25,10 +25,10 @@ def add_extension_if_not_present(file_name: str, extension: str) -> str: return file_name -def guarantee_existence(path: str) -> str: - if not os.path.exists(path): - os.makedirs(path) - return os.path.abspath(path) +def guarantee_existence(path: str | Path) -> Path: + path = Path(path) + path.mkdir(parents=True, exist_ok=True) + return path.absolute() def find_file(