2022-02-12 23:47:23 +08:00
|
|
|
from __future__ import annotations
|
|
|
|
|
2021-01-02 20:47:51 -08:00
|
|
|
import os
|
2024-12-05 11:53:18 -06:00
|
|
|
import tempfile
|
|
|
|
import appdirs
|
2021-01-02 20:47:51 -08:00
|
|
|
|
2024-12-05 11:53:18 -06:00
|
|
|
|
2024-12-11 09:50:17 -06:00
|
|
|
from manimlib.config import manim_config
|
2024-12-05 11:53:18 -06:00
|
|
|
from manimlib.config import get_manim_dir
|
2022-04-12 19:19:59 +08:00
|
|
|
from manimlib.utils.file_ops import guarantee_existence
|
2021-01-02 20:47:51 -08:00
|
|
|
|
|
|
|
|
2022-02-12 23:47:23 +08:00
|
|
|
def get_directories() -> dict[str, str]:
|
2024-12-11 09:50:17 -06:00
|
|
|
return manim_config.directories
|
2021-01-02 20:47:51 -08:00
|
|
|
|
|
|
|
|
2024-12-04 20:50:42 -06:00
|
|
|
def get_cache_dir() -> str:
|
2024-12-05 11:53:18 -06:00
|
|
|
return get_directories()["cache"] or appdirs.user_cache_dir("manim")
|
2024-12-04 20:50:42 -06:00
|
|
|
|
|
|
|
|
2022-02-12 23:47:23 +08:00
|
|
|
def get_temp_dir() -> str:
|
2024-12-05 11:53:18 -06:00
|
|
|
return get_directories()["temporary_storage"] or tempfile.gettempdir()
|
2021-01-06 10:39:34 -08:00
|
|
|
|
|
|
|
|
2022-02-12 23:47:23 +08:00
|
|
|
def get_downloads_dir() -> str:
|
2024-12-05 15:27:57 -06:00
|
|
|
return get_directories()["downloads"] or appdirs.user_cache_dir("manim_downloads")
|
2021-02-03 00:04:30 +05:30
|
|
|
|
2021-01-02 20:47:51 -08:00
|
|
|
|
2022-02-12 23:47:23 +08:00
|
|
|
def get_output_dir() -> str:
|
2021-01-02 20:47:51 -08:00
|
|
|
return guarantee_existence(get_directories()["output"])
|
|
|
|
|
|
|
|
|
2022-02-12 23:47:23 +08:00
|
|
|
def get_raster_image_dir() -> str:
|
2021-01-02 20:47:51 -08:00
|
|
|
return get_directories()["raster_images"]
|
|
|
|
|
|
|
|
|
2022-02-12 23:47:23 +08:00
|
|
|
def get_vector_image_dir() -> str:
|
2021-01-02 20:47:51 -08:00
|
|
|
return get_directories()["vector_images"]
|
|
|
|
|
|
|
|
|
2022-02-12 23:47:23 +08:00
|
|
|
def get_sound_dir() -> str:
|
2021-01-23 11:02:02 -08:00
|
|
|
return get_directories()["sounds"]
|
|
|
|
|
|
|
|
|
2022-02-12 23:47:23 +08:00
|
|
|
def get_shader_dir() -> str:
|
2024-12-05 11:53:18 -06:00
|
|
|
return os.path.join(get_manim_dir(), "manimlib", "shaders")
|