A community-maintained Python framework for creating mathematical animations.
Some updates on error handling ⚠️
Syrus Dark8502b01d99cf
diff --git a/manim/logger/__main__.py b/manim/logger/__main__.pyindex 35a5b4b9f..9f01cee44 100644--- a/manim/logger/__main__.py+++ b/manim/logger/__main__.py@@ -1,11 +1,29 @@from rich.console import Consolefrom rich.progress import track+from rich.color import Colorimport configparser+def check_valid_colour(color):+ '''Checks whether the entered color is a valid color according to rich+ Parameters+ ----------+ color : :class:`str`+ The color to check whether it is valid.+ Returns+ -------+ Boolean+ Returns whether it is valid color or not.+ '''+ try:+ Color.parse(color) is None+ return True+ except:+ return Falseif __name__=="__main__":console = Console()config = configparser.ConfigParser()+ config.read('manim.cfg')default={"logging.keyword":"bold yellow","logging.level.notset":"dim","logging.level.debug":"green",@@ -25,9 +43,14 @@ if __name__=="__main__":console.print('Enter the Style for %s'%key+':',style=key,end='')temp=input()if temp:- default[key]=temp+ while check_valid_colour(temp)==False:+ console.print("[red bold]Your Style is not valid. Try again.[/red bold]")+ console.print('Enter the Style for %s'%key+':',style=key,end='')+ temp=input()+ else:+ default[key]=tempconfig['log.color']=default- for n in track(range(100), description="Converting to JSON"):+ for n in track(range(100), description="Converting to Manim.cfg"):with open("manim.cfg","w") as fp:config.write(fp)console.print("A file called [yellow]manim.cfg[/yellow] is created. To save your theme please save that file and each time \nplace it in you current working directory(The directory where you execute manim command) for the your theme to be displayed.")\ No newline at end of file