Skip to content

Commit 0e57488

Browse files
Refactor #1637 (#1650)
* Refactor #1637 * Refactor #1637 * Refactor #1637 * Refactor #1637 * Refactor #1637 * Refactor #1637 * Update config.py Co-authored-by: 鹤翔万里 <tonycrane@foxmail.com>
1 parent bee3470 commit 0e57488

File tree

9 files changed

+27
-22
lines changed

9 files changed

+27
-22
lines changed

manimlib/__main__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77

88
def main():
9-
args = manimlib.config.parse_cli()
10-
119
print(f"ManimGL \033[32mv{__version__}\033[0m")
10+
11+
args = manimlib.config.parse_cli()
1212
if args.version and args.file == None:
1313
return
1414

@@ -21,5 +21,5 @@ def main():
2121
for scene in scenes:
2222
scene.run()
2323

24-
if __name__ == '__main__':
24+
if __name__ == "__main__":
2525
main()

manimlib/config.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,9 @@ def get_custom_config():
193193

194194
def check_temporary_storage(config):
195195
if config["directories"]["temporary_storage"] == "" and sys.platform == "win32":
196-
log.warning("You may be using Windows platform and have not specified the `temporary\
197-
_storage` path, which may cause OSError. So it is recommended that you specify the `temporary\
198-
_storage` in the config file (.yml)")
196+
log.warning("You may be using Windows platform and have not specified the path of"
197+
" `temporary_storage`, which may cause OSError. So it is recommended"
198+
" to specify the `temporary_storage` in the config file (.yml)")
199199

200200

201201
def get_configuration(args):
@@ -220,13 +220,13 @@ def get_configuration(args):
220220
global_defaults_file = os.path.join(get_manim_dir(), "manimlib", "default_config.yml")
221221

222222
if not (os.path.exists(global_defaults_file) or os.path.exists(__config_file__)):
223-
log.info("There is no configuration file detected. Initial configuration:\n")
223+
log.info("There is no configuration file detected. Switch to the config file initializer:")
224224
init_customization()
225225

226226
elif not os.path.exists(__config_file__):
227227
log.info(f"Using the default configuration file, which you can modify in `{global_defaults_file}`")
228-
log.info(f"If you want to create a local configuration file, you can create a file named \
229-
`{__config_file__}`, or run `manimgl --config`")
228+
log.info("If you want to create a local configuration file, you can create a file named"
229+
f" `{__config_file__}`, or run `manimgl --config`")
230230

231231
custom_config = get_custom_config()
232232
check_temporary_storage(custom_config)

manimlib/logger.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import logging
22
from rich.logging import RichHandler
33

4+
__all__ = ["log"]
5+
6+
47
FORMAT = "%(message)s"
58
logging.basicConfig(
69
level="NOTSET", format=FORMAT, datefmt="[%X]", handlers=[RichHandler()]
710
)
811

9-
log = logging.getLogger("rich")
12+
log = logging.getLogger("rich")

manimlib/scene/scene.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010

1111
from manimlib.animation.animation import prepare_animation
1212
from manimlib.animation.transform import MoveToTarget
13-
from manimlib.mobject.mobject import Point
1413
from manimlib.camera.camera import Camera
1514
from manimlib.constants import DEFAULT_WAIT_TIME
1615
from manimlib.mobject.mobject import Mobject
16+
from manimlib.mobject.mobject import Point
1717
from manimlib.scene.scene_file_writer import SceneFileWriter
1818
from manimlib.utils.config_ops import digest_config
1919
from manimlib.utils.family_ops import extract_mobject_family_members
@@ -101,8 +101,8 @@ def interact(self):
101101
# If there is a window, enter a loop
102102
# which updates the frame while under
103103
# the hood calling the pyglet event loop
104-
log.info("Tips: You are now in the interactive mode. Now you can use the keyboard\
105-
and the mouse to interact with the scene. Just press `q` if you want to quit.")
104+
log.info("Tips: You are now in the interactive mode. Now you can use the keyboard"
105+
" and the mouse to interact with the scene. Just press `q` if you want to quit.")
106106
self.quit_interaction = False
107107
self.lock_static_mobject_data()
108108
while not (self.window.is_closing or self.quit_interaction):
@@ -134,8 +134,8 @@ def embed(self):
134134
local_ns["touch"] = self.interact
135135
for term in ("play", "wait", "add", "remove", "clear", "save_state", "restore"):
136136
local_ns[term] = getattr(self, term)
137-
log.info("Tips: Now the embed iPython terminal is open. But you can't interact with \
138-
the window directly. To do so, you need to type `touch()` or `self.interact()`")
137+
log.info("Tips: Now the embed iPython terminal is open. But you can't interact with"
138+
" the window directly. To do so, you need to type `touch()` or `self.interact()`")
139139
shell(local_ns=local_ns, stack_depth=2)
140140
# End scene when exiting an embed.
141141
raise EndSceneEarlyException()
@@ -463,9 +463,7 @@ def finish_animations(self, animations):
463463
@handle_play_like_call
464464
def play(self, *args, **kwargs):
465465
if len(args) == 0:
466-
log.warning(
467-
"Called Scene.play with no animations"
468-
)
466+
log.warning("Called Scene.play with no animations")
469467
return
470468
animations = self.anims_from_play_args(*args, **kwargs)
471469
self.lock_static_mobject_data(*animations)

manimlib/scene/scene_file_writer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ def save_final_image(self, image):
301301
self.print_file_ready_message(file_path)
302302

303303
def print_file_ready_message(self, file_path):
304-
log.info(f"\nFile ready at {file_path}\n")
304+
log.info(f"File ready at {file_path}")
305305

306306
def should_open_file(self):
307307
return any([

manimlib/utils/bezier.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ def interpolate(start, end, alpha):
6969
try:
7070
return (1 - alpha) * start + alpha * end
7171
except TypeError:
72-
log.debug(type(start), start.dtype)
73-
log.debug(type(end), start.dtype)
74-
log.debug(alpha)
72+
log.debug(f"`start` parameter with type `{type(start)}` and dtype `{start.dtype}`")
73+
log.debug(f"`end` parameter with type `{type(end)}` and dtype `{end.dtype}`")
74+
log.debug(f"`alpha` parameter with value `{alpha}`")
7575
import sys
7676
sys.exit(2)
7777

manimlib/utils/init_config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ def init_customization():
4646
}
4747
}
4848

49+
print("Initialize configuration")
4950
scope = input(" Please select the scope of the configuration [global/local]: ")
5051
if scope == "global":
5152
from manimlib.config import get_manim_dir

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ moderngl_window
1212
pydub
1313
pygments
1414
pyyaml
15+
rich
1516
screeninfo
1617
pyreadline; sys_platform == 'win32'
1718
validators

setup.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ install_requires =
2929
moderngl
3030
moderngl_window
3131
pydub
32+
pygments
3233
pyyaml
34+
rich
3335
screeninfo
3436
pyreadline; sys_platform == 'win32'
3537
validators

0 commit comments

Comments
 (0)