]>
git.rmz.io Git - dotfiles.git/blob - bin/starling.py
3 from datetime
import datetime
10 class FeedError(Exception):
13 def read_feed_item(i
):
15 date
= datetime
.strptime(i
["transactionTime"], "%Y-%m-%dT%H:%M:%S.%fZ")
16 amount
= i
["amount"]["minorUnits"] / 100
17 if i
["direction"] == "OUT":
19 payee
= i
["counterPartyName"]
20 reference
= i
.get("reference", payee
)
21 if outformat
== "csv":
22 print('{date:%Y-%m-%d},{amount},"{payee}","{description}","{notes}"'.format(date
=date
,
25 description
=reference
,
27 elif outformat
== "qif":
28 print("D{:%Y-%m-%d}".format(date
))
29 print("T{}".format(amount
))
30 print("P{}".format(payee
))
31 print("M{}".format(reference
))
32 print("#{}".format(i
['feedItemUid']))
35 raise FeedError(i
['feedItemUid'])
38 if __name__
== "__main__":
39 if outformat
== "qif":
41 print("NCurrent Accounts:Starling")
45 with open(sys
.argv
[1], 'r') if len(sys
.argv
) > 1 else sys
.stdin
as fp
:
47 for i
in data
.get('feedItems'):