changeset 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 103ad506a83d
files .gitignore MANIFEST.in Makefile README.rst setup.py src/ofxstatement/__init__.py src/ofxstatement/plugins/__init__.py src/ofxstatement/plugins/sample.py
diffstat 8 files changed, 115 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /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*
--- /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
--- /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
--- /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.
--- /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
+      )
--- /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__)
--- /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__)
--- /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()