Skip to content

armgit / manim

Public Imported from GitHub
0

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__.py
index 35a5b4b9f..9f01cee44 100644
--- a/manim/logger/__main__.py
+++ b/manim/logger/__main__.py
@@ -1,11 +1,29 @@
from rich.console import Console
from rich.progress import track
+from rich.color import Color
import 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 False
if __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]=temp
config['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