Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Small fixes and cleanup.

* Use datetime instead of date for report's timestamp.
* Formatting fixed (newlines).
* Getter for aib.data, fixed aib.bye.
* Renamed ofx.parse to ofx.prettyprint.
  • Loading branch information...
commit 714ee4d770f61bf21ec02a3aa0eb321d6cb9d8b2 1 parent b573d3b
@yacoob authored
Showing with 23 additions and 27 deletions.
  1. +4 −1 aib2ofx/aib.py
  2. +3 −0  aib2ofx/cfg.py
  3. +16 −26 aib2ofx/ofx.py
View
5 aib2ofx/aib.py
@@ -117,7 +117,7 @@ def scrape(self):
account['available'] = amount;
account['currency'] = 'EUR';
account['bankId'] = 'AIB';
- account['reportDate'] = datetime.date.today();
+ account['reportDate'] = datetime.datetime.now();
self.data[account['accountId']] = account;
@@ -171,7 +171,10 @@ def scrape(self):
acc['balance'] = operations[-1]['balance'];
acc['operations'] = operations;
+ def getdata(self):
+ return self.data;
def bye(self):
+ br = self.br;
br.select_form(nr=1);
br.submit();
View
3  aib2ofx/cfg.py
@@ -14,6 +14,9 @@ def __init__(self, config_filename='~/.aib-sucker'):
def get_config(self):
return self.cfg;
+ def users(self):
+ return self.cfg.keys();
+
def __getitem__(self, name):
if self.cfg.has_key(name):
return self.cfg[name];
View
42 aib2ofx/ofx.py
@@ -9,8 +9,7 @@ def _toDate(d):
class ofx:
def __init__(self):
- self.opening = """
-OFXHEADER:100
+ self.opening = """OFXHEADER:100
DATA:OFXSGML
VERSION:102
SECURITY:NONE
@@ -26,56 +25,47 @@ def __init__(self):
<STATUS>
<CODE>0</CODE>
<SEVERITY>INFO</SEVERITY>
-</STATUS>
-
-<DTSERVER>%(reportDate)s</DTSERVER>
+</STATUS><DTSERVER>%(reportDate)s</DTSERVER>
<LANGUAGE>ENG</LANGUAGE>
</SONRS>
-</SIGNONMSGSRSV1>
-""";
+</SIGNONMSGSRSV1>""";
+
self.headers = {
'checking': """
<BANKMSGSRSV1>
<STMTTRNRS><TRNUID>1</TRNUID>
<STATUS><CODE>0</CODE><SEVERITY>INFO</SEVERITY></STATUS>
<STMTRS><CURDEF>%(currency)s</CURDEF>
-
<BANKACCTFROM><BANKID>%(bankId)s</BANKID>
<ACCTID>%(accountId)s</ACCTID>
<ACCTTYPE>CHECKING</ACCTTYPE>
-</BANKACCTFROM>
-""",
+</BANKACCTFROM>""",
'credit': """
<CREDITCARDMSGSRSV1>
<CCSTMTTRNRS><TRNUID>1</TRNUID>
<STATUS><CODE>0</CODE><SEVERITY>INFO</SEVERITY></STATUS>
<CCSTMTRS><CURDEF>%(currency)s</CURDEF>
-
<CCACCTFROM>
<ACCTID>%(accountId)s</ACCTID>
-</CCACCTFROM>
-""",
+</CCACCTFROM>""",
};
+
self.transactions_header = """
<BANKTRANLIST>
<DTSTART>%(firstDate)s</DTSTART>
-<DTEND>%(lastDate)s</DTEND>
-""";
+<DTEND>%(lastDate)s</DTEND>""";
+
self.closing = {
- 'checking': """
-</BANKTRANLIST>
+ 'checking': """</BANKTRANLIST>
<LEDGERBAL><BALAMT>%(balance)s</BALAMT><DTASOF>%(reportDate)s</DTASOF></LEDGERBAL>
<AVAILBAL><BALAMT>%(available)s</BALAMT><DTASOF>%(reportDate)s</DTASOF></AVAILBAL>
-</STMTRS></STMTTRNRS></BANKMSGSRSV1></OFX>
-""",
- 'credit': """
-</BANKTRANLIST>
+</STMTRS></STMTTRNRS></BANKMSGSRSV1></OFX>""",
+ 'credit': """</BANKTRANLIST>
<LEDGERBAL><BALAMT>%(available)s</BALAMT><DTASOF>%(reportDate)s</DTASOF></LEDGERBAL>
-</CCSTMTRS></CCSTMTTRNRS></CREDITCARDMSGSRSV1></OFX>
-""",
+</CCSTMTRS></CCSTMTTRNRS></CREDITCARDMSGSRSV1></OFX>""",
};
- self.single_transaction = """
-<STMTTRN>
+
+ self.single_transaction = """<STMTTRN>
<TRNTYPE>%(type)s</TRNTYPE>
<DTPOSTED>%(timestamp)s</DTPOSTED>
<TRNAMT>%(amount)s</TRNAMT>
@@ -85,7 +75,7 @@ def __init__(self):
""";
- def parse(self, input):
+ def prettyprint(self, input):
ofx = '';
data = {};
Please sign in to comment.
Something went wrong with that request. Please try again.