diff options
author | Rasmus Andersson <rasmus@notion.se> | 2020-08-20 23:10:13 +0300 |
---|---|---|
committer | Rasmus Andersson <rasmus@notion.se> | 2020-08-20 23:10:13 +0300 |
commit | d86c8641527fce31282cd0b59d77621d4b1bc448 (patch) | |
tree | 75ba38247c8c6d29507a14096829dbc0edb546db /misc/tools | |
parent | dc3b56dac76a57ec5b0b43690595d946492d15a7 (diff) | |
download | inter-d86c8641527fce31282cd0b59d77621d4b1bc448.tar.xz |
misc: update misc/tools/download-count.py
Diffstat (limited to 'misc/tools')
-rwxr-xr-x | misc/tools/download-count.py | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/misc/tools/download-count.py b/misc/tools/download-count.py index c70532490..28c3fea5b 100755 --- a/misc/tools/download-count.py +++ b/misc/tools/download-count.py @@ -1,19 +1,31 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 # encoding: utf8 from __future__ import print_function import os, sys, json, urllib2 +# Before v2.5 the repo was under a different URL (rsms/interface). +# This is the last known download count of that old repo. +pre_v2_5_count = 81218 + f = urllib2.urlopen('https://api.github.com/repos/rsms/inter/releases') releases = json.load(f) -countTotal = 0 +# find longest name +maxNameLen = 0 +for release in releases: + if len(release['assets']) > 0: + maxNameLen = max(maxNameLen, len(release['tag_name'])) +# print download count per version and count total +countTotal = pre_v2_5_count for release in releases: if len(release['assets']) > 0: count = release['assets'][0]['download_count'] countTotal += count - print('%s: %d' % (release['tag_name'], count)) + print('%-*s %d' % (maxNameLen, release['tag_name'], count)) else: - print('%s: (missing)' % release['tag_name']) + print('%-*s (missing)' % (maxNameLen, release['tag_name'])) -print('Total: %d' % countTotal) +print('%-*s %d' % (maxNameLen, '<v2.5', pre_v2_5_count)) +print(('—' * maxNameLen) + ' ' + ('—' * maxNameLen)) +print('%-*s %d' % (maxNameLen, 'Total', countTotal)) |