ofxhome-0.3.2/0000755000076500000240000000000012374541554014577 5ustar davidbartlestaff00000000000000ofxhome-0.3.2/ofxhome/0000755000076500000240000000000012374541554016244 5ustar davidbartlestaff00000000000000ofxhome-0.3.2/ofxhome/__init__.py0000644000076500000240000000674412374535604020367 0ustar davidbartlestaff00000000000000import urllib from datetime import datetime from xml.dom.minidom import parseString __version__ = '0.3.2' API_URL='http://www.ofxhome.com/api.php' class OFXHome: @staticmethod def lookup(id): """ Get financial institution OFX info given an ofxhome.com 'id' Returns: Institution bank = OFXHome.lookup('456') print bank.name _ bank.url _ bank.fid """ return Institution(_xml_request({ 'lookup': id })) @staticmethod def all(): """ List every available bank that ofxhome.com knows about Returns: InstitutionList See also: OFXHome.search() """ return search() @staticmethod def search(name=None): """ Search for a financial institution by name. Returns: InstitutionList If no name is provided , or a name of None is provided then it is the same as calling OFXHome.all(). Note that passing a string of '' will not be the same thing and will result in no results. banks = OFXHome.search('America') for res in banks: print res.id _ res.name bank = OFXHome.lookup(res.id) print bank.name _ bank.url _ bank.fid """ if name is None: params = { 'all': 'yes' } else: params = { 'search': name } return InstitutionList(_xml_request(params)) def _attr(node,name): return node.getAttribute(name) def _text(parent,name): rc = [] elements = parent.getElementsByTagName(name) if not elements: return '' for node in elements[0].childNodes: if node.nodeType == node.TEXT_NODE: rc.append(node.data) return ''.join(rc) def _xml_request(params=None): encoded = urllib.urlencode(params) xml = urllib.urlopen("%s?%s" % (API_URL,encoded)).read() return xml #--------------------------------------------- class InstitutionList: def __init__(self,xml): root = parseString(xml).documentElement data = [] for node in root.getElementsByTagName('institutionid'): data.append({ 'name': _attr(node,'name'), 'id': _attr(node,'id') }) self.items = data self.xml = xml @staticmethod def from_file(file): return InstitutionList(open(file,'r').read()) def __getitem__(self,item): return self.items[item] def __len__(self): return len(self.items) def __iter__(self): for i in self.items: yield i def __str__(self): return self.xml #--------------------------------------------- class Institution: def __init__(self,xml): dom = parseString(xml) root = dom.documentElement self.id = _attr(root,'id') self.name = _text(root,'name') self.fid = _text(root,'fid') self.org = _text(root,'org') self.url = _text(root,'url') self.brokerid = _text(root,'brokerid') self.ofxfail = _text(root,'ofxfail') self.sslfail = _text(root,'sslfail') self.lastofxvalidation = datetime.strptime(_text(root,'lastofxvalidation'),"%Y-%m-%d %H:%M:%S") self.lastsslvalidation = datetime.strptime(_text(root,'lastsslvalidation'),"%Y-%m-%d %H:%M:%S") self.xml = xml def __getitem__(self,item): return self.__dict__[item] def __setitem__(self,item,value): self.__dict__[item] = value @staticmethod def from_file(file): return Institution(open(file,'r').read()) ofxhome-0.3.2/ofxhome/tests/0000755000076500000240000000000012374541554017406 5ustar davidbartlestaff00000000000000ofxhome-0.3.2/ofxhome/tests/__init__.py0000644000076500000240000000000012374532655021507 0ustar davidbartlestaff00000000000000ofxhome-0.3.2/ofxhome/tests/test_suite.py0000644000076500000240000000714212374535330022147 0ustar davidbartlestaff00000000000000import sys, os, os.path from ofxhome import OFXHome, Institution, InstitutionList import unittest import datetime class InstitutionTestCase(unittest.TestCase): def testGoodParse(self): xml = testfile('scottrade.xml').read() i = Institution(xml) self.assertEquals(i.id,'623') self.assertEquals(i.name,'Scottrade, Inc.') self.assertEquals(i.fid,'777') self.assertEquals(i.org,'Scottrade') self.assertEquals(i.brokerid,'www.scottrade.com') self.assertEquals(i.url,'https://ofxstl.scottsave.com') self.assertEquals(i.ofxfail,'0') self.assertEquals(i.sslfail,'4') self.assertEquals(i.lastofxvalidation,datetime.datetime(2012,8,13,22,28,10)) self.assertEquals(i.lastsslvalidation,datetime.datetime(2011,9,28,22,22,22)) self.assertEquals(i.xml, xml) def testOptionalBroker(self): xml = testfile('jpmorgan.xml').read() i = Institution(xml) self.assertEquals(i.id,'435') self.assertEquals(i.name,'JPMorgan Chase Bank') self.assertEquals(i.fid,'1601') self.assertEquals(i.org,'Chase Bank') self.assertEquals(i.brokerid,'') self.assertEquals(i.url,'https://www.oasis.cfree.com/1601.ofxgp') self.assertEquals(i.ofxfail,'0') self.assertEquals(i.sslfail,'0') self.assertEquals(i.lastofxvalidation,datetime.datetime(2014,8,17,22,23,35)) self.assertEquals(i.lastsslvalidation,datetime.datetime(2014,8,17,22,23,34)) self.assertEquals(i.xml, xml) def testFromFile(self): i = Institution.from_file( testfile_name('scottrade.xml') ) self.assertEquals(i.id,'623') self.assertEquals(i['id'],'623') def testDictKeys(self): xml = testfile('scottrade.xml').read() i = Institution(xml) self.assertEquals(i['id'],'623') self.assertEquals(i['name'],'Scottrade, Inc.') i['id'] = '123' self.assertEquals(i['id'],'123') def testBadParse(self): xml = testfile('badxml_bank.xml').read() try: l = Institution(xml) self.assertFalse(0) except Exception: self.assertTrue(1) class InstitutionListTestCase(unittest.TestCase): def testFromFile(self): l = InstitutionList.from_file( testfile_name('search_america.xml') ) self.assertEquals(len(l),15) def testGoodResult(self): xml = testfile('search_america.xml').read() l = InstitutionList(xml) self.assertEquals(len(l),15) self.assertEquals(l.xml,xml) self.assertEquals(l[0]['id'],'533') self.assertEquals(l[0]['name'],'America First Credit Union') def testResultWithPHPError(self): xml = testfile('search_noexist.xml').read() l = InstitutionList(xml) self.assertEquals(len(l),0) self.assertEquals(l.xml,xml) def testIterator(self): count = 0 xml = testfile('search_america.xml').read() l = InstitutionList(xml) for i in l: count += 1 self.assertEquals(count,15) def testBadXML(self): xml = testfile('badxml_search.xml').read() try: l = InstitutionList(xml) self.assertFalse(0) except Exception: self.assertTrue(1) def testfile_name(filename): base_path = os.path.dirname(os.path.abspath(__file__)) path = os.path.join(base_path,'testfiles',filename) if ('tests' in os.listdir('.')): path = os.path.join('tests',path) return path def testfile(filename): return file(testfile_name(filename)) if __name__ == '__main__': unittest.main() ofxhome-0.3.2/ofxhome.egg-info/0000755000076500000240000000000012374541554017736 5ustar davidbartlestaff00000000000000ofxhome-0.3.2/ofxhome.egg-info/dependency_links.txt0000644000076500000240000000000112374541550024000 0ustar davidbartlestaff00000000000000 ofxhome-0.3.2/ofxhome.egg-info/entry_points.txt0000644000076500000240000000000712374541550023225 0ustar davidbartlestaff00000000000000 ofxhome-0.3.2/ofxhome.egg-info/PKG-INFO0000644000076500000240000000362412374541550021034 0ustar davidbartlestaff00000000000000Metadata-Version: 1.1 Name: ofxhome Version: 0.3.2 Summary: ofxhome.com financial institution lookup REST client Home-page: https://github.com/captin411/ofxhome Author: David Bartle Author-email: captindave@gmail.com License: MIT License Description: ofxhome ========= REST client for the web service provided by ofxhome.com ofxhome.com provides a way to discover the Open Financial Exchange (OFX) URL's and financial institution IDs for banks and other financial institutions. ofxhome is a sort of "DNS" for financial institution OFX URLs and IDs. This client by itself is not all that useful unless you are coupling it with software that needs this lookup capability. other modules ============= ofxclient - a python API that downloads transactions from banks example ======= ```python from ofxhome import OFXHome s = OFXHome.search("USAA") " 's' contains a list that has entries like so: " { name: 'USAA Federal Savings Bank', id: '483' } " { name: 'USAA Investment Mgmt Co', id: '665' } for item in s: print item['id'] _ item['name'] bank = OFXHome.lookup(item.id) print bank.name _ bank.fid _ bank.url _ bank.brokerid # OR print bank['name'] _ bank['fid'] _ bank['url'] _ bank['brokerid'] ``` Keywords: ofx,Open Financial Exchange,bank search,ofxhome,ofxhome.com Platform: UNKNOWN Classifier: Development Status :: 4 - Beta Classifier: Intended Audience :: Developers Classifier: Natural Language :: English Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python Classifier: Topic :: Software Development :: Libraries :: Python Modules Classifier: Topic :: Utilities Classifier: License :: OSI Approved :: MIT License ofxhome-0.3.2/ofxhome.egg-info/SOURCES.txt0000644000076500000240000000043312374541550021616 0ustar davidbartlestaff00000000000000README setup.cfg setup.py ofxhome/__init__.py ofxhome.egg-info/PKG-INFO ofxhome.egg-info/SOURCES.txt ofxhome.egg-info/dependency_links.txt ofxhome.egg-info/entry_points.txt ofxhome.egg-info/top_level.txt ofxhome.egg-info/zip-safe ofxhome/tests/__init__.py ofxhome/tests/test_suite.pyofxhome-0.3.2/ofxhome.egg-info/top_level.txt0000644000076500000240000000001012374541550022453 0ustar davidbartlestaff00000000000000ofxhome ofxhome-0.3.2/ofxhome.egg-info/zip-safe0000644000076500000240000000000112374533425021364 0ustar davidbartlestaff00000000000000 ofxhome-0.3.2/PKG-INFO0000644000076500000240000000362412374541554015701 0ustar davidbartlestaff00000000000000Metadata-Version: 1.1 Name: ofxhome Version: 0.3.2 Summary: ofxhome.com financial institution lookup REST client Home-page: https://github.com/captin411/ofxhome Author: David Bartle Author-email: captindave@gmail.com License: MIT License Description: ofxhome ========= REST client for the web service provided by ofxhome.com ofxhome.com provides a way to discover the Open Financial Exchange (OFX) URL's and financial institution IDs for banks and other financial institutions. ofxhome is a sort of "DNS" for financial institution OFX URLs and IDs. This client by itself is not all that useful unless you are coupling it with software that needs this lookup capability. other modules ============= ofxclient - a python API that downloads transactions from banks example ======= ```python from ofxhome import OFXHome s = OFXHome.search("USAA") " 's' contains a list that has entries like so: " { name: 'USAA Federal Savings Bank', id: '483' } " { name: 'USAA Investment Mgmt Co', id: '665' } for item in s: print item['id'] _ item['name'] bank = OFXHome.lookup(item.id) print bank.name _ bank.fid _ bank.url _ bank.brokerid # OR print bank['name'] _ bank['fid'] _ bank['url'] _ bank['brokerid'] ``` Keywords: ofx,Open Financial Exchange,bank search,ofxhome,ofxhome.com Platform: UNKNOWN Classifier: Development Status :: 4 - Beta Classifier: Intended Audience :: Developers Classifier: Natural Language :: English Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python Classifier: Topic :: Software Development :: Libraries :: Python Modules Classifier: Topic :: Utilities Classifier: License :: OSI Approved :: MIT License ofxhome-0.3.2/README0000644000076500000240000000171412374532655015464 0ustar davidbartlestaff00000000000000ofxhome ========= REST client for the web service provided by ofxhome.com ofxhome.com provides a way to discover the Open Financial Exchange (OFX) URL's and financial institution IDs for banks and other financial institutions. ofxhome is a sort of "DNS" for financial institution OFX URLs and IDs. This client by itself is not all that useful unless you are coupling it with software that needs this lookup capability. other modules ============= ofxclient - a python API that downloads transactions from banks example ======= ```python from ofxhome import OFXHome s = OFXHome.search("USAA") " 's' contains a list that has entries like so: " { name: 'USAA Federal Savings Bank', id: '483' } " { name: 'USAA Investment Mgmt Co', id: '665' } for item in s: print item['id'] _ item['name'] bank = OFXHome.lookup(item.id) print bank.name _ bank.fid _ bank.url _ bank.brokerid # OR print bank['name'] _ bank['fid'] _ bank['url'] _ bank['brokerid'] ``` ofxhome-0.3.2/setup.cfg0000644000076500000240000000016012374541554016415 0ustar davidbartlestaff00000000000000[egg_info] tag_svn_revision = 0 tag_build = tag_date = 0 [aliases] release = register sdist bdist_egg upload ofxhome-0.3.2/setup.py0000644000076500000240000000207712374541174016315 0ustar davidbartlestaff00000000000000from setuptools import setup, find_packages setup(name='ofxhome', version="0.3.2", description="ofxhome.com financial institution lookup REST client", long_description=open("./README", "r").read(), classifiers=[ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Utilities", "License :: OSI Approved :: MIT License", ], keywords='ofx, Open Financial Exchange, bank search, ofxhome, ofxhome.com', author='David Bartle', author_email='captindave@gmail.com', url='https://github.com/captin411/ofxhome', license='MIT License', packages=find_packages(exclude=['ez_setup', 'examples']), include_package_data=True, zip_safe=True, install_requires=[ ], test_suite = 'ofxhome.tests', entry_points=""" """, )