mirror of
https://github.com/jeertmans/manim-slides.git
synced 2025-05-24 14:05:59 +08:00
chore(ci): add more style checks (#32)
* chore(ci): add more style checks * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * chore(ci): remove vulture as flake8 replaces it * chore(lib): add __all__ list * chore(ci): make flake8 happy and remove mypy * fix: config_path is actually used in commons Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@ -19,7 +19,12 @@ repos:
|
||||
rev: 22.8.0
|
||||
hooks:
|
||||
- id: black
|
||||
- repo: https://github.com/jendrikseipp/vulture
|
||||
rev: v2.6
|
||||
- repo: https://github.com/PyCQA/flake8
|
||||
rev: 5.0.4
|
||||
hooks:
|
||||
- id: vulture
|
||||
- id: flake8
|
||||
additional_dependencies:
|
||||
- flake8-bugbear
|
||||
- flake8-comprehensions
|
||||
- flake8-tidy-imports
|
||||
- flake8-typing-imports
|
||||
|
@ -1,3 +1,4 @@
|
||||
# flake8: noqa: F403, F405
|
||||
import sys
|
||||
|
||||
if "manim" in sys.modules:
|
||||
|
@ -1,2 +1,3 @@
|
||||
# flake8: noqa: F401
|
||||
from .__version__ import __version__
|
||||
from .slide import Slide, ThreeDSlide
|
||||
|
@ -3,6 +3,22 @@ import sys
|
||||
from contextlib import contextmanager
|
||||
from importlib.util import find_spec
|
||||
|
||||
__all__ = [
|
||||
"MANIM",
|
||||
"MANIM_PACKAGE_NAME",
|
||||
"MANIM_AVAILABLE",
|
||||
"MANIM_IMPORTED",
|
||||
"MANIMGL",
|
||||
"MANIMGL_PACKAGE_NAME",
|
||||
"MANIMGL_AVAILABLE",
|
||||
"MANIMGL_IMPORTED",
|
||||
"logger",
|
||||
"Scene",
|
||||
"ThreeDScene",
|
||||
"config",
|
||||
"FFMPEG_BIN",
|
||||
]
|
||||
|
||||
|
||||
@contextmanager
|
||||
def suppress_stdout():
|
||||
@ -61,6 +77,6 @@ else:
|
||||
from manim import Scene, ThreeDScene, config, logger
|
||||
|
||||
try: # For manim<v0.16.0.post0
|
||||
from manim.constants import FFMPEG_BIN as FFMPEG_BIN
|
||||
from manim.constants import FFMPEG_BIN
|
||||
except ImportError:
|
||||
FFMPEG_BIN = config.ffmpeg_executable
|
||||
|
@ -1,8 +1,6 @@
|
||||
import json
|
||||
import math
|
||||
import os
|
||||
import platform
|
||||
import sys
|
||||
import time
|
||||
from enum import IntEnum, auto, unique
|
||||
from typing import List, Tuple
|
||||
@ -15,7 +13,7 @@ from tqdm import tqdm
|
||||
|
||||
from .commons import config_path_option
|
||||
from .config import Config, PresentationConfig, SlideConfig, SlideType
|
||||
from .defaults import CONFIG_PATH, FOLDER_PATH, FONT_ARGS
|
||||
from .defaults import FOLDER_PATH, FONT_ARGS
|
||||
|
||||
INTERPOLATION_FLAGS = {
|
||||
"nearest": cv2.INTER_NEAREST,
|
||||
@ -94,7 +92,7 @@ class Presentation:
|
||||
|
||||
def release_cap(self):
|
||||
"""Releases current Video Capture, if existing."""
|
||||
if not self.cap is None:
|
||||
if self.cap is not None:
|
||||
self.cap.release()
|
||||
|
||||
self.loaded_animation_cap = -1
|
||||
@ -349,7 +347,7 @@ class Display:
|
||||
self.lag = now() - self.last_time
|
||||
self.last_time = now()
|
||||
|
||||
if not self.record_to is None:
|
||||
if self.record_to is not None:
|
||||
pres = self.current_presentation
|
||||
self.recordings.append(
|
||||
(pres.current_file, pres.current_frame_number, pres.fps)
|
||||
@ -451,7 +449,7 @@ class Display:
|
||||
"""Destroys all windows created by presentations and exits gracefully."""
|
||||
cv2.destroyAllWindows()
|
||||
|
||||
if not self.record_to is None and len(self.recordings) > 0:
|
||||
if self.record_to is not None and len(self.recordings) > 0:
|
||||
file, frame_number, fps = self.recordings[0]
|
||||
|
||||
cap = cv2.VideoCapture(file)
|
||||
@ -591,7 +589,7 @@ def present(
|
||||
def value_proc(value: str):
|
||||
indices = list(map(int, value.strip().replace(" ", "").split(",")))
|
||||
|
||||
if not all(map(lambda i: 0 < i <= len(scene_choices), indices)):
|
||||
if not all(0 < i <= len(scene_choices) for i in indices):
|
||||
raise click.UsageError(
|
||||
"Please only enter numbers displayed on the screen."
|
||||
)
|
||||
@ -610,7 +608,7 @@ def present(
|
||||
except ValueError as e:
|
||||
raise click.UsageError(e)
|
||||
|
||||
presentations = list()
|
||||
presentations = []
|
||||
for scene in scenes:
|
||||
config_file = os.path.join(folder, f"{scene}.json")
|
||||
if not os.path.exists(config_file):
|
||||
@ -631,11 +629,11 @@ def present(
|
||||
else:
|
||||
config = Config()
|
||||
|
||||
if not record_to is None:
|
||||
if record_to is not None:
|
||||
_, ext = os.path.splitext(record_to)
|
||||
if ext.lower() != ".avi":
|
||||
raise click.UsageError(
|
||||
f"Recording only support '.avi' extension. For other video formats, please convert the resulting '.avi' file afterwards."
|
||||
"Recording only support '.avi' extension. For other video formats, please convert the resulting '.avi' file afterwards."
|
||||
)
|
||||
|
||||
display = Display(
|
||||
|
@ -1,4 +1,3 @@
|
||||
import json
|
||||
import os
|
||||
import platform
|
||||
import shutil
|
||||
@ -39,7 +38,7 @@ class Slide(Scene):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
self.output_folder = output_folder
|
||||
self.slides = list()
|
||||
self.slides = []
|
||||
self.current_slide = 1
|
||||
self.current_animation = 0
|
||||
self.loop_start_animation = None
|
||||
@ -143,7 +142,7 @@ class Slide(Scene):
|
||||
else:
|
||||
old_animation_files.update(os.listdir(scene_files_folder))
|
||||
|
||||
files = list()
|
||||
files = []
|
||||
for src_file in tqdm(
|
||||
self.partial_movie_files,
|
||||
desc=f"Copying animation files to '{scene_files_folder}' and generating reversed animations",
|
||||
|
@ -1,3 +1,4 @@
|
||||
# flake8: noqa: F403, F405
|
||||
from manim import *
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user