Mercurial > babel > mirror
diff babel/numbers.py @ 556:aa53048ad7ac trunk
remove Python 2.3 compat code for Decimal
author | fschwarz |
---|---|
date | Tue, 30 Aug 2011 20:27:34 +0000 |
parents | ca203b2af83c |
children | 4e561e6411ba |
line wrap: on
line diff
--- a/babel/numbers.py +++ b/babel/numbers.py @@ -23,13 +23,9 @@ # TODO: # Padding and rounding increments in pattern: # - http://www.unicode.org/reports/tr35/ (Appendix G.6) +from decimal import Decimal import math import re -try: - from decimal import Decimal - have_decimal = True -except ImportError: - have_decimal = False from babel.core import default_locale, Locale @@ -326,7 +322,7 @@ def split_number(value): """Convert a number into a (intasstring, fractionasstring) tuple""" - if have_decimal and isinstance(value, Decimal): + if isinstance(value, Decimal): text = str(value) else: text = ('%.9f' % value).rstrip('0') @@ -366,7 +362,7 @@ elif digits[i] == '5' and digits[i-1] in '13579': add = 1 scale = 10**ndigits - if have_decimal and isinstance(value, Decimal): + if isinstance(value, Decimal): return Decimal(int(value * scale + add)) / scale * sign else: return float(int(value * scale + add)) / scale * sign @@ -490,7 +486,7 @@ # Exponent grouping elif self.int_prec[1]: exp = int(exp) / self.int_prec[1] * self.int_prec[1] - if not have_decimal or not isinstance(value, Decimal): + if not isinstance(value, Decimal): value = float(value) if exp < 0: value = value * 10**(-exp)