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):
if i is None or i == '':
i = 1
i = float(i)
try:
i = float(i)
except TypeError:
return str(i)
if int(i) == float(i):
return roman(int(i)) if use_roman else '%d'%int(i)
try:
return fmt%i
except TypeError:
return fmt%float(i)
return fmt%i
class Resource(object):
'''