Fix video output directory bug

This commit is contained in:
icreiuheciijc 2018-10-24 18:42:32 +08:00
parent 31478c523c
commit 8077697fc7

View file

@ -1,6 +1,7 @@
import inspect import inspect
import os import os
from constants import THIS_DIR
from constants import ANIMATIONS_DIR from constants import ANIMATIONS_DIR
@ -21,11 +22,7 @@ def guarantee_existance(path):
def get_scene_output_directory(scene_class): def get_scene_output_directory(scene_class):
file_path = os.path.abspath(inspect.getfile(scene_class)) file_path = os.path.abspath(inspect.getfile(scene_class))
# TODO, is there a better way to do this? file_path = os.path.relpath(file_path, THIS_DIR)
parts = file_path.split(os.path.sep)
if "manim" in parts:
sub_parts = parts[parts.index("manim") + 1:]
file_path = os.path.join(*sub_parts)
file_path = file_path.replace(".pyc", "") file_path = file_path.replace(".pyc", "")
file_path = file_path.replace(".py", "") file_path = file_path.replace(".py", "")
return guarantee_existance(os.path.join(ANIMATIONS_DIR, file_path)) return guarantee_existance(os.path.join(ANIMATIONS_DIR, file_path))