Created
August 23, 2013 10:29
-
-
Save ViktorStiskala/6317817 to your computer and use it in GitHub Desktop.
Revisions
-
ViktorStiskala created this gist
Aug 23, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ def _convert_to_iban(self, account): """ Convert czech account number to IBAN """ acc = self.RE_ACCOUNT.match(account) iban = 'CZ00{b}{ba:0>6}{a:0>10}'.format( ba=acc.group('ba') or 0, a=acc.group('a'), b=acc.group('b'), ) # convert IBAN letters into numbers crc = re.sub(r'[A-Z]', lambda m: str(ord(m.group(0)) - 55), iban[4:] + iban[:4]) # compute control digits digits = "{:0>2}".format(98 - int(crc) % 97) return iban[:2] + digits + iban[4:]