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