A community-maintained Python framework for creating mathematical animations.
Updated stage_scenes to write to a directory unique to the animation file
Grant Sanderson4d7bb5c3f163
diff --git a/stage_scenes.py b/stage_scenes.pyindex e79d341cf..7177d6141 100644--- a/stage_scenes.py+++ b/stage_scenes.py@@ -18,9 +18,7 @@ def get_sorted_scene_names(module_name):for line_no in sorted(line_to_scene.keys())]---def stage_animaions(module_name):+def stage_animations(module_name):scene_names = get_sorted_scene_names(module_name)animation_dir = os.path.join(ANIMATIONS_DIR, module_name.replace(".py", "")@@ -32,19 +30,27 @@ def stage_animaions(module_name):sorted_files.append(os.path.join(animation_dir, clip))- for f in os.listdir(STAGED_SCENES_DIR):- os.remove(os.path.join(STAGED_SCENES_DIR, f))- for f, count in zip(sorted_files, it.count()):+ staged_scenes_dir = os.path.join(animation_dir, "staged_scenes")+ count = 0+ while True:+ staged_scenes_dir = os.path.join(+ animation_dir, "staged_scenes_%d"%count+ )+ if not os.path.exists(staged_scenes_dir):+ os.makedirs(staged_scenes_dir)+ break+ #Otherwise, keep trying new names until+ #there is a free one+ count += 1+ for count, f in enumerate(sorted_files):symlink_name = os.path.join(- STAGED_SCENES_DIR,+ staged_scenes_dir,"Scene_%03d"%count + f.split(os.sep)[-1])os.symlink(f, symlink_name)--if __name__ == "__main__":if len(sys.argv) < 2:raise Exception("No module given.")module_name = sys.argv[1]- stage_animaions(module_name)\ No newline at end of file+ stage_animations(module_name)\ No newline at end of file