Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates accents on céntimos in Spanish #240

Merged
merged 13 commits into from
Feb 12, 2019
18 changes: 9 additions & 9 deletions num2words/lang_AR.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,11 @@ def process_arabic_group(self, group_number, group_level,
ones = tens % 10
tens = (tens / 10) - 2
if ones > 0:
if ret_val is not "" and tens < 4:
if ret_val != "" and tens < 4:
ret_val += " و "

ret_val += self.digit_feminine_status(ones, group_level)
if ret_val is not "" and ones != 0:
if ret_val != "" and ones != 0:
ret_val += " و "

ret_val += self.arabicTens[int(tens)]
Expand Down Expand Up @@ -226,17 +226,17 @@ def convert_to_arabic(self):
self.process_arabic_group(number_to_process,
group,
Decimal(floor(temp_number)))
if group_description is not '':
if group_description != '':
if group > 0:
if ret_val is not "":
if ret_val != "":
ret_val = "{} و {}".format("", ret_val)
if number_to_process != 2:
if number_to_process % 100 != 1:
if 3 <= number_to_process <= 10:
ret_val = "{} {}".format(
self.arabicPluralGroups[group], ret_val)
else:
if ret_val is not "":
if ret_val != "":
ret_val = "{} {}".format(
self.arabicAppendedGroup[group],
ret_val)
Expand All @@ -250,7 +250,7 @@ def convert_to_arabic(self):
ret_val = "{} {}".format(group_description, ret_val)
group += 1
formatted_number = ""
if self.arabicPrefixText is not "":
if self.arabicPrefixText != "":
formatted_number += "{} ".format(self.arabicPrefixText)
formatted_number += ret_val
if self.integer_value != 0:
Expand Down Expand Up @@ -288,7 +288,7 @@ def convert_to_arabic(self):
elif 11 <= remaining100 <= 99:
formatted_number += self.currency_subunit[3]

if self.arabicSuffixText is not "":
if self.arabicSuffixText != "":
formatted_number += " {}".format(self.arabicSuffixText)

return formatted_number
Expand All @@ -299,10 +299,10 @@ def validate_number(self, number):
return number

def set_currency_prefer(self, currency):
if currency is 'EGP':
if currency == 'EGP':
self.currency_unit = CURRENCY_EGP[0]
self.currency_subunit = CURRENCY_EGP[1]
elif currency is 'KWD':
elif currency == 'KWD':
self.currency_unit = CURRENCY_KWD[0]
self.currency_subunit = CURRENCY_KWD[1]
else:
Expand Down
8 changes: 4 additions & 4 deletions num2words/lang_ES.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@

class Num2Word_ES(Num2Word_EU):
CURRENCY_FORMS = {
'EUR': (('euro', 'euros'), ('centimo', 'centimos')),
'ESP': (('peseta', 'pesetas'), ('centimo', 'centimos')),
'USD': (('dolar', 'dolares'), ('centavo', 'centavos')),
'PEN': (('sol', 'soles'), ('centimo', 'centimos')),
'EUR': (('euro', 'euros'), ('céntimo', 'céntimos')),
'ESP': (('peseta', 'pesetas'), ('céntimo', 'céntimos')),
'USD': (('dolar', 'dólares'), ('centavo', 'centavos')),
'PEN': (('sol', 'soles'), ('céntimo', 'céntimos')),
}

# //CHECK: Is this sufficient??
Expand Down
5 changes: 3 additions & 2 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ def test_cli_with_lang_to(self):
output = self.cli.run_cmd(150.55, '--lang', 'es', '--to', 'currency')
self.assertEqual(output.return_code, 0)
self.assertEqual(
output.out.strip(),
"ciento cincuenta euros con cincuenta y cinco centimos"
(output.out.decode('utf-8') if hasattr(output.out, 'decode') else
output.out).strip(),
"ciento cincuenta euros con cincuenta y cinco céntimos"
)
62 changes: 31 additions & 31 deletions tests/test_es.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,47 +112,47 @@
)

