Skip to content

Commit eef5b03

Browse files
ohduranerozqba
authored andcommitted
Updates accents on céntimos in Spanish (#240)
* Updates accents on céntimos in Spanish * Update test_es.py * Update test_es.py * fix tests * fix encoding * Update tox.ini * Update test_cli.py * Update test_cli.py * Update test_cli.py * Update lang_AR.py flake-8 compliant * Update test_cli.py flake8 compliant * Update test_cli.py * Update test_cli.py
1 parent aa9b882 commit eef5b03

File tree

5 files changed

+51
-46
lines changed

5 files changed

+51
-46
lines changed

num2words/lang_AR.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,11 @@ def process_arabic_group(self, group_number, group_level,
188188
ones = tens % 10
189189
tens = (tens / 10) - 2
190190
if ones > 0:
191-
if ret_val is not "" and tens < 4:
191+
if ret_val != "" and tens < 4:
192192
ret_val += " و "
193193

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

198198
ret_val += self.arabicTens[int(tens)]
@@ -226,17 +226,17 @@ def convert_to_arabic(self):
226226
self.process_arabic_group(number_to_process,
227227
group,
228228
Decimal(floor(temp_number)))
229-
if group_description is not '':
229+
if group_description != '':
230230
if group > 0:
231-
if ret_val is not "":
231+
if ret_val != "":
232232
ret_val = "{} و {}".format("", ret_val)
233233
if number_to_process != 2:
234234
if number_to_process % 100 != 1:
235235
if 3 <= number_to_process <= 10:
236236
ret_val = "{} {}".format(
237237
self.arabicPluralGroups[group], ret_val)
238238
else:
239-
if ret_val is not "":
239+
if ret_val != "":
240240
ret_val = "{} {}".format(
241241
self.arabicAppendedGroup[group],
242242
ret_val)
@@ -250,7 +250,7 @@ def convert_to_arabic(self):
250250
ret_val = "{} {}".format(group_description, ret_val)
251251
group += 1
252252
formatted_number = ""
253-
if self.arabicPrefixText is not "":
253+
if self.arabicPrefixText != "":
254254
formatted_number += "{} ".format(self.arabicPrefixText)
255255
formatted_number += ret_val
256256
if self.integer_value != 0:
@@ -288,7 +288,7 @@ def convert_to_arabic(self):
288288
elif 11 <= remaining100 <= 99:
289289
formatted_number += self.currency_subunit[3]
290290

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

294294
return formatted_number
@@ -299,10 +299,10 @@ def validate_number(self, number):
299299
return number
300300

301301
def set_currency_prefer(self, currency):
302-
if currency is 'EGP':
302+
if currency == 'EGP':
303303
self.currency_unit = CURRENCY_EGP[0]
304304
self.currency_subunit = CURRENCY_EGP[1]
305-
elif currency is 'KWD':
305+
elif currency == 'KWD':
306306
self.currency_unit = CURRENCY_KWD[0]
307307
self.currency_subunit = CURRENCY_KWD[1]
308308
else:

num2words/lang_ES.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222

2323
class Num2Word_ES(Num2Word_EU):
2424
CURRENCY_FORMS = {
25-
'EUR': (('euro', 'euros'), ('centimo', 'centimos')),
26-
'ESP': (('peseta', 'pesetas'), ('centimo', 'centimos')),
27-
'USD': (('dolar', 'dolares'), ('centavo', 'centavos')),
28-
'PEN': (('sol', 'soles'), ('centimo', 'centimos')),
25+
'EUR': (('euro', 'euros'), ('céntimo', 'céntimos')),
26+
'ESP': (('peseta', 'pesetas'), ('céntimo', 'céntimos')),
27+
'USD': (('dolar', 'dólares'), ('centavo', 'centavos')),
28+
'PEN': (('sol', 'soles'), ('céntimo', 'céntimos')),
2929
}
3030

3131
# //CHECK: Is this sufficient??

tests/test_cli.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ def test_cli_with_lang_to(self):
106106
output = self.cli.run_cmd(150.55, '--lang', 'es', '--to', 'currency')
107107
self.assertEqual(output.return_code, 0)
108108
self.assertEqual(
109-
output.out.strip(),
110-
"ciento cincuenta euros con cincuenta y cinco centimos"
109+
(output.out.decode('utf-8') if hasattr(output.out, 'decode') else
110+
output.out).strip(),
111+
"ciento cincuenta euros con cincuenta y cinco céntimos"
111112
)

tests/test_es.py

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -112,47 +112,47 @@
112112
)
113113

114114
TEST_CASES_TO_CURRENCY = (
115-
(1.00, 'un euro con cero centimos'),
116-
(2.00, 'dos euros con cero centimos'),
117-
(8.00, 'ocho euros con cero centimos'),
118-
(12.00, 'doce euros con cero centimos'),
119-
(21.00, 'veintiun euros con cero centimos'),
120-
(81.25, 'ochenta y un euros con veinticinco centimos'),
121-
(350.90, 'trescientos cincuenta euros con noventa centimos'),
122-
(100.00, 'cien euros con cero centimos'),
115+
(1.00, 'un euro con cero céntimos'),
116+
(2.00, 'dos euros con cero céntimos'),
117+
(8.00, 'ocho euros con cero céntimos'),
118+
(12.00, 'doce euros con cero céntimos'),
119+
(21.00, 'veintiun euros con cero céntimos'),
120+
(81.25, 'ochenta y un euros con veinticinco céntimos'),
121+
(350.90, 'trescientos cincuenta euros con noventa céntimos'),
122+
(100.00, 'cien euros con cero céntimos'),
123123
)
124124

125125
TEST_CASES_TO_CURRENCY_ESP = (
126-
(1.00, 'un peseta con cero centimos'),
127-
(2.00, 'dos pesetas con cero centimos'),
128-
(8.00, 'ocho pesetas con cero centimos'),
129-
(12.00, 'doce pesetas con cero centimos'),
130-
(21.00, 'veintiun pesetas con cero centimos'),
131-
(81.25, 'ochenta y un pesetas con veinticinco centimos'),
132-
(350.90, 'trescientos cincuenta pesetas con noventa centimos'),
133-
(100.00, 'cien pesetas con cero centimos'),
126+
(1.00, 'un peseta con cero céntimos'),
127+
(2.00, 'dos pesetas con cero céntimos'),
128+
(8.00, 'ocho pesetas con cero céntimos'),
129+
(12.00, 'doce pesetas con cero céntimos'),
130+
(21.00, 'veintiun pesetas con cero céntimos'),
131+
(81.25, 'ochenta y un pesetas con veinticinco céntimos'),
132+
(350.90, 'trescientos cincuenta pesetas con noventa céntimos'),
133+
(100.00, 'cien pesetas con cero céntimos'),
134134
)
135135

136136
TEST_CASES_TO_CURRENCY_USD = (
137137
(1.00, 'un dolar con cero centavos'),
138-
(2.00, 'dos dolares con cero centavos'),
139-
(8.00, 'ocho dolares con cero centavos'),
140-
(12.00, 'doce dolares con cero centavos'),
141-
(21.00, 'veintiun dolares con cero centavos'),
142-
(81.25, 'ochenta y un dolares con veinticinco centavos'),
143-
(350.90, 'trescientos cincuenta dolares con noventa centavos'),
144-
(100.00, 'cien dolares con cero centavos'),
138+
(2.00, 'dos dólares con cero centavos'),
139+
(8.00, 'ocho dólares con cero centavos'),
140+
(12.00, 'doce dólares con cero centavos'),
141+
(21.00, 'veintiun dólares con cero centavos'),
142+
(81.25, 'ochenta y un dólares con veinticinco centavos'),
143+
(350.90, 'trescientos cincuenta dólares con noventa centavos'),
144+
(100.00, 'cien dólares con cero centavos'),
145145
)
146146

147147
TEST_CASES_TO_CURRENCY_PEN = (
148-
(1.00, 'un sol con cero centimos'),
149-
(2.00, 'dos soles con cero centimos'),
150-
(8.00, 'ocho soles con cero centimos'),
151-
(12.00, 'doce soles con cero centimos'),
152-
(21.00, 'veintiun soles con cero centimos'),
153-
(81.25, 'ochenta y un soles con veinticinco centimos'),
154-
(350.90, 'trescientos cincuenta soles con noventa centimos'),
155-
(100.00, 'cien soles con cero centimos'),
148+
(1.00, 'un sol con cero céntimos'),
149+
(2.00, 'dos soles con cero céntimos'),
150+
(8.00, 'ocho soles con cero céntimos'),
151+
(12.00, 'doce soles con cero céntimos'),
152+
(21.00, 'veintiun soles con cero céntimos'),
153+
(81.25, 'ochenta y un soles con veinticinco céntimos'),
154+
(350.90, 'trescientos cincuenta soles con noventa céntimos'),
155+
(100.00, 'cien soles con cero céntimos'),
156156
)
157157

158158

tox.ini

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,7 @@ deps =
2626
delegator.py
2727
commands =
2828
isort --check-only --recursive --diff num2words tests
29+
30+
[testenv:py27]
31+
setenv =
32+
PYTHONIOENCODING = UTF-8

0 commit comments

Comments
 (0)