Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def setUp(self):
super(Num2WordsPTTest, self).setUp()
self.n2w = Num2Word_PT()
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301 USA
from __future__ import division, unicode_literals
import re
from . import lang_PT
class Num2Word_PT_BR(lang_PT.Num2Word_PT):
def set_high_numwords(self, high):
max = 3 + 3*len(high)
for word, n in zip(high, range(max, 3, -3)):
self.cards[10**n] = word + "ilhão"
def setup(self):
super(Num2Word_PT_BR, self).setup()
self.low_numwords[1] = 'dezenove'
self.low_numwords[3] = 'dezessete'
self.low_numwords[4] = 'dezesseis'
self.thousand_separators = {
3: "milésimo",
6: "milionésimo",
9: "bilionésimo",
'es_VE': lang_ES_VE.Num2Word_ES_VE(),
'id': lang_ID.Num2Word_ID(),
'ja': lang_JA.Num2Word_JA(),
'kn': lang_KN.Num2Word_KN(),
'ko': lang_KO.Num2Word_KO(),
'kz': lang_KZ.Num2Word_KZ(),
'lt': lang_LT.Num2Word_LT(),
'lv': lang_LV.Num2Word_LV(),
'pl': lang_PL.Num2Word_PL(),
'ro': lang_RO.Num2Word_RO(),
'ru': lang_RU.Num2Word_RU(),
'sl': lang_SL.Num2Word_SL(),
'sr': lang_SR.Num2Word_SR(),
'no': lang_NO.Num2Word_NO(),
'dk': lang_DK.Num2Word_DK(),
'pt': lang_PT.Num2Word_PT(),
'pt_BR': lang_PT_BR.Num2Word_PT_BR(),
'he': lang_HE.Num2Word_HE(),
'it': lang_IT.Num2Word_IT(),
'vi': lang_VI.Num2Word_VI(),
'th': lang_TH.Num2Word_TH(),
'tr': lang_TR.Num2Word_TR(),
'nl': lang_NL.Num2Word_NL(),
'uk': lang_UK.Num2Word_UK(),
'te': lang_TE.Num2Word_TE(),
'hu': lang_HU.Num2Word_HU()
}
CONVERTES_TYPES = ['cardinal', 'ordinal', 'ordinal_num', 'year', 'currency']
def to_cardinal(self, value):
result = super(Num2Word_PT, self).to_cardinal(value)
# Transforms "mil e cento e catorze" into "mil cento e catorze"
# Transforms "cem milhões e duzentos mil e duzentos e dez" em "cem
# milhões duzentos mil duzentos e dez" but "cem milhões e duzentos
# mil e duzentos" in "cem milhões duzentos mil e duzentos" and not in
# "cem milhões duzentos mil duzentos"
for ext in (
'mil', 'milhão', 'milhões', 'mil milhões',
'bilião', 'biliões', 'mil biliões'):
if re.match('.*{} e \\w*entos? (?=.*e)'.format(ext), result):
result = result.replace(
'{} e'.format(ext), '{}'.format(ext)
)
return result