19
19
import os
20
20
import re
21
21
import sys
22
- import typing
23
22
from collections .abc import Mapping , MutableMapping
24
23
from pathlib import Path
24
+ from typing import Any , Iterable , Iterator
25
25
26
26
import colour
27
27
import numpy as np
28
28
29
29
from .. import constants
30
30
from ..utils .tex import TexTemplate , TexTemplateFromFile
31
31
from ..utils .tex_templates import TexTemplateLibrary
32
- from .logger_utils import set_file_logger
33
32
34
33
35
34
def config_file_paths () -> list [Path ]:
@@ -255,7 +254,6 @@ class MyScene(Scene):
255
254
"input_file" ,
256
255
"media_embed" ,
257
256
"media_width" ,
258
- "webgl_renderer_path" ,
259
257
"log_dir" ,
260
258
"log_to_file" ,
261
259
"max_files_cached" ,
@@ -282,7 +280,6 @@ class MyScene(Scene):
282
280
"upto_animation_number" ,
283
281
"renderer" ,
284
282
"use_opengl_renderer" ,
285
- "use_webgl_renderer" ,
286
283
"enable_gui" ,
287
284
"gui_location" ,
288
285
"use_projection_fill_shaders" ,
@@ -304,7 +301,7 @@ def __init__(self) -> None:
304
301
self ._d = {k : None for k in self ._OPTS }
305
302
306
303
# behave like a dict
307
- def __iter__ (self ) -> typing . Iterator [str ]:
304
+ def __iter__ (self ) -> Iterator [str ]:
308
305
return iter (self ._d )
309
306
310
307
def __len__ (self ) -> int :
@@ -317,10 +314,10 @@ def __contains__(self, key) -> bool:
317
314
except AttributeError :
318
315
return False
319
316
320
- def __getitem__ (self , key ) -> typing . Any :
317
+ def __getitem__ (self , key ) -> Any :
321
318
return getattr (self , key )
322
319
323
- def __setitem__ (self , key : str , val : typing . Any ) -> None :
320
+ def __setitem__ (self , key : str , val : Any ) -> None :
324
321
getattr (ManimConfig , key ).fset (self , val ) # fset is the property's setter
325
322
326
323
def update (self , obj : ManimConfig | dict ) -> None :
@@ -395,7 +392,7 @@ def __copy__(self) -> ManimConfig:
395
392
"""See ManimConfig.copy()."""
396
393
return copy .deepcopy (self )
397
394
398
- def __deepcopy__ (self , memo : dict [str , typing . Any ]) -> ManimConfig :
395
+ def __deepcopy__ (self , memo : dict [str , Any ]) -> ManimConfig :
399
396
"""See ManimConfig.copy()."""
400
397
c = ManimConfig ()
401
398
# Deepcopying the underlying dict is enough because all properties
@@ -405,14 +402,14 @@ def __deepcopy__(self, memo: dict[str, typing.Any]) -> ManimConfig:
405
402
return c
406
403
407
404
# helper type-checking methods
408
- def _set_from_list (self , key : str , val : typing . Any , values : list ) -> None :
405
+ def _set_from_list (self , key : str , val : Any , values : list ) -> None :
409
406
"""Set ``key`` to ``val`` if ``val`` is contained in ``values``."""
410
407
if val in values :
411
408
self ._d [key ] = val
412
409
else :
413
410
raise ValueError (f"attempted to set { key } to { val } ; must be in { values } " )
414
411
415
- def _set_boolean (self , key : str | int , val : typing . Any ) -> None :
412
+ def _set_boolean (self , key : str | int , val : Any ) -> None :
416
413
"""Set ``key`` to ``val`` if ``val`` is Boolean."""
417
414
if val in [True , False ]:
418
415
self ._d [key ] = val
@@ -425,7 +422,7 @@ def _set_tuple(self, key: str, val: tuple) -> None:
425
422
else :
426
423
raise ValueError (f"{ key } must be tuple" )
427
424
428
- def _set_str (self , key : str , val : typing . Any ) -> None :
425
+ def _set_str (self , key : str , val : Any ) -> None :
429
426
"""Set ``key`` to ``val`` if ``val`` is a string."""
430
427
if isinstance (val , str ):
431
428
self ._d [key ] = val
@@ -537,7 +534,6 @@ def digest_parser(self, parser: configparser.ConfigParser) -> ManimConfig:
537
534
"flush_cache" ,
538
535
"custom_folders" ,
539
536
"use_opengl_renderer" ,
540
- "use_webgl_renderer" ,
541
537
"enable_gui" ,
542
538
"fullscreen" ,
543
539
"use_projection_fill_shaders" ,
@@ -577,7 +573,6 @@ def digest_parser(self, parser: configparser.ConfigParser) -> ManimConfig:
577
573
"movie_file_extension" ,
578
574
"background_color" ,
579
575
"renderer" ,
580
- "webgl_renderer_path" ,
581
576
"window_position" ,
582
577
]:
583
578
setattr (self , key , parser ["CLI" ].get (key , fallback = "" , raw = True ))
@@ -710,7 +705,6 @@ def digest_args(self, args: argparse.Namespace) -> ManimConfig:
710
705
"renderer" ,
711
706
"background_color" ,
712
707
"use_opengl_renderer" ,
713
- "use_webgl_renderer" ,
714
708
"enable_gui" ,
715
709
"fullscreen" ,
716
710
"use_projection_fill_shaders" ,
@@ -835,8 +829,7 @@ def digest_file(self, filename: str) -> ManimConfig:
835
829
filename ,
836
830
)
837
831
838
- if filename :
839
- return self .digest_parser (make_config_parser (filename ))
832
+ return self .digest_parser (make_config_parser (filename ))
840
833
841
834
# config options are properties
842
835
preview = property (
@@ -861,19 +854,11 @@ def digest_file(self, filename: str) -> ManimConfig:
861
854
doc = "Whether to show progress bars while rendering animations." ,
862
855
)
863
856
864
- @property
865
- def log_to_file (self ):
866
- """Whether to save logs to a file."""
867
- return self ._d ["log_to_file" ]
868
-
869
- @log_to_file .setter
870
- def log_to_file (self , val : str ) -> None :
871
- self ._set_boolean ("log_to_file" , val )
872
- if val :
873
- log_dir = self .get_dir ("log_dir" )
874
- if not os .path .exists (log_dir ):
875
- os .makedirs (log_dir )
876
- set_file_logger (self , self ["verbosity" ])
857
+ log_to_file = property (
858
+ lambda self : self ._d ["log_to_file" ],
859
+ lambda self , val : self ._set_boolean ("log_to_file" , val ),
860
+ doc = "Whether to save logs to a file." ,
861
+ )
877
862
878
863
notify_outdated_version = property (
879
864
lambda self : self ._d ["notify_outdated_version" ],
@@ -929,12 +914,6 @@ def log_to_file(self, val: str) -> None:
929
914
doc = "Set to force window when using the opengl renderer" ,
930
915
)
931
916
932
- dry_run = property (
933
- lambda self : self ._d ["dry_run" ],
934
- lambda self , val : self ._set_boolean ("dry_run" , val ),
935
- doc = "Enable dry_run so that no output files are generated and window is disabled." ,
936
- )
937
-
938
917
@property
939
918
def verbosity (self ):
940
919
"""Logger verbosity; "DEBUG", "INFO", "WARNING", "ERROR", or "CRITICAL" (-v)."""
@@ -1181,7 +1160,7 @@ def dry_run(self, val: bool) -> None:
1181
1160
1182
1161
@property
1183
1162
def renderer (self ):
1184
- """Renderer: "cairo", "opengl", "webgl" ""
1163
+ """Renderer: "cairo", "opengl"""
1185
1164
return self ._d ["renderer" ]
1186
1165
1187
1166
@renderer .setter
@@ -1221,7 +1200,7 @@ def renderer(self, val: str) -> None:
1221
1200
self ._set_from_list (
1222
1201
"renderer" ,
1223
1202
val ,
1224
- ["cairo" , "opengl" , "webgl" ],
1203
+ ["cairo" , "opengl" ],
1225
1204
)
1226
1205
1227
1206
@property
@@ -1236,31 +1215,9 @@ def use_opengl_renderer(self, val: bool) -> None:
1236
1215
self ._set_from_list (
1237
1216
"renderer" ,
1238
1217
"opengl" ,
1239
- ["cairo" , "opengl" , "webgl" ],
1218
+ ["cairo" , "opengl" ],
1240
1219
)
1241
1220
1242
- @property
1243
- def use_webgl_renderer (self ):
1244
- """Whether or not to use WebGL renderer."""
1245
- return self ._d ["use_webgl_renderer" ]
1246
-
1247
- @use_webgl_renderer .setter
1248
- def use_webgl_renderer (self , val : bool ) -> None :
1249
- self ._d ["use_webgl_renderer" ] = val
1250
- if val :
1251
- self ._set_from_list (
1252
- "webgl" ,
1253
- "renderer" ,
1254
- ["cairo" , "opengl" , "webgl" ],
1255
- )
1256
- self ["disable_caching" ] = True
1257
-
1258
- webgl_renderer_path = property (
1259
- lambda self : self ._d ["webgl_renderer_path" ],
1260
- lambda self , val : self ._d .__setitem__ ("webgl_renderer_path" , val ),
1261
- doc = "Path to WebGL renderer." ,
1262
- )
1263
-
1264
1221
media_dir = property (
1265
1222
lambda self : self ._d ["media_dir" ],
1266
1223
lambda self , val : self ._set_dir ("media_dir" , val ),
@@ -1637,15 +1594,15 @@ def __init__(self, c: ManimConfig) -> None:
1637
1594
self .__dict__ ["_c" ] = c
1638
1595
1639
1596
# there are required by parent class Mapping to behave like a dict
1640
- def __getitem__ (self , key : str | int ) -> typing . Any :
1597
+ def __getitem__ (self , key : str | int ) -> Any :
1641
1598
if key in self ._OPTS :
1642
1599
return self ._c [key ]
1643
1600
elif key in self ._CONSTANTS :
1644
1601
return self ._CONSTANTS [key ]
1645
1602
else :
1646
1603
raise KeyError (key )
1647
1604
1648
- def __iter__ (self ) -> typing . Iterable :
1605
+ def __iter__ (self ) -> Iterable :
1649
1606
return iter (list (self ._OPTS ) + list (self ._CONSTANTS ))
1650
1607
1651
1608
def __len__ (self ) -> int :
0 commit comments