[IMP] account_banking: moved check on SEPA countries from iban.__init__ to

iban.valid to ease tests
This commit is contained in:
Pieter J. Kersten
2010-02-12 19:04:33 +01:00
parent b26ec7eda5
commit 8c1decb163
2 changed files with 3 additions and 6 deletions

View File

@@ -277,12 +277,8 @@ class IBAN(str):
Sanity check: don't offer extensions unless the base is sound.
'''
super(IBAN, self).__init__()
# Rearrange position of country code and check digits
if self.countrycode not in self.countries:
self.BBAN_format = self.unknown_BBAN_format
raise Warning, \
'Don\'t know how to format BBAN for country %s' % \
self.countrycode
else:
self.BBAN_format = self.BBAN_formats[self.countrycode]
@@ -326,7 +322,8 @@ class IBAN(str):
Check if the string + check digits deliver a valid checksum
'''
_buffer = self[4:] + self[:4]
return int(base36_to_base10str(_buffer)) % 97 == 1
return self.countrycode in self.countries and \
int(base36_to_base10str(_buffer)) % 97 == 1
def __repr__(self):
'''