mirrors: silence flake8 E721
This commit is contained in:
parent
9e4df5f0f3
commit
6883cbea24
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
@register.filter
|
@register.filter
|
||||||
def duration(value):
|
def duration(value):
|
||||||
if not value and type(value) != timedelta:
|
if not value or not isinstance(value, timedelta):
|
||||||
return u''
|
return u''
|
||||||
# does not take microseconds into account
|
# does not take microseconds into account
|
||||||
total_secs = value.seconds + value.days * 24 * 3600
|
total_secs = value.seconds + value.days * 24 * 3600
|
||||||
@ -17,7 +17,7 @@ def duration(value):
|
|||||||
|
|
||||||
@register.filter
|
@register.filter
|
||||||
def hours(value):
|
def hours(value):
|
||||||
if not value and type(value) != timedelta:
|
if not value or not isinstance(value, timedelta):
|
||||||
return u''
|
return u''
|
||||||
# does not take microseconds into account
|
# does not take microseconds into account
|
||||||
total_secs = value.seconds + value.days * 24 * 3600
|
total_secs = value.seconds + value.days * 24 * 3600
|
||||||
@ -30,7 +30,7 @@ def hours(value):
|
|||||||
|
|
||||||
@register.filter
|
@register.filter
|
||||||
def percentage(value, arg=1):
|
def percentage(value, arg=1):
|
||||||
if not value and type(value) != float:
|
if not value or not isinstance(value, float):
|
||||||
return u''
|
return u''
|
||||||
new_val = value * 100.0
|
new_val = value * 100.0
|
||||||
return '%.*f%%' % (arg, new_val)
|
return '%.*f%%' % (arg, new_val)
|
||||||
|
@ -22,5 +22,5 @@ def test_hours():
|
|||||||
|
|
||||||
def test_percentage():
|
def test_percentage():
|
||||||
assert percentage(None) == ''
|
assert percentage(None) == ''
|
||||||
assert percentage(10) == '1000.0%'
|
assert percentage(10.0) == '1000.0%'
|
||||||
assert percentage(10, 2) == '1000.00%'
|
assert percentage(10.0, 2) == '1000.00%'
|
||||||
|
Loading…
Reference in New Issue
Block a user