Added fixes to foreignkeys select in webmodel and added filesize.py module
This commit is contained in:
parent
617a9fb87b
commit
dfe0ee6550
2 changed files with 34 additions and 6 deletions
14
paramecio/citoplasma/filesize.py
Normal file
14
paramecio/citoplasma/filesize.py
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
# Code based in http://stackoverflow.com/questions/5194057/better-way-to-convert-file-sizes-in-python
|
||||
|
||||
import math
|
||||
|
||||
def filesize(size):
|
||||
if (size == 0):
|
||||
return '0B'
|
||||
size_name = ("b", "Kb", "Mb", "Gb", "Tb", "Pb", "Eb", "Zb", "Yb")
|
||||
i = int(math.floor(math.log(size,1024)))
|
||||
p = math.pow(1024,i)
|
||||
s = round(size/p,2)
|
||||
return '%s %s' % (s,size_name[i])
|
||||
Loading…
Add table
Add a link
Reference in a new issue