Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Replace last `os.path` occurrencies by `pathlib` (#3224)

Adrien ANTON LUDWIG05594eca5e74
diff --git a/manim/scene/scene_file_writer.py b/manim/scene/scene_file_writer.py
index 189158867..d9e509de8 100644
--- a/manim/scene/scene_file_writer.py
+++ b/manim/scene/scene_file_writer.py
@@ -700,9 +700,8 @@ class SceneFileWriter:
)
oldest_files_to_delete = sorted(
cached_partial_movies,
- key=os.path.getatime,
+ key=lambda path: path.stat().st_atime,
)[:number_files_to_delete]
- # oldest_file_path = min(cached_partial_movies, key=os.path.getatime)
for file_to_delete in oldest_files_to_delete:
file_to_delete.unlink()
logger.info(
diff --git a/manim/utils/file_ops.py b/manim/utils/file_ops.py
index 1bbb04821..ae0656199 100644
--- a/manim/utils/file_ops.py
+++ b/manim/utils/file_ops.py
@@ -183,7 +183,7 @@ def modify_atime(file_path: str) -> None:
file_path
The path of the file.
"""
- os.utime(file_path, times=(time.time(), os.path.getmtime(file_path)))
+ os.utime(file_path, times=(time.time(), Path(file_path).stat().st_mtime))
def open_file(file_path, in_browser=False):