diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 47068a08..00000000 Binary files a/.DS_Store and /dev/null differ diff --git a/README.rst b/README.rst index e89310aa..2531f84b 100644 --- a/README.rst +++ b/README.rst @@ -80,8 +80,8 @@ Besides the numerical argument, there are two main optional arguments, ``to:`` a * ``ar`` (Arabic) * ``az`` (Azerbaijani) * ``cs`` (Czech) -* ``de`` (German) * ``da`` (Danish) +* ``de`` (German) * ``en_GB`` (English - Great Britain) * ``en_IN`` (English - India) * ``en_NG`` (English - Nigeria) @@ -102,9 +102,9 @@ Besides the numerical argument, there are two main optional arguments, ``to:`` a * ``is`` (Icelandic) * ``it`` (Italian) * ``ja`` (Japanese) +* ``kk`` (Kazakh) * ``kn`` (Kannada) * ``ko`` (Korean) -* ``kk`` (Kazakh) * ``lt`` (Lithuanian) * ``lv`` (Latvian) * ``no`` (Norwegian) diff --git a/bin/num2words b/bin/num2words index 06ff0443..8f87533d 100755 --- a/bin/num2words +++ b/bin/num2words @@ -50,9 +50,12 @@ Examples: """ from __future__ import print_function, unicode_literals + import os import sys + from docopt import docopt + import num2words __version__ = "0.5.12" diff --git a/num2words/__init__.py b/num2words/__init__.py index 79d6f3da..b4a81a36 100644 --- a/num2words/__init__.py +++ b/num2words/__init__.py @@ -17,56 +17,14 @@ from __future__ import unicode_literals -from . import ( - lang_AM, - lang_AR, - lang_AZ, - lang_CS, - lang_DA, - lang_DE, - lang_EN, - lang_EN_IN, - lang_EN_NG, - lang_EO, - lang_ES, - lang_ES_CO, - lang_ES_GT, - lang_ES_NI, - lang_ES_VE, - lang_FA, - lang_FI, - lang_FR, - lang_FR_BE, - lang_FR_CH, - lang_FR_DZ, - lang_HE, - lang_HU, - lang_ID, - lang_IS, - lang_IT, - lang_JA, - lang_KK, - lang_KN, - lang_KO, - lang_LT, - lang_LV, - lang_NL, - lang_NO, - lang_PL, - lang_PT, - lang_PT_BR, - lang_RO, - lang_RU, - lang_SL, - lang_SR, - lang_SV, - lang_TE, - lang_TG, - lang_TH, - lang_TR, - lang_UK, - lang_VI, -) +from . import (lang_AM, lang_AR, lang_AZ, lang_CS, lang_DA, lang_DE, lang_EN, + lang_EN_IN, lang_EN_NG, lang_EO, lang_ES, lang_ES_CO, + lang_ES_GT, lang_ES_NI, lang_ES_VE, lang_FA, lang_FI, lang_FR, + lang_FR_BE, lang_FR_CH, lang_FR_DZ, lang_HE, lang_HU, lang_ID, + lang_IS, lang_IT, lang_JA, lang_KK, lang_KN, lang_KO, lang_LT, + lang_LV, lang_NL, lang_NO, lang_PL, lang_PT, lang_PT_BR, + lang_RO, lang_RU, lang_SL, lang_SR, lang_SV, lang_TE, lang_TG, + lang_TH, lang_TR, lang_UK, lang_VI) CONVERTER_CLASSES = { "am": lang_AM.Num2Word_AM(), diff --git a/num2words/lang_CS.py b/num2words/lang_CS.py index 836b083f..246e547a 100644 --- a/num2words/lang_CS.py +++ b/num2words/lang_CS.py @@ -99,9 +99,8 @@ def to_cardinal(self, number): if "." in n: left, right = n.split(".") leading_zero_count = len(right) - len(right.lstrip("0")) - decimal_part = (ZERO[0] + " ") * leading_zero_count + self._int2word( - int(right) - ) + leading_zeros = (ZERO[0] + " ") * leading_zero_count + decimal_part = leading_zeros + self._int2word(int(right)) return "%s %s %s" % ( self._int2word(int(left)), self.pointword, diff --git a/num2words/lang_DA.py b/num2words/lang_DA.py index d7e2f03c..b3da892b 100644 --- a/num2words/lang_DA.py +++ b/num2words/lang_DA.py @@ -147,7 +147,10 @@ def to_ordinal_num(self, value): def to_currency(self, val, longval=True): if val // 100 == 1 or val == 1: ret = self.to_splitnum( - val, hightxt="kr", lowtxt="\xf8re", jointxt="og", longval=longval + val, hightxt="kr", + lowtxt="\xf8re", + jointxt="og", + longval=longval ) return "en " + ret[3:] return self.to_splitnum( diff --git a/tests/test_cs.py b/tests/test_cs.py index 974eb2bb..bde0bf29 100644 --- a/tests/test_cs.py +++ b/tests/test_cs.py @@ -33,12 +33,14 @@ def test_cardinal(self): self.assertEqual(num2words(1001, lang="cs"), "tisíc jedna") self.assertEqual(num2words(2012, lang="cs"), "dva tisíce dvanáct") self.assertEqual(num2words(10.02, lang="cs"), "deset celá nula dva") - self.assertEqual(num2words(15.007, lang="cs"), "patnáct celá nula nula sedm") + self.assertEqual(num2words(15.007, lang="cs"), + "patnáct celá nula nula sedm") self.assertEqual( num2words(12519.85, lang="cs"), - "dvanáct tisíc pětset devatenáct celá osmdesát pět", + "dvanáct tisíc pětset devatenáct celá osmdesát pět" ) - self.assertEqual(num2words(123.50, lang="cs"), "sto dvacet tři celá pět") + self.assertEqual(num2words(123.50, lang="cs"), + "sto dvacet tři celá pět") self.assertEqual( num2words(1234567890, lang="cs"), "miliarda dvěstě třicet čtyři miliony pětset šedesát " @@ -86,11 +88,19 @@ def test_currency(self): "tisíc dvěstě třicet čtyři koruny, padesát šest haléřů", ) self.assertEqual( - num2words(101.11, lang="cs", to="currency", currency="EUR", separator=" a"), + num2words(101.11, + lang="cs", + to="currency", + currency="EUR", + separator=" a"), "sto jedna euro a jedenáct centů", ) self.assertEqual( - num2words(101.21, lang="cs", to="currency", currency="CZK", separator=" a"), + num2words(101.21, + lang="cs", + to="currency", + currency="CZK", + separator=" a"), "sto jedna korun a dvacet jedna haléřů", ) self.assertEqual( @@ -98,7 +108,11 @@ def test_currency(self): "mínus dvanáct tisíc pětset devatenáct euro, 85 centů", ) self.assertEqual( - num2words(123.50, lang="cs", to="currency", currency="CZK", separator=" a"), + num2words(123.50, + lang="cs", + to="currency", + currency="CZK", + separator=" a"), "sto dvacet tři koruny a padesát haléřů", ) self.assertEqual( diff --git a/tests/test_kk.py b/tests/test_kk.py index f164d8f7..2ad37b09 100644 --- a/tests/test_kk.py +++ b/tests/test_kk.py @@ -28,7 +28,8 @@ def test_to_cardinal(self): self.assertEqual(num2words(7, lang="kk"), "жеті") self.assertEqual(num2words(23, lang="kk"), "жиырма үш") self.assertEqual(num2words(145, lang="kk"), "жүз қырық бес") - self.assertEqual(num2words(2869, lang="kk"), "екі мың сегіз жүз алпыс тоғыз") + self.assertEqual(num2words(2869, lang="kk"), + "екі мың сегіз жүз алпыс тоғыз") self.assertEqual( num2words(-789000125, lang="kk"), "минус жеті жүз сексен тоғыз миллион жүз жиырма бес", @@ -42,7 +43,8 @@ def test_to_cardinal_floats(self): self.assertEqual(num2words(0.7, lang="kk"), "нөл бүтін жеті") self.assertEqual(num2words(1.73, lang="kk"), "бір бүтін жетпіс үш") self.assertEqual(num2words(10.02, lang="kk"), "он бүтін нөл екі") - self.assertEqual(num2words(15.007, lang="kk"), "он бес бүтін нөл нөл жеті") + self.assertEqual(num2words(15.007, lang="kk"), + "он бес бүтін нөл нөл жеті") def test_to_ordinal(self): with self.assertRaises(NotImplementedError):