TEST_CASES_TO_CURRENCY = (
(1.00, 'un euro con cero centimos'),
(2.00, 'dos euros con cero centimos'),
(8.00, 'ocho euros con cero centimos'),
(12.00, 'doce euros con cero centimos'),
(21.00, 'veintiun euros con cero centimos'),
(81.25, 'ochenta y un euros con veinticinco centimos'),
(350.90, 'trescientos cincuenta euros con noventa centimos'),
(100.00, 'cien euros con cero centimos'),
(1.00, 'un euro con cero céntimos'),
(2.00, 'dos euros con cero céntimos'),
(8.00, 'ocho euros con cero céntimos'),
(12.00, 'doce euros con cero céntimos'),
(21.00, 'veintiun euros con cero céntimos'),
(81.25, 'ochenta y un euros con veinticinco céntimos'),
(350.90, 'trescientos cincuenta euros con noventa céntimos'),
(100.00, 'cien euros con cero céntimos'),
)

TEST_CASES_TO_CURRENCY_ESP = (
(1.00, 'un peseta con cero centimos'),
(2.00, 'dos pesetas con cero centimos'),
(8.00, 'ocho pesetas con cero centimos'),
(12.00, 'doce pesetas con cero centimos'),
(21.00, 'veintiun pesetas con cero centimos'),
(81.25, 'ochenta y un pesetas con veinticinco centimos'),
(350.90, 'trescientos cincuenta pesetas con noventa centimos'),
(100.00, 'cien pesetas con cero centimos'),
(1.00, 'un peseta con cero céntimos'),
(2.00, 'dos pesetas con cero céntimos'),
(8.00, 'ocho pesetas con cero céntimos'),
(12.00, 'doce pesetas con cero céntimos'),
(21.00, 'veintiun pesetas con cero céntimos'),
(81.25, 'ochenta y un pesetas con veinticinco céntimos'),
(350.90, 'trescientos cincuenta pesetas con noventa céntimos'),
(100.00, 'cien pesetas con cero céntimos'),
)

TEST_CASES_TO_CURRENCY_USD = (
(1.00, 'un dolar con cero centavos'),
(2.00, 'dos dolares con cero centavos'),
(8.00, 'ocho dolares con cero centavos'),
(12.00, 'doce dolares con cero centavos'),
(21.00, 'veintiun dolares con cero centavos'),
(81.25, 'ochenta y un dolares con veinticinco centavos'),
(350.90, 'trescientos cincuenta dolares con noventa centavos'),
(100.00, 'cien dolares con cero centavos'),
(2.00, 'dos dólares con cero centavos'),
(8.00, 'ocho dólares con cero centavos'),
(12.00, 'doce dólares con cero centavos'),
(21.00, 'veintiun dólares con cero centavos'),
(81.25, 'ochenta y un dólares con veinticinco centavos'),
(350.90, 'trescientos cincuenta dólares con noventa centavos'),
(100.00, 'cien dólares con cero centavos'),
)

TEST_CASES_TO_CURRENCY_PEN = (
(1.00, 'un sol con cero centimos'),
(2.00, 'dos soles con cero centimos'),
(8.00, 'ocho soles con cero centimos'),
(12.00, 'doce soles con cero centimos'),
(21.00, 'veintiun soles con cero centimos'),
(81.25, 'ochenta y un soles con veinticinco centimos'),
(350.90, 'trescientos cincuenta soles con noventa centimos'),
(100.00, 'cien soles con cero centimos'),
(1.00, 'un sol con cero céntimos'),
(2.00, 'dos soles con cero céntimos'),
(8.00, 'ocho soles con cero céntimos'),
(12.00, 'doce soles con cero céntimos'),
(21.00, 'veintiun soles con cero céntimos'),
(81.25, 'ochenta y un soles con veinticinco céntimos'),
(350.90, 'trescientos cincuenta soles con noventa céntimos'),
(100.00, 'cien soles con cero céntimos'),
)


Expand Down
4 changes: 4 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,7 @@ deps =
delegator.py
commands =
isort --check-only --recursive --diff num2words tests

[testenv:py27]
setenv =
PYTHONIOENCODING = UTF-8