Make formatting of series_index more robust

This commit is contained in:
Kovid Goyal 2009-06-11 07:56:12 -07:00
parent 97386ccb9d
commit cd64abe26c

View File

@ -63,14 +63,13 @@ def roman(num):
def fmt_sidx(i, fmt='%.2f', use_roman=False): def fmt_sidx(i, fmt='%.2f', use_roman=False):
if i is None or i == '': if i is None or i == '':
i = 1 i = 1
try:
i = float(i) i = float(i)
except TypeError:
return str(i)
if int(i) == float(i): if int(i) == float(i):
return roman(int(i)) if use_roman else '%d'%int(i) return roman(int(i)) if use_roman else '%d'%int(i)
try:
return fmt%i return fmt%i
except TypeError:
return fmt%float(i)
class Resource(object): class Resource(object):
''' '''