From ddb1ec724faf2ca84b5d959c831f7f55ec587504 Mon Sep 17 00:00:00 2001 From: Numerigraphe - Lionel Sausin Date: Mon, 21 Nov 2011 16:35:39 +0100 Subject: [PATCH] [IMP] rewrote the translation tbale lookup without downgrading strings to latin-1 bzr revid: ls@numerigraphe.fr-20111121153539-a060b20nvvf6x2c7 --- addons/l10n_fr_rib/bank.py | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/addons/l10n_fr_rib/bank.py b/addons/l10n_fr_rib/bank.py index ac67b536265..b1a285ef743 100644 --- a/addons/l10n_fr_rib/bank.py +++ b/addons/l10n_fr_rib/bank.py @@ -19,9 +19,6 @@ # ############################################################################## -import string -import unicodedata - import netsvc from osv import fields, osv from tools.translate import _ @@ -48,14 +45,10 @@ class res_partner_bank(osv.osv): bank_acc.acc_number) # Translate letters into numbers according to a specific table # (notice how s -> 2) - # Note: maketrans and translate work best with latin1 - that - # should not be a problem for RIB data - # XXX use dict((ord(a), b) for a, b in zip(intab, outtab)) - # and translate() - rib = rib.lower().encode('latin-1').translate( - string.maketrans(u'abcdefghijklmnopqrstuvwxyz', - u'12345678912345678923456789')) - # compute the key + table = dict((ord(a), b) for a, b in zip( + u'abcdefghijklmnopqrstuvwxyz', u'12345678912345678923456789')) + rib = rib.lower().translate(table) + # compute the key key = 97 - (100 * int(rib)) % 97 if int(bank_acc.key) != key: return False