# HG changeset patch # User Andrey Lebedev # Date 1383395163 -7200 # Node ID 1f85ed8ed469d2570cb7e109b9e49b05310b1999 Iniitial commit of sample ofxstatement plugin diff -r 000000000000 -r 1f85ed8ed469 .gitignore --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.gitignore Sat Nov 02 14:26:03 2013 +0200 @@ -0,0 +1,12 @@ +*.pyc +*.swp +develop-eggs +dist +src/*.egg-info +tags +build +eggs +.venv +.project +.pydevproject +*.sublime* diff -r 000000000000 -r 1f85ed8ed469 MANIFEST.in --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MANIFEST.in Sat Nov 02 14:26:03 2013 +0200 @@ -0,0 +1,1 @@ +include README.rst diff -r 000000000000 -r 1f85ed8ed469 Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Makefile Sat Nov 02 14:26:03 2013 +0200 @@ -0,0 +1,7 @@ +PYTHON=.venv/bin/python + +all: PYTHON + +PYTHON: setup.py + virtualenv -p python3 --no-site-packages .venv + $(PYTHON) setup.py develop \ No newline at end of file diff -r 000000000000 -r 1f85ed8ed469 README.rst --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/README.rst Sat Nov 02 14:26:03 2013 +0200 @@ -0,0 +1,17 @@ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Sample plugin for ofxstatement +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +This project provides a boilerplate for custom plugins for ofxstatement. + +`ofxstatement`_ is a tool to convert proprietary bank statement to OFX format, +suitable for importing to GnuCash. Plugin for ofxstatement parses a +particular proprietary bank statement format and produces common data +structure, that is then formatted into an OFX file. + +.. _ofxstatement: https://github.com/kedder/ofxstatement + + +Users of ofxstatement have developed several plugins for their banks. They are +listed on main `ofxstatement`_ site. If your bank is missing, you can develop +your own plugin. diff -r 000000000000 -r 1f85ed8ed469 setup.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/setup.py Sat Nov 02 14:26:03 2013 +0200 @@ -0,0 +1,40 @@ +#!/usr/bin/python3 +"""Setup +""" +from setuptools import find_packages +from distutils.core import setup + +version = "0.0.1" + +with open('README.rst') as f: + long_description = f.read() + +setup(name='ofxstatement-sample', + version=version, + author="Andrey Lebedev", + author_email="andrey@lebedev.lt", + url="https://github.com/kedder/ofxstatement", + description=("Sample plugin for ofxstatement"), + long_description=long_description, + license="GPLv3", + keywords=["ofx", "banking", "statement"], + classifiers=[ + 'Development Status :: 3 - Alpha', + 'Programming Language :: Python :: 3', + 'Natural Language :: English', + 'Topic :: Office/Business :: Financial :: Accounting', + 'Topic :: Utilities', + 'Environment :: Console', + 'Operating System :: OS Independent', + 'License :: OSI Approved :: GNU Affero General Public License v3'], + packages=find_packages('src'), + package_dir={'': 'src'}, + namespace_packages=["ofxstatement", "ofxstatement.plugins"], + entry_points={ + 'ofxstatement': + ['sample = ofxstatement.plugins.sample:SamplePlugin'] + }, + install_requires=['ofxstatement'], + include_package_data=True, + zip_safe=True + ) diff -r 000000000000 -r 1f85ed8ed469 src/ofxstatement/__init__.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ofxstatement/__init__.py Sat Nov 02 14:26:03 2013 +0200 @@ -0,0 +1,1 @@ +__import__('pkg_resources').declare_namespace(__name__) diff -r 000000000000 -r 1f85ed8ed469 src/ofxstatement/plugins/__init__.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ofxstatement/plugins/__init__.py Sat Nov 02 14:26:03 2013 +0200 @@ -0,0 +1,1 @@ +__import__('pkg_resources').declare_namespace(__name__) diff -r 000000000000 -r 1f85ed8ed469 src/ofxstatement/plugins/sample.py --- /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()