Skip to content

Instantly share code, notes, and snippets.

@s3rgeym
Created May 2, 2026 07:33
Show Gist options
  • Select an option

  • Save s3rgeym/a51a55dcdb8ad981d42dce5f5dece613 to your computer and use it in GitHub Desktop.

Select an option

Save s3rgeym/a51a55dcdb8ad981d42dce5f5dece613 to your computer and use it in GitHub Desktop.
data="""\
1. [✓] org.freedesktop.Platform.GL.default 24.08 u flathub 25.8 MB / 147.8 MB
2. [✓] org.freedesktop.Platform.GL.default 24.08extra u flathub 25.9 MB / 147.8 MB
3. [✓] org.freedesktop.Platform.Locale 24.08 u flathub 850.4 kB / 388.9 MB
4. [✓] org.freedesktop.Platform.ffmpeg-full 24.08 u flathub 5.4 kB / 12.1 MB
5. [✓] org.freedesktop.Sdk.Locale 24.08 u flathub 1.9 MB / 394.4 MB
6. [✓] org.freedesktop.Sdk.Locale 25.08 u flathub 18.5 kB / 394.8 MB
7. [✓] org.gnome.Platform.Locale 49 u flathub 18.5 kB / 385.8 MB
8. [✓] org.gnome.Platform.Locale 50 u flathub 18.5 kB / 386.0 MB
9. [✓] org.gnome.Platform 50 u flathub 1.4 MB / 408.8 MB
10. [✓] org.gimp.GIMP stable u flathub 30.6 MB / 99.5 MB
11. [✓] org.gnome.Platform 49 u flathub 7.3 MB / 407.9 MB
12. [✓] org.freedesktop.Sdk 25.08 u flathub 1.3 MB / 596.2 MB
13. [✓] org.freedesktop.Sdk 24.08 u flathub 11.6 MB / 631.2 MB
14. [✓] org.freedesktop.Platform 24.08 u flathub 2.3 MB / 268.4 MB
15. [✓] org.libreoffice.LibreOffice.Locale stable u flathub 10.3 kB / 91.6 MB
16. [✓] org.libreoffice.LibreOffice stable u flathub 169.9 MB / 326.4 MB
17. [✓] org.mozilla.Thunderbird.Locale stable u flathub 5.5 MB / 5.5 MB
18. [✓] org.mozilla.Thunderbird stable u flathub 69.0 MB / 108.3 MB
19. [✓] org.shotcut.Shotcut.Locale stable i flathub 3.5 kB / 644.9 kB
20. [✓] org.shotcut.Shotcut stable u flathub 24.1 MB / 78.3 MB\
"""
def convert_size(s,u):
return float(s)*({'kB':1<<10,'MB':1<<20,'GB':1<<30})[u]
sizes = []
for line in data.split('\n'):
d_s, d_u, _, t_s, t_u = line.split()[-5:]
sizes.append((convert_size(d_s, d_u), convert_size(t_s, t_u)))
print(sizes)
downloaded = sum(s[0] for s in sizes)
total = sum(s[1] for s in sizes)
print(downloaded, '/', total, '=', downloaded / total*100, '%')
@s3rgeym

s3rgeym commented Jun 22, 2026

Copy link
Copy Markdown
Author
data="""\
 1. [✓] io.github.ungoogled_software.ungoogled_chromium.Locale    stable        u    flathub    25.0 kB / 19.5 MB
 2. [✓] org.freedesktop.Platform.GL.default                       25.08         u    flathub    69.0 MB / 142.6 MB
 3. [✓] org.freedesktop.Platform.GL.default                       25.08-extra   u    flathub     5.4 MB / 142.6 MB
 4. [✓] org.freedesktop.Platform.Locale                           25.08         u    flathub     1.6 kB / 379.1 MB
 5. [✓] org.freedesktop.Platform.codecs-extra                     25.08-extra   u    flathub   815.4 kB / 14.4 MB
 6. [✓] org.freedesktop.Sdk.Locale                                25.08         u    flathub     1.5 kB / 394.9 MB
 7. [✓] org.gnome.Platform.Locale                                 50            u    flathub     1.5 kB / 386.1 MB
 8. [✓] org.gtk.Gtk3theme.Breeze                                  3.22          u    flathub    12.0 kB / 192.5 kB
 9. [✓] org.gnome.Platform                                        50            u    flathub    13.7 MB / 408.5 MB
10. [✓] org.telegram.desktop                                      stable        u    flathub   303.5 kB / 96.3 MB
11. [✓] org.gimp.GIMP                                             stable        u    flathub    47.3 MB / 99.6 MB
12. [✓] org.freedesktop.Sdk                                       25.08         u    flathub    28.9 MB / 596.6 MB
13. [✓] org.freedesktop.Platform                                  25.08         u    flathub     3.1 MB / 252.7 MB
14. [✓] io.github.ungoogled_software.ungoogled_chromium           stable        u    flathub   126.5 MB / 153.7 MB
15. [✓] org.mozilla.firefox.Locale                                stable        u    flathub   788.4 kB / 38.8 MB
16. [✓] org.mozilla.firefox                                       stable        u    flathub    94.7 MB / 122.1 MB\
"""

def convert_size(s,u):
  return float(s)*({'kB':1<<10,'MB':1<<20,'GB':1<<30})[u]

sizes = []
for line in data.split('\n'):
  d_s, d_u, _, t_s, t_u = line.split()[-5:]
  sizes.append((convert_size(d_s, d_u), convert_size(t_s, t_u)))
  
print(sizes)

downloaded = sum(s[0] for s in sizes)
total = sum(s[1] for s in sizes)

print(downloaded, '/', total, '=', downloaded / total*100, '%')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment