Mercurial > louis > ofxstatement-us-hsbc
diff src/ofxstatement/plugins/sample.py @ 0:1f85ed8ed469
Iniitial commit of sample ofxstatement plugin
author | Andrey Lebedev <andrey@lebedev.lt> |
---|---|
date | Sat, 02 Nov 2013 14:26:03 +0200 |
parents | |
children | 05135d973356 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ofxstatement/plugins/sample.py Sat Nov 02 14:26:03 2013 +0200 @@ -0,0 +1,36 @@ +from ofxstatement.plugin import Plugin +from ofxstatement.parser import StatementParser +from ofxstatement.statement import StatementLine + + +class SamplePlugin(Plugin): + """Sample plugin (for developers only) + """ + + def getParser(self, filename): + return SampleParser(filename) + + +class SampleParser(StatementParser): + def __init__(self, filename): + self.filename = filename + + def parse(self): + """Main entry point for parsers + + super() implementation will call to split_records and parse_record to + process the file. + """ + with open(self.filename, "r") as f: + self.input = f + return super(SampleParser, self).parse() + + def split_records(self): + """Return iterable object consisting of a line per transaction + """ + return [] + + def parse_record(self, line): + """Parse given transaction line and return StatementLine object + """ + return StatementLine()