Fixed -o flag functionality for extract_scene.py

This commit is contained in:
Grant Sanderson 2017-05-09 14:54:50 -07:00
parent b1e6c9c916
commit f3eb43f96f
2 changed files with 6 additions and 5 deletions

View file

@ -96,7 +96,6 @@ def get_configuration(sys_argv):
return config return config
def handle_scene(scene, **config): def handle_scene(scene, **config):
output_name = config["output_name"] or str(scene)
if config["quiet"]: if config["quiet"]:
curr_stdout = sys.stdout curr_stdout = sys.stdout
sys.stdout = open(os.devnull, "w") sys.stdout = open(os.devnull, "w")
@ -106,7 +105,7 @@ def handle_scene(scene, **config):
if config["save_image"]: if config["save_image"]:
if not config["write_all"]: if not config["write_all"]:
scene.show_frame() scene.show_frame()
scene.save_image(output_name) scene.save_image()
if config["quiet"]: if config["quiet"]:
sys.stdout.close() sys.stdout.close()
@ -182,6 +181,7 @@ def main():
"output_directory", "output_directory",
] ]
]) ])
scene_kwargs["name"] = config["output_name"]
for SceneClass in get_scene_classes(scene_names_to_classes, config): for SceneClass in get_scene_classes(scene_names_to_classes, config):
try: try:
handle_scene(SceneClass(**scene_kwargs), **config) handle_scene(SceneClass(**scene_kwargs), **config)

View file

@ -29,6 +29,7 @@ class Scene(object):
"write_to_movie" : True, "write_to_movie" : True,
"save_frames" : False, "save_frames" : False,
"output_directory" : MOVIE_DIR, "output_directory" : MOVIE_DIR,
"name" : None,
} }
def __init__(self, **kwargs): def __init__(self, **kwargs):
digest_config(self, kwargs) digest_config(self, kwargs)
@ -37,6 +38,8 @@ class Scene(object):
self.foreground_mobjects = [] self.foreground_mobjects = []
self.num_plays = 0 self.num_plays = 0
self.saved_frames = [] self.saved_frames = []
if self.name is None:
self.name = self.__class__.__name__
self.setup() self.setup()
if self.write_to_movie: if self.write_to_movie:
@ -57,9 +60,7 @@ class Scene(object):
pass #To be implemented in subclasses pass #To be implemented in subclasses
def __str__(self): def __str__(self):
if hasattr(self, "name"): return self.name
return self.name
return self.__class__.__name__
def set_name(self, name): def set_name(self, name):
self.name = name self.name = name