Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Allow selection of all scenes to render using '*' (#4470)

NightyStudios9528337ad4d4
diff --git a/manim/constants.py b/manim/constants.py
index 0a3e00da8..45e324c0c 100644
--- a/manim/constants.py
+++ b/manim/constants.py
@@ -84,7 +84,7 @@ SCENE_NOT_FOUND_MESSAGE = """
"""
CHOOSE_NUMBER_MESSAGE = """
Choose number corresponding to desired scene/arguments.
-(Use comma separated list for multiple entries)
+(Use comma separated list for multiple entries or use "*" to select all scenes.)
Choice(s): """
INVALID_NUMBER_MESSAGE = "Invalid scene numbers have been specified. Aborting."
NO_SCENE_MESSAGE = """
diff --git a/manim/utils/module_ops.py b/manim/utils/module_ops.py
index e4d921d8b..e4c937440 100644
--- a/manim/utils/module_ops.py
+++ b/manim/utils/module_ops.py
@@ -121,12 +121,18 @@ def prompt_user_for_choice(scene_classes: list[type[Scene]]) -> list[type[Scene]
user_input = console.input(
f"[log.message] {CHOOSE_NUMBER_MESSAGE} [/log.message]",
)
- scene_classes = [
- num_to_class[int(num_str)]
- for num_str in re.split(r"\s*,\s*", user_input.strip())
+
+ if user_input == "*":
+ selected_scenes_classes = scene_classes
+ else:
+ selected_scenes_classes = [
+ num_to_class[int(num_str)]
+ for num_str in re.split(r"\s*,\s*", user_input.strip())
+ ]
+ config["scene_names"] = [
+ scene_class.__name__ for scene_class in selected_scenes_classes
]
- config["scene_names"] = [scene_class.__name__ for scene_class in scene_classes]
- return scene_classes
+ return selected_scenes_classes
except KeyError:
logger.error(INVALID_NUMBER_MESSAGE)
sys.exit(2)