Utilities¶
This module provides internal helper functions, video post-processing effects, and progress-bar utilities. Most users do not need to interact with these directly, but the public items are documented here for completeness.
String processing¶
stripEmptyLines()— Remove leading and trailing empty lines from a string.findSpacePositions()— Locate non-leading, non-trailing spaces in a multi-line string.replaceMiddleSpacesWithOccupyCharacter()— Replace middle spaces with a placeholder character used by Manim.
Video effects¶
addGlowEffect()— Apply a soft-glow filter to a rendered video.
Progress bars¶
DefaultProgressBar— Arichprogress bar used during rendering.RichProgressBarLogger— Aprogloglogger that bridges to Rich progress bars.
Context managers¶
noManimOutput()— Suppress Manim console output within awithblock.
- CodeVideoRenderer.utils.noManimOutput() Generator[None, Any, None][source]¶
Context manager used to execute code without outputting Manim logs.
Within the
withblock, Manim’s standard output, standard error, and progress bars are suppressed. Streams are restored when the block exits.- Yields:
None
- CodeVideoRenderer.utils.stripEmptyLines(text: str) str[source]¶
Remove empty lines from the beginning and end of a string.
- Parameters:
text (str) – The input string to process.
- Returns:
The string with empty lines removed from the beginning and end.
- Return type:
str
- CodeVideoRenderer.utils.typeName(item_type: Any) str[source]¶
Get the name of a type, handling union types and generic types.
- Parameters:
item_type – The type or value to get the name of.
- Returns:
The name of the type.
- Return type:
str
- CodeVideoRenderer.utils.addGlowEffect(input_path: StrPath, output_path: StrPath, output: bool) None[source]¶
Add a glow effect to a video.
- CodeVideoRenderer.utils.findSpacePositions(string: str) List[List[int]][source]¶
Find the 2D positions of all non-leading, non-trailing spaces in a string. Each position is represented as a list
[row_index, column_index].- Parameters:
string (str) – A string.
- Returns:
A list of 2D positions of all non-leading, non-trailing spaces. Each position is represented as a list
[row_index, column_index].- Return type:
List[List[int]]
- CodeVideoRenderer.utils.findEmptyLinePositions(string: str) List[int][source]¶
Find the line indices of all empty lines in a string.
- Parameters:
string (str) – A string.
- Returns:
A list of line indices of all empty lines.
- Return type:
List[int]
- CodeVideoRenderer.utils.replaceMiddleSpacesWithOccupyCharacter(string: str) str[source]¶
Replace all non-leading, non-trailing spaces in the input string with
OCCUPY_CHARACTER. Retain leading and trailing spaces.- Parameters:
string (str) – Original string.
- Returns:
Processed string with middle spaces replaced by
OCCUPY_CHARACTER.- Return type:
str
- class CodeVideoRenderer.utils.DefaultProgressBar(output: bool)[source]¶
Bases:
ProgressDefault progress bar used during video rendering.
This is a thin wrapper around
rich.progress.Progresspre-configured with descriptive columns (task name, bar, completion count, percentage, time remaining, and transfer speed).
- class CodeVideoRenderer.utils.RichProgressBarLogger(output: bool, title: str, init_state=None, bars=None, leave_bars=True, ignored_bars=None, logged_bars='all', print_messages=True, min_time_interval=0.1, ignore_bars_under=0)[source]¶
Bases:
ProgressBarLoggerA progress logger that uses Rich to display progress bars.
This class bridges
proglog(used by MoviePy) andrichprogress bars, allowing the glow-effect post-processing step to show a native-looking progress indicator in the terminal.