stanza.jupyter.utils
Utilities for Jupyter notebook management.
Module Contents
Functions
API
Remove carriage return artifacts from logged output.
Terminal progress bars use \r to overwrite previous text. When logged to a file, this creates lines like “old_text\r new_text”. We keep only the text after the last \r on each line, which is what would be visible on a real terminal.
Parameters:
Raw text containing carriage return artifacts
Returns:
Cleaned text with only the final visible content from each line
Read last N lines from log file.
Only reads last 4KB to avoid loading large files into memory. Splits on \n only to preserve \r for carriage return processing.
Parameters:
Path to the log file to read
Number of lines to return from the end of the file
Returns:
Last N lines from the log file, or empty string if file doesn’t exist
Format bytes to human-readable string.
Parameters:
Size in bytes
Returns:
Human-readable string (e.g., “1.5 KB”, “2.3 MB”)

