-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.py
30 lines (28 loc) · 1016 Bytes
/
example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import time
from swedishbanks import Swedbank, Nordea
templ = {'irc': {
'time': '[%s]',
'title': '[\x02%s\x02]',
'account': '%s: \x02%s\x02;',
'sum': 'Summa: \x02\x1f%s'
},
'plain': {
'title': '[%s]',
'account': '%s: %s;',
'sum': 'Summa: %s'
}
}
def printaccount(bank, name="BANK", template="plain"):
if 'time' in templ[template]:
print templ[template]['time'] % time.asctime().split()[3],
if 'title' in templ[template]:
print templ[template]['title'] % name,
for acc in bank.accounts:
print templ[template]['account'] % (acc[0].capitalize(), acc[1]),
if 'sum' in templ[template]:
print templ[template]['sum'] % sum([a[1] for a in bank.accounts])
if __name__ == "__main__":
b = Swedbank("19760518XXXX", "password")
printaccount(b, "SWEDBANK", "irc")
b = Nordea("19760518-XXXX", "password")
printaccount(b, "NORDEA", "plain")