Skip to content

Commit

Permalink
Iniitial commit of sample ofxstatement plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
kedder committed Nov 2, 2013
0 parents commit bd5baa8
Show file tree
Hide file tree
Showing 8 changed files with 115 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
*.pyc
*.swp
develop-eggs
dist
src/*.egg-info
tags
build
eggs
.venv
.project
.pydevproject
*.sublime*
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include README.rst
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
PYTHON=.venv/bin/python

all: PYTHON

PYTHON: setup.py
virtualenv -p python3 --no-site-packages .venv
$(PYTHON) setup.py develop
17 changes: 17 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -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.
40 changes: 40 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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="[email protected]",
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
)
1 change: 1 addition & 0 deletions src/ofxstatement/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__import__('pkg_resources').declare_namespace(__name__)
1 change: 1 addition & 0 deletions src/ofxstatement/plugins/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__import__('pkg_resources').declare_namespace(__name__)
36 changes: 36 additions & 0 deletions src/ofxstatement/plugins/sample.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit bd5baa8

Please sign in to comment.