mirror of
https://github.com/meeb/tubesync.git
synced 2025-06-24 14:06:36 +00:00
Add fixB filter
This commit is contained in:
parent
4e710f503a
commit
22cec87636
@ -1,10 +1,20 @@
|
||||
from django import template
|
||||
from django.template.defaultfilters import filesizeformat
|
||||
from django.template.defaultfilters import filesizeformat, stringfilter
|
||||
|
||||
|
||||
register = template.Library()
|
||||
|
||||
|
||||
@register.filter(is_safe=True)
|
||||
@stringfilter
|
||||
def fixB(input):
|
||||
return input.replace('B', 'iB')
|
||||
|
||||
|
||||
@register.filter(is_safe=True)
|
||||
def bytesformat(input):
|
||||
intermediate = filesizeformat(input)
|
||||
return intermediate.replace('B', 'iB')
|
||||
output = filesizeformat(input)
|
||||
if not (output and output.endswith('B')):
|
||||
return output
|
||||
return fixB(output)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user