From cd64abe26c668c6f286384c283b79cc7650cedf1 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 11 Jun 2009 07:56:12 -0700 Subject: [PATCH] Make formatting of series_index more robust --- src/calibre/ebooks/metadata/__init__.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/calibre/ebooks/metadata/__init__.py b/src/calibre/ebooks/metadata/__init__.py index 4c2c6c744a..81275b4ff6 100644 --- a/src/calibre/ebooks/metadata/__init__.py +++ b/src/calibre/ebooks/metadata/__init__.py @@ -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): '''