From 2c91696e2dc902813b1540f213ead11669029423 Mon Sep 17 00:00:00 2001 From: Todd Zullinger Date: Fri, 30 Oct 2009 02:34:41 -0400 Subject: [PATCH 2/2] spins: Format the torrent size in MB rather than bytes --- spins.fedoraproject.org/data/templates/master.html | 9 +++++++++ .../data/templates/sidebar.html | 2 +- 2 files changed, 10 insertions(+), 1 deletions(-) diff --git a/spins.fedoraproject.org/data/templates/master.html b/spins.fedoraproject.org/data/templates/master.html index 9a8bb1b..cb4f28d 100644 --- a/spins.fedoraproject.org/data/templates/master.html +++ b/spins.fedoraproject.org/data/templates/master.html @@ -24,6 +24,15 @@ def gettorrentinfo(name, value): if name in part['name'].lower(): return part[value] + +def gettorrentsize(area): + for spin in spins: + if spin['name'].lower().endswith(area): + return formatsize(spin['size']) + +def formatsize(n, format='%0.2f'): + return format % (n / 1024.0**2) + # let's get our data fo = urllib.urlopen('http://torrent.fedoraproject.org/stats/current-stats.json') torrents = simplejson.load(fo) diff --git a/spins.fedoraproject.org/data/templates/sidebar.html b/spins.fedoraproject.org/data/templates/sidebar.html index 106e59f..779ff8d 100644 --- a/spins.fedoraproject.org/data/templates/sidebar.html +++ b/spins.fedoraproject.org/data/templates/sidebar.html @@ -41,7 +41,7 @@
-

${gettorrentinfo(area, 'size')} MB Torrent File for 32-bit PC ISO

+

${gettorrentsize(area)} MB Torrent File for 32-bit PC ISO

${_('How do I use this?')} | ${_('More download options ...')}

-- 1.6.5.2