Skip to main content

Module common

Module common 

Source
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

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
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_distance
Format distance consistently: 1 decimal for < 100 km, 0 decimals for >= 100 km.
is_valid_ipv4
Validate an IPv4 address string.