A community-maintained Python framework for creating mathematical animations.
feat: migrate to Pathlib (#630)
Manvendra Singh768d05b0a78a
diff --git a/manim/utils/images.py b/manim/utils/images.pyindex 0f63c4776..3a36b442a 100644--- a/manim/utils/images.py+++ b/manim/utils/images.py@@ -4,7 +4,6 @@ __all__ = ["get_full_raster_image_path", "drag_pixels", "invert_image"]import numpy as np-import osfrom .. import configfrom PIL import Imagediff --git a/manim/utils/module_ops.py b/manim/utils/module_ops.pyindex 1ef96befb..0dd85f3ba 100644--- a/manim/utils/module_ops.py+++ b/manim/utils/module_ops.py@@ -2,6 +2,7 @@ from .. import constants, logger, console, configimport importlib.utilimport inspectimport os+from pathlib import Pathimport sysimport typesimport re@@ -27,7 +28,7 @@ def get_module(file_name):logger.error(f"Failed to render scene: {str(e)}")sys.exit(2)else:- if os.path.exists(file_name):+ if Path(file_name).exists():ext = file_name.suffixif ext != ".py":raise ValueError(f"{file_name} is not a valid Manim python script.")diff --git a/manim/utils/sounds.py b/manim/utils/sounds.pyindex 84d587b57..f63c32a26 100644--- a/manim/utils/sounds.py+++ b/manim/utils/sounds.py@@ -5,7 +5,7 @@ __all__ = []-import os+from pathlib import Pathfrom ..utils.file_ops import seek_full_path_from_defaults@@ -13,6 +13,6 @@ from ..utils.file_ops import seek_full_path_from_defaultsdef get_full_sound_file_path(sound_file_name):return seek_full_path_from_defaults(sound_file_name,- default_dir=os.path.join("assets", "sounds"),+ default_dir=Path("assets") / "sounds",extensions=[".wav", ".mp3"],)