ofxhome-0.3.3/0000755000076500000240000000000012656722473014604 5ustar davidbartlestaff00000000000000ofxhome-0.3.3/ofxhome/0000755000076500000240000000000012656722473016251 5ustar davidbartlestaff00000000000000ofxhome-0.3.3/ofxhome/__init__.py0000644000076500000240000000737312656722245020371 0ustar davidbartlestaff00000000000000try: # Python3 case from urllib.parse import urlencode from urllib.request import urlopen except ImportError: # Python2 case from urllib import urlencode from urllib2 import urlopen from datetime import datetime from xml.dom.minidom import parseString __version__ = '0.3.3' 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 OFXHome.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 = urlencode(params) xml = 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): with open(file, 'r') as f: data = f.read() return InstitutionList(data) 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): with open(file, 'r') as f: data = f.read() return Institution(data) ofxhome-0.3.3/ofxhome/tests/0000755000076500000240000000000012656722473017413 5ustar davidbartlestaff00000000000000ofxhome-0.3.3/ofxhome/tests/__init__.py0000644000076500000240000000000012374532655021510 0ustar davidbartlestaff00000000000000ofxhome-0.3.3/ofxhome/tests/test_suite.py0000644000076500000240000000740712656722245022162 0ustar davidbartlestaff00000000000000import sys, os, os.path from ofxhome import OFXHome, Institution, InstitutionList import unittest import datetime class InstitutionTestCase(unittest.TestCase): def testGoodParse(self): with testfile('scottrade.xml') as f: xml = f.read() i = Institution(xml) self.assertEqual(i.id,'623') self.assertEqual(i.name,'Scottrade, Inc.') self.assertEqual(i.fid,'777') self.assertEqual(i.org,'Scottrade') self.assertEqual(i.brokerid,'www.scottrade.com') self.assertEqual(i.url,'https://ofxstl.scottsave.com') self.assertEqual(i.ofxfail,'0') self.assertEqual(i.sslfail,'4') self.assertEqual(i.lastofxvalidation,datetime.datetime(2012,8,13,22,28,10)) self.assertEqual(i.lastsslvalidation,datetime.datetime(2011,9,28,22,22,22)) self.assertEqual(i.xml, xml) def testOptionalBroker(self): with testfile('jpmorgan.xml') as f: xml = f.read() i = Institution(xml) self.assertEqual(i.id,'435') self.assertEqual(i.name,'JPMorgan Chase Bank') self.assertEqual(i.fid,'1601') self.assertEqual(i.org,'Chase Bank') self.assertEqual(i.brokerid,'') self.assertEqual(i.url,'https://www.oasis.cfree.com/1601.ofxgp') self.assertEqual(i.ofxfail,'0') self.assertEqual(i.sslfail,'0') self.assertEqual(i.lastofxvalidation,datetime.datetime(2014,8,17,22,23,35)) self.assertEqual(i.lastsslvalidation,datetime.datetime(2014,8,17,22,23,34)) self.assertEqual(i.xml, xml) def testFromFile(self): i = Institution.from_file( testfile_name('scottrade.xml') ) self.assertEqual(i.id,'623') self.assertEqual(i['id'],'623') def testDictKeys(self): with testfile('scottrade.xml') as f: xml = f.read() i = Institution(xml) self.assertEqual(i['id'],'623') self.assertEqual(i['name'],'Scottrade, Inc.') i['id'] = '123' self.assertEqual(i['id'],'123') def testBadParse(self): with testfile('badxml_bank.xml') as f: xml = f.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.assertEqual(len(l),15) def testGoodResult(self): with testfile('search_america.xml') as f: xml = f.read() l = InstitutionList(xml) self.assertEqual(len(l),15) self.assertEqual(l.xml,xml) self.assertEqual(l[0]['id'],'533') self.assertEqual(l[0]['name'],'America First Credit Union') def testResultWithPHPError(self): with testfile('search_noexist.xml') as f: xml = f.read() l = InstitutionList(xml) self.assertEqual(len(l),0) self.assertEqual(l.xml,xml) def testIterator(self): count = 0 with testfile('search_america.xml') as f: xml = f.read() l = InstitutionList(xml) for i in l: count += 1 self.assertEqual(count,15) def testBadXML(self): with testfile('badxml_search.xml') as f: xml = f.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 open(testfile_name(filename)) if __name__ == '__main__': unittest.main() ofxhome-0.3.3/ofxhome.egg-info/0000755000076500000240000000000012656722473017743 5ustar davidbartlestaff00000000000000ofxhome-0.3.3/ofxhome.egg-info/dependency_links.txt0000644000076500000240000000000112656722451024005 0ustar davidbartlestaff00000000000000 ofxhome-0.3.3/ofxhome.egg-info/entry_points.txt0000644000076500000240000000000712656722451023232 0ustar davidbartlestaff00000000000000 ofxhome-0.3.3/ofxhome.egg-info/PKG-INFO0000644000076500000240000000362412656722451021041 0ustar davidbartlestaff00000000000000Metadata-Version: 1.1 Name: ofxhome Version: 0.3.3 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.3/ofxhome.egg-info/SOURCES.txt0000644000076500000240000000043312656722451021623 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.3/ofxhome.egg-info/top_level.txt0000644000076500000240000000001012656722451022460 0ustar davidbartlestaff00000000000000ofxhome ofxhome-0.3.3/ofxhome.egg-info/zip-safe0000644000076500000240000000000112374533425021365 0ustar davidbartlestaff00000000000000 ofxhome-0.3.3/PKG-INFO0000644000076500000240000000362412656722473015706 0ustar davidbartlestaff00000000000000Metadata-Version: 1.1 Name: ofxhome Version: 0.3.3 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.3/README0000644000076500000240000000171412374532655015465 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.3/setup.cfg0000644000076500000240000000016012656722473016422 0ustar davidbartlestaff00000000000000[egg_info] tag_svn_revision = 0 tag_build = tag_date = 0 [aliases] release = register sdist bdist_egg upload ofxhome-0.3.3/setup.py0000644000076500000240000000207712656722245016321 0ustar davidbartlestaff00000000000000from setuptools import setup, find_packages setup(name='ofxhome', version="0.3.3", 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=""" """, )