Skip to content

armgit / manim

Public Imported from GitHub
0

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.py
index 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 os
from .. import config
from PIL import Image
diff --git a/manim/utils/module_ops.py b/manim/utils/module_ops.py
index 1ef96befb..0dd85f3ba 100644
--- a/manim/utils/module_ops.py
+++ b/manim/utils/module_ops.py
@@ -2,6 +2,7 @@ from .. import constants, logger, console, config
import importlib.util
import inspect
import os
+from pathlib import Path
import sys
import types
import 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.suffix
if 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.py
index 84d587b57..f63c32a26 100644
--- a/manim/utils/sounds.py
+++ b/manim/utils/sounds.py
@@ -5,7 +5,7 @@ __all__ = [
]
-import os
+from pathlib import Path
from ..utils.file_ops import seek_full_path_from_defaults
@@ -13,6 +13,6 @@ from ..utils.file_ops import seek_full_path_from_defaults
def 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"],
)