##// END OF EJS Templates
fixed issue with show at revision button. Some JS were not properly loaded due to ajaxified files view....
fixed issue with show at revision button. Some JS were not properly loaded due to ajaxified files view. Removed JS code and the logic for that is in python view now. Simpler and less ugly JS callbacks

File last commit:

r2007:324ac367 beta
r2931:4c7cc3a4 beta
Show More
filesize.py
28 lines | 840 B | text/x-python | PythonLexer
Added VCS into rhodecode core for faster and easier deployments of new versions
r2007 def filesizeformat(bytes, sep=' '):
"""
Formats the value like a 'human-readable' file size (i.e. 13 KB, 4.1 MB,
102 B, 2.3 GB etc).
Grabbed from Django (http://www.djangoproject.com), slightly modified.
:param bytes: size in bytes (as integer)
:param sep: string separator between number and abbreviation
"""
try:
bytes = float(bytes)
except (TypeError, ValueError, UnicodeDecodeError):
return '0%sB' % sep
if bytes < 1024:
size = bytes
template = '%.0f%sB'
elif bytes < 1024 * 1024:
size = bytes / 1024
template = '%.0f%sKB'
elif bytes < 1024 * 1024 * 1024:
size = bytes / 1024 / 1024
template = '%.1f%sMB'
else:
size = bytes / 1024 / 1024 / 1024
template = '%.2f%sGB'
return template % (size, sep)