synology_apm_repo.sdk.presentation.format module¶
Size/duration/count formatting shared by the CLI and the TUI. Both
surfaces must render these identically, so they live in the SDK rather
than in cli/progress_render.py or browser/format.py: a per-surface
copy would let them silently drift apart.
- synology_apm_repo.sdk.presentation.format.pluralize(count, singular, plural=None)¶
singularforcount == 1, elseplural(default:singularwith an “s” appended) — the English-pluralization shape every status line reporting a count already needed on its own.
- synology_apm_repo.sdk.presentation.format.format_bytes(n)¶
- synology_apm_repo.sdk.presentation.format.format_duration(seconds)¶
- synology_apm_repo.sdk.presentation.format.format_timestamp(dt)¶
Renders an already timezone-aware
datetime(aNode’s ownnode_modified_time(), a version’s own backup epoch, …) in the machine’s local timezone — shared bycatalog/version.py’s own_version_display_name(), so a Modified column and a version’s own display name read consistently.
- synology_apm_repo.sdk.presentation.format.format_rate(rate, unit)¶
Format a
ProgressMeter.ratevalue for display:"12.3 MiB/s"for the byte-denominated"bytes"unit,"4.0 <unit>/s"for any other progress unit. Callers should only invoke this oncerate > 0— a zero/negative rate isn’t a meaningful display value and both call sites already gate on it.