Arthur de Jong

Open Source / Free Software developer

summaryrefslogtreecommitdiffstats
path: root/getiban.py
diff options
context:
space:
mode:
authorArthur de Jong <arthur@arthurdejong.org>2011-08-19 10:22:13 +0200
committerArthur de Jong <arthur@arthurdejong.org>2011-08-19 10:22:13 +0200
commit881e8a6a2429b43180e1ece0148077bdb77c59d5 (patch)
treea68cb2dc12bd38f3d73528b9bb7ec705b5fe2093 /getiban.py
parent8dbcedd38baa7b04ae66fd4c1908b8eb2dddc613 (diff)
make source code layout follow PEP8 more
git-svn-id: http://arthurdejong.org/svn/python-stdnum/python-stdnum@76 9dea7c4f-944c-4273-ac1a-574ede026edc
Diffstat (limited to 'getiban.py')
-rwxr-xr-xgetiban.py19
1 files changed, 13 insertions, 6 deletions
diff --git a/getiban.py b/getiban.py
index 287c082..de18728 100755
--- a/getiban.py
+++ b/getiban.py
@@ -30,22 +30,26 @@ import re
# The place where the current version of IBAN_Registry.txt can be downloaded.
download_url = 'http://www.swift.com/dsp/resources/documents/IBAN_Registry.txt'
+
def splitlines(f):
"""Read lines from the TAB-delimited IBAN_Registry.txt file and return
a dictionary per read line. We clean up the values a bit because it
contains some junk."""
stripit = ' \t\n\r;:\'"'
- firstline = [ x.strip(stripit) for x in f.readline().lower().split('\t') ]
+ firstline = [x.strip(stripit) for x in f.readline().lower().split('\t')]
for line in f:
- yield dict(zip(firstline, [ x.strip(stripit) for x in line.split('\t') ]))
+ yield dict(zip(firstline, [x.strip(stripit)
+ for x in line.split('\t')]))
+
def get_country_codes(line):
"""Return the list of country codes this line has."""
# simplest case first
if len(line['country code as defined in iso 3166']) == 2:
- return [ line['country code as defined in iso 3166'] ]
+ return [line['country code as defined in iso 3166']]
# fall back to parsing the IBAN structure
- return [ x.strip()[:2] for x in line['iban structure'].split(',') ]
+ return [x.strip()[:2] for x in line['iban structure'].split(',')]
+
def parse(f):
"""Parse the specified file."""
@@ -54,11 +58,14 @@ def parse(f):
for line in splitlines(f):
for cc in get_country_codes(line):
# print country line
- print '%s country="%s" bban="%s"' % ( cc, line['name of country'], line['bban structure'])
+ print '%s country="%s" bban="%s"' % (
+ cc, line['name of country'], line['bban structure'])
# TODO: some countries have a fixed check digit value
# TODO: some countries have extra check digits
# TODO: use "Bank identifier position within the BBAN" field
- # to add labels to the ranges (Bank identifier and Branch Identifier)
+ # to add labels to the ranges (Bank identifier and Branch
+ # Identifier)
+
if __name__ == '__main__':
#f = open('IBAN_Registry.txt', 'r')