mirror of
https://github.com/bblaz/num2words.git
synced 2025-12-06 06:42:25 +00:00
Convert to single codebase for py2 and py3
No more 2to3. Also, added tox config for easy cross-python testing.
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
# MA 02110-1301 USA
|
||||
|
||||
from __future__ import division, unicode_literals
|
||||
from __future__ import division, unicode_literals, print_function
|
||||
from . import lang_EU
|
||||
|
||||
class Num2Word_EN(lang_EU.Num2Word_EU):
|
||||
@@ -47,7 +47,9 @@ class Num2Word_EN(lang_EU.Num2Word_EU):
|
||||
"twelve" : "twelfth" }
|
||||
|
||||
|
||||
def merge(self, (ltext, lnum), (rtext, rnum)):
|
||||
def merge(self, lpair, rpair):
|
||||
ltext, lnum = lpair
|
||||
rtext, rnum = rpair
|
||||
if lnum == 1 and rnum < 100:
|
||||
return (rtext, rnum)
|
||||
elif 100 > lnum > rnum :
|
||||
@@ -68,9 +70,9 @@ class Num2Word_EN(lang_EU.Num2Word_EU):
|
||||
lastword = self.ords[lastword]
|
||||
except KeyError:
|
||||
if lastword[-1] == "y":
|
||||
lastword = lastword[:-1] + "ie"
|
||||
lastword = lastword[:-1] + "ie"
|
||||
lastword += "th"
|
||||
lastwords[-1] = self.title(lastword)
|
||||
lastwords[-1] = self.title(lastword)
|
||||
outwords[-1] = "-".join(lastwords)
|
||||
return " ".join(outwords)
|
||||
|
||||
@@ -105,9 +107,9 @@ def main():
|
||||
n2w.test(val)
|
||||
n2w.test(1325325436067876801768700107601001012212132143210473207540327057320957032975032975093275093275093270957329057320975093272950730)
|
||||
for val in [1,120,1000,1120,1800, 1976,2000,2010,2099,2171]:
|
||||
print val, "is", n2w.to_currency(val)
|
||||
print val, "is", n2w.to_year(val)
|
||||
|
||||
print(val, "is", n2w.to_currency(val))
|
||||
print(val, "is", n2w.to_year(val))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user