PR#3137: www: rpminfo/fileinfo/imageinfo/archiveinfo page shows human-readable filesize
Merges #3137 https://pagure.io/koji/pull-request/3137 Fixes: #2943 https://pagure.io/koji/issue/2943 www: rpminfo page does not show human-readable filesize
This commit is contained in:
commit
f2f4a3dcdf
5 changed files with 16 additions and 7 deletions
|
|
@ -42,7 +42,7 @@
|
|||
</tr>
|
||||
#end if
|
||||
<tr>
|
||||
<th>Size</th><td>$archive.size</td>
|
||||
<th>Size</th><td><span title="$util.formatThousands($archive.size)">$util.formatNatural($archive.size)</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Checksum</th><td>$archive.checksum</td>
|
||||
|
|
@ -97,7 +97,7 @@
|
|||
</tr>
|
||||
#for $file in $files
|
||||
<tr class="$util.rowToggle($self)">
|
||||
<td><a href="fileinfo?archiveID=$archive.id&filename=$quote($file.name)">$file.name</a></td><td>$file.size</td>
|
||||
<td><a href="fileinfo?archiveID=$archive.id&filename=$quote($file.name)">$file.name</a></td><td><span title="$util.formatThousands($file.size)">$util.formatNatural($file.size)</span></td>
|
||||
</tr>
|
||||
#end for
|
||||
</table>
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
</tr>
|
||||
#end if
|
||||
<tr>
|
||||
<th>Size</th><td>$file.size</td>
|
||||
<th>Size</th><td><span title="$util.formatThousands($file.size)">$util.formatNatural($file.size)</span></td>
|
||||
</tr>
|
||||
#if 'mtime' in $file and $file.mtime
|
||||
<tr>
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
<th>File Name</th><td>$image.filename</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>File Size</th><td>$image.filesize</td>
|
||||
<th>File Size</th><td><span title="$util.formatThousands($image.filesize)">$util.formatNatural($image.filesize)</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Arch</th><td>$image.arch</td>
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@
|
|||
</tr>
|
||||
#end if
|
||||
<tr>
|
||||
<th>Size</th><td>$util.formatThousands($rpm.size)</td>
|
||||
<th>Size</th><td><span title="$util.formatThousands($rpm.size)">$util.formatNatural($rpm.size)</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><label title="The MD5 digest of the combined header and payload contents. You can query it by `rpmkeys -Kv foo.rpm`">SIGMD5</label></th><td>$rpm.payloadhash</td>
|
||||
|
|
@ -250,7 +250,7 @@
|
|||
</tr>
|
||||
#for $file in $files
|
||||
<tr class="$util.rowToggle($self)">
|
||||
<td><a href="fileinfo?rpmID=$rpm.id&filename=$quote($file.name)">$util.escapeHTML($file.name)</a></td><td align="right">$util.formatThousands($file.size)</td>
|
||||
<td><a href="fileinfo?rpmID=$rpm.id&filename=$quote($file.name)">$util.escapeHTML($file.name)</a></td><td align="right"><span title="$util.formatThousands($file.size)">$util.formatNatural($file.size)</span></td>
|
||||
</tr>
|
||||
#end for
|
||||
</table>
|
||||
|
|
|
|||
|
|
@ -530,7 +530,16 @@ def formatMode(mode):
|
|||
|
||||
|
||||
def formatThousands(value):
|
||||
return '{:,}'.format(value)
|
||||
return '{:,} B'.format(value)
|
||||
|
||||
|
||||
def formatNatural(value):
|
||||
suffix = ['B', 'KB', 'MB', 'GB']
|
||||
suff_index = 0
|
||||
while value >= 1024 and suff_index < 3:
|
||||
suff_index += 1 # increment the index of the suffix
|
||||
value = value / 1024.0 # apply the division
|
||||
return '{:.2f} {}'.format(value, suffix[suff_index])
|
||||
|
||||
|
||||
def formatLink(url):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue