Expand description
Common shared utilities used across download, upload, formatting, and progress modules.
This module consolidates duplicated functionality to follow DRY principles:
- Bandwidth calculation
- Stream count determination
- Distance formatting
- Data size formatting
- Terminal width detection
Functionsยง
- bar_
chart - Render a horizontal bar chart using Unicode block characters.
- calculate_
bandwidth - Calculate bandwidth in bits per second from bytes transferred and elapsed time.
- determine_
stream_ count Deprecated - Determine number of concurrent streams based on single connection flag.
- format_
data_ size - Format byte count into a human-readable string (KB, MB, GB).
- format_
data_ size_ tabular - Format data size (bytes) with tabular alignment for data transfer amounts.
Returns a fixed-width string like
" 15.0 MB". - format_
distance - Format distance consistently: 1 decimal for < 100 km, 0 decimals for >= 100 km.
- format_
duration_ tabular - Format duration with tabular alignment.
- format_
jitter_ tabular - Format jitter in ms with tabular alignment.
- format_
latency_ tabular - Format latency in ms with tabular alignment.
Returns a fixed-width string like
" 12.1 ms". - format_
loss_ tabular - Format packet loss percentage with tabular alignment.
- format_
speed_ tabular - Format a speed value in Mbps with tabular alignment.
Returns a fixed-width string like
" 150.00 Mb/s"or" 0.12 Gb/s". - get_
terminal_ width - Get the terminal width in columns, or a sensible default.
- get_
terminal_ width_ bounded - Get the terminal width with a minimum and maximum bound.
- is_
valid_ ipv4 - Validate an IPv4 address string.
- tabular_
number - Format a numeric value with fixed-width padding for vertical alignment. Pads with leading spaces so numbers right-align in columns.