mirror of
https://github.com/3b1b/manim.git
synced 2025-09-01 00:48:45 +00:00
Move mirror output path logic to config.py
This commit is contained in:
parent
181038e2f3
commit
c4d452248a
2 changed files with 15 additions and 14 deletions
|
@ -337,6 +337,16 @@ def get_configuration(args):
|
|||
else:
|
||||
file_ext = ".mp4"
|
||||
|
||||
dir_config = custom_config["directories"]
|
||||
output_directory = args.video_dir or dir_config["output"]
|
||||
if dir_config["mirror_module_path"]:
|
||||
to_cut = dir_config["removed_mirror_prefix"]
|
||||
input_file = os.path.abspath(args.file)
|
||||
output_directory = os.path.join(
|
||||
output_directory,
|
||||
input_file.replace(to_cut, "").replace(".py", "")
|
||||
)
|
||||
|
||||
file_writer_config = {
|
||||
"write_to_movie": not args.skip_animations and write_file,
|
||||
"break_into_partial_movies": custom_config["break_into_partial_movies"],
|
||||
|
@ -345,8 +355,7 @@ def get_configuration(args):
|
|||
# If -t is passed in (for transparent), this will be RGBA
|
||||
"png_mode": "RGBA" if args.transparent else "RGB",
|
||||
"movie_file_extension": file_ext,
|
||||
"mirror_module_path": custom_config["directories"]["mirror_module_path"],
|
||||
"output_directory": args.video_dir or custom_config["directories"]["output"],
|
||||
"output_directory": output_directory,
|
||||
"file_name": args.file_name,
|
||||
"input_file_path": args.file or "",
|
||||
"open_file_upon_completion": args.open,
|
||||
|
|
|
@ -37,9 +37,6 @@ class SceneFileWriter(object):
|
|||
"png_mode": "RGBA",
|
||||
"save_last_frame": False,
|
||||
"movie_file_extension": ".mp4",
|
||||
# Should the path of output files mirror the directory
|
||||
# structure of the module holding the scene?
|
||||
"mirror_module_path": False,
|
||||
# What python file is generating this scene
|
||||
"input_file_path": "",
|
||||
# Where should this be written
|
||||
|
@ -63,10 +60,6 @@ class SceneFileWriter(object):
|
|||
# Output directories and files
|
||||
def init_output_directories(self) -> None:
|
||||
out_dir = self.output_directory or ""
|
||||
if self.mirror_module_path:
|
||||
module_dir = self.get_default_module_directory()
|
||||
out_dir = os.path.join(out_dir, module_dir)
|
||||
|
||||
scene_name = self.file_name or self.get_default_scene_name()
|
||||
if self.save_last_frame:
|
||||
image_dir = guarantee_existence(os.path.join(out_dir, "images"))
|
||||
|
@ -81,7 +74,9 @@ class SceneFileWriter(object):
|
|||
movie_dir, "partial_movie_files", scene_name,
|
||||
))
|
||||
# A place to save mobjects
|
||||
self.saved_mobject_directory = os.path.join(out_dir, "mobjects")
|
||||
self.saved_mobject_directory = os.path.join(
|
||||
out_dir, "mobjects", str(self.scene)
|
||||
)
|
||||
|
||||
def get_default_module_directory(self) -> str:
|
||||
path, _ = os.path.splitext(self.input_file_path)
|
||||
|
@ -124,10 +119,7 @@ class SceneFileWriter(object):
|
|||
return self.movie_file_path
|
||||
|
||||
def get_saved_mobject_directory(self) -> str:
|
||||
return guarantee_existence(os.path.join(
|
||||
self.saved_mobject_directory,
|
||||
str(self.scene),
|
||||
))
|
||||
return guarantee_existence(self.saved_mobject_directory)
|
||||
|
||||
def get_saved_mobject_path(self, mobject: Mobject) -> str | None:
|
||||
directory = self.get_saved_mobject_directory()
|
||||
|
|
Loading…
Add table
Reference in a new issue