A community-maintained Python framework for creating mathematical animations.
Some general Fixes
Syrus Darkb3b428f1ca49
diff --git a/example_scenes/manim.cfg b/example_scenes/manim.cfgindex 88abfee43..a11d17e5b 100644--- a/example_scenes/manim.cfg+++ b/example_scenes/manim.cfg@@ -1,70 +1,3 @@-[CLI]-write_to_movie = True-save_last_frame = False-write_all = False-save_pngs = False-save_as_gif = False-preview = False-show_file_in_finder = False-quiet = False-sound = False-output_file =-leave_progress_bars = False-background_color = BLACK-background_opacity = 1-from_animation_number = 0-upto_animation_number = -1-media_dir = ./media-png_mode = RGB-movie_file_extension = .mp4-frame_rate = 60-pixel_height = 1440-pixel_width = 2560--[transparent]-png_mode = RGBA-movie_file_extension = .mov-background_opacity = 0--[fourk_quality]-pixel_height = 2160-pixel_width = 3840-frame_rate = 60--[high_quality]-pixel_height = 1080-pixel_width = 1920-frame_rate = 60--[medium_quality]-pixel_height = 720-pixel_width = 1280-frame_rate = 30--[low_quality]-pixel_height = 480-pixel_width = 854-frame_rate = 15--[dry_run]-write_to_movie = False-write_all = False-save_last_frame = False-save_pngs = False-save_as_gif = False--[streaming]-live_stream_name = LiveStream-twitch_stream_key = YOUR_STREAM_KEY-streaming_protocol = tcp-streaming_ip = 127.0.0.1-streaming_port = 2000-streaming_client = ffplay-streaming_url = %(STREAMING_PROTOCOL)s://%(STREAMING_IP)s:%(STREAMING_PORT)s?listen-streaming_console_banner = Manim is now running in streaming mode.- Stream animations by passing them to manim.play(), e.g.- >>> c = Circle()- >>> manim.play(ShowCreation(c))#This is some custom configuration just as an example[logger]diff --git a/manim/__main__.py b/manim/__main__.pyindex 888cc90e1..61d4b987e 100644--- a/manim/__main__.py+++ b/manim/__main__.py@@ -72,7 +72,7 @@ def prompt_user_for_choice(scene_classes):for count, scene_class in enumerate(scene_classes):count += 1 # start with 1 instead of 0name = scene_class.__name__- console.print(f"{count}: {name}" ,style="logging.level.info")+ console.print(f"{count}: {name}", style="logging.level.info")num_to_class[count] = scene_classtry:user_input = console.input(f"[log.message] {constants.CHOOSE_NUMBER_MESSAGE} [/log.message]")diff --git a/manim/config.py b/manim/config.pyindex 31e4ed074..60149bb1b 100644--- a/manim/config.py+++ b/manim/config.py@@ -15,7 +15,7 @@ from .utils.config_utils import _run_config, _init_dirs, _from_command_linefrom .logger import loggerfrom .utils.tex import TexTemplate, TexTemplateFromFile-__all__ = ["config", "camera_config"]+__all__ = ["file_writer_config", "config", "camera_config"]def _parse_config(config_parser, args):@@ -68,9 +68,7 @@ def _parse_config(config_parser, args):config["right_side"] = config["frame_x_radius"] * constants.RIGHT# Handle the --tex_template flag. Note we accept None if the flag is absent- filename = (- os.path.expanduser(args.tex_template) if args.tex_template else None- )+ filename = os.path.expanduser(args.tex_template) if args.tex_template else Noneif filename is not None and not os.access(filename, os.R_OK):# custom template not available, fallback to defaultdiff --git a/manim/utils/cfgwriter.py b/manim/utils/cfgwriter.pyindex 92e63f89d..fc4e46d4f 100644--- a/manim/utils/cfgwriter.py+++ b/manim/utils/cfgwriter.py@@ -15,8 +15,10 @@ from rich.progress import trackfrom rich.style import Stylefrom rich.errors import StyleSyntaxError+INVALID_STYLE_MSG = "[red bold]Your Style is not valid. Try again.[/red bold]"-def check_valid_style(style):++def is_valid_style(style):"""Checks whether the entered color is a valid color according to richParameters----------@@ -34,10 +36,36 @@ def check_valid_style(style):return False+def replace_keys(default):+ """Replaces _ to . and viceversa in a dictionary for rich+ Parameters+ ----------+ default : :class:`dict`+ The dictionary to check and replace+ Returns+ -------+ :class:`dict`+ The dictionary which is modified by replcaing _ with . and viceversa+ """+ for key in default:+ if "_" in key:+ temp = default[key]+ del default[key]+ key = key.replace("_", ".")+ default[key] = temp+ else:+ temp = default[key]+ del default[key]+ key = key.replace(".", "_")+ default[key] = temp+ return default++def main():- successfully_read_files = _run_config()[-1]+ config_items = _run_config()+ successfully_read_files = config_items[-1]console = Console()- config = configparser.ConfigParser()+ config = config_items[1]config.read(successfully_read_files)default = config["logger"]console.print(@@ -48,29 +76,19 @@ def main():)console.print("[magenta] For a full list of styles, visit[/magenta] https://rich.readthedocs.io/en/latest/style.html"- )- for key in default:- temp = default[key]- del default[key]- key = key.replace("_", ".")- default[key] = temp+ )+ default = replace_keys(default)for key in default:console.print("Enter the Style for %s" % key + ":", style=key, end="")temp = input()if temp:- while not check_valid_style(temp):- console.print(- "[red bold]Your Style is not valid. Try again.[/red bold]"- )+ while not is_valid_style(temp):+ console.print(INVALID_STYLE_MSG)console.print("Enter the Style for %s" % key + ":", style=key, end="")temp = input()else:default[key] = temp- for key in default:- temp = default[key]- del default[key]- key = key.replace(".", "_")- default[key] = temp+ default = replace_keys(default)config["logger"] = defaultconsole.print("Do you want to save this as the default for this User?(y/n)[[n]]",@@ -92,8 +110,10 @@ you will have to create a manim.cfg in the local directory, where you want thoseelse:with open(config_paths[2], "w") as fp:config.write(fp)- console.print(f"""A configuration file called [yellow]{config_paths[2]}[/yellow] has been created.-To save your theme please save that file and place it in your current working directory, from where you run the manim command.""")+ console.print(+ f"""A configuration file called [yellow]{config_paths[2]}[/yellow] has been created.+To save your theme please save that file and place it in your current working directory, from where you run the manim command."""+ )if __name__ == "__main__":diff --git a/manim/utils/config_utils.py b/manim/utils/config_utils.pyindex be0f9a6df..f1a4762ff 100644--- a/manim/utils/config_utils.py+++ b/manim/utils/config_utils.py@@ -350,27 +350,23 @@ def _paths_config_file():os.path.join(os.path.dirname(__file__), "..", "default.cfg"))if sys.platform.startswith("linux"):- # This is for linux usersuser_wide = os.path.expanduser(- os.path.join("~", ".config", "Manim", "manim.cfg")+ os.path.join("~", ".config", "manim", "manim.cfg"))elif sys.platform.startswith("darwin"):- # This is for MacOS usersuser_wide = os.path.expanduser(os.path.join("~", "Library", "Application Support", "Manim", "manim.cfg"))elif sys.platform.startswith("win32"):- # This is for Windows usersuser_wide = os.path.expanduser(os.path.join("~", "AppData", "Roaming", "Manim", "manim.cfg"))else:- # This is for users whose OS is unknownuser_wide = os.path.expanduser(- os.path.join("~", ".config", "Manim", "manim.cfg")+ os.path.join("~", ".config", "manim", "manim.cfg"))- current_working_directory = os.path.abspath("manim.cfg")- return [library_wide, user_wide, current_working_directory]+ folder_wide = os.path.abspath("manim.cfg")+ return [library_wide, user_wide, folder_wide]def _run_config():