mirror of
https://github.com/3b1b/manim.git
synced 2025-09-19 04:41:56 +00:00
Fixed stage_scenes, which required updating get_scene_output_directory and get_module
This commit is contained in:
parent
a1c9e8dbb2
commit
641a429e66
3 changed files with 16 additions and 6 deletions
|
@ -88,7 +88,7 @@ def get_module(file_name):
|
|||
print(f"Failed to render scene: {str(e)}")
|
||||
sys.exit(2)
|
||||
else:
|
||||
module_name = file_name.split(os.sep)[-1].replace(".py", "")
|
||||
module_name = file_name.replace(os.sep, ".").replace(".py", "")
|
||||
spec = importlib.util.spec_from_file_location(module_name, file_name)
|
||||
module = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(module)
|
||||
|
|
|
@ -20,7 +20,10 @@ def guarantee_existance(path):
|
|||
|
||||
|
||||
def get_scene_output_directory(scene_class):
|
||||
return guarantee_existance(os.path.join(VIDEO_DIR, scene_class.__module__))
|
||||
return guarantee_existance(os.path.join(
|
||||
VIDEO_DIR,
|
||||
scene_class.__module__.replace(".", os.path.sep)
|
||||
))
|
||||
|
||||
|
||||
def get_movie_output_directory(scene_class, camera_config, frame_duration):
|
||||
|
|
|
@ -1,19 +1,26 @@
|
|||
#!/usr/bin/env python
|
||||
import inspect
|
||||
import os
|
||||
import sys
|
||||
import importlib
|
||||
|
||||
from manimlib.constants import PRODUCTION_QUALITY_CAMERA_CONFIG
|
||||
from manimlib.constants import PRODUCTION_QUALITY_FRAME_DURATION
|
||||
from manimlib.extract_scene import get_module
|
||||
from manimlib.extract_scene import is_scene
|
||||
from manimlib.config import get_module
|
||||
from manimlib.extract_scene import is_child_scene
|
||||
from manimlib.utils.output_directory_getters import get_movie_output_directory
|
||||
|
||||
|
||||
def get_sorted_scene_classes(module_name):
|
||||
module = get_module(module_name)
|
||||
importlib.import_module(module.__name__)
|
||||
line_to_scene = {}
|
||||
for name, scene_class in inspect.getmembers(module, is_scene):
|
||||
if inspect.getmodule(scene_class) != module:
|
||||
name_scene_list = inspect.getmembers(
|
||||
module,
|
||||
lambda obj: is_child_scene(obj, module)
|
||||
)
|
||||
for name, scene_class in name_scene_list:
|
||||
if inspect.getmodule(scene_class).__name__ != module.__name__:
|
||||
continue
|
||||
lines, line_no = inspect.getsourcelines(scene_class)
|
||||
line_to_scene[line_no] = scene_class
|
Loading…
Add table
Reference in a new issue