Remove excess try/except KeyError block

This commit is contained in:
btharper
2019-10-26 23:22:23 -04:00
parent 6819f5a6ed
commit d161b4348d

View File

@@ -15,7 +15,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301 USA
from __future__ import print_function, unicode_literals
from __future__ import division, print_function, unicode_literals
import math
@@ -122,7 +122,6 @@ class Num2Word_ES(Num2Word_EU):
def to_ordinal(self, value):
self.verify_ordinal(value)
try:
if value == 0:
text = ""
elif value <= 10:
@@ -158,18 +157,13 @@ class Num2Word_ES(Num2Word_EU):
# eg (12, 345) = divmod(12_345, 1_000)
high_part, low_part = divmod(value, dec)
cardinal = (
self.to_cardinal(high_part) if high_part != 1 else ""
)
cardinal = self.to_cardinal(high_part) if high_part != 1 else ""
text = (
"%s%s%s %s" % (cardinal, self.ords[dec], self.gender_stem,
self.to_ordinal(low_part))
)
else:
text = self.to_cardinal(value)
except KeyError:
text = self.to_cardinal(value)
raise
return text.strip()
def to_ordinal_num(self, value):