diff options
author | Andrew Shadura <andrewsh@debian.org> | 2016-10-19 17:41:41 +0200 |
---|---|---|
committer | Andrew Shadura <andrewsh@debian.org> | 2016-10-19 17:41:41 +0200 |
commit | 06c5e426f45c6482eb9c37a684179f8c37e3b90c (patch) | |
tree | bd8d33d98c7a3d5707f96ac4bcc3cac16dc57dd5 | |
parent | 219aa6f7c3c88da2a7023186e5ca660c708ef94f (diff) |
Imported Upstream version 2.0.2+git20161018
-rw-r--r-- | .gitignore | 33 | ||||
-rw-r--r-- | .travis.yml | 11 | ||||
-rw-r--r-- | AUTHORS | 10 | ||||
-rw-r--r-- | Dockerfile | 17 | ||||
-rw-r--r-- | PKG-INFO | 63 | ||||
l---------[-rw-r--r--] | README | 45 | ||||
-rw-r--r-- | example/amex.py | 19 | ||||
-rw-r--r-- | keyringrc.cfg | 2 | ||||
-rw-r--r-- | ofxclient.egg-info/PKG-INFO | 63 | ||||
-rw-r--r-- | ofxclient.egg-info/SOURCES.txt | 27 | ||||
-rw-r--r-- | ofxclient.egg-info/dependency_links.txt | 1 | ||||
-rw-r--r-- | ofxclient.egg-info/entry_points.txt | 3 | ||||
-rw-r--r-- | ofxclient.egg-info/not-zip-safe | 1 | ||||
-rw-r--r-- | ofxclient.egg-info/requires.txt | 6 | ||||
-rw-r--r-- | ofxclient.egg-info/top_level.txt | 1 | ||||
-rw-r--r-- | ofxclient/account.py | 9 | ||||
-rw-r--r-- | ofxclient/cli.py | 32 | ||||
-rw-r--r-- | ofxclient/client.py | 2 | ||||
-rw-r--r-- | ofxclient/institution.py | 9 | ||||
-rw-r--r-- | requirements.txt | 8 | ||||
-rw-r--r-- | setup.cfg | 5 |
21 files changed, 135 insertions, 232 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..41df384 --- /dev/null +++ b/.gitignore @@ -0,0 +1,33 @@ +.buildinfo +.doctrees + +*.py[co] + +# Packages +*.egg +*.egg-info +dist +build +eggs +parts +bin +var +sdist +develop-eggs +.installed.cfg + +# Installer logs +pip-log.txt + +# Unit test / coverage reports +.coverage +.tox + +# ofx files in root folder +/*.ofx + +#Translations +*.mo + +#Mr Developer +.mr.developer.cfg diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..7053b5a --- /dev/null +++ b/.travis.yml @@ -0,0 +1,11 @@ +language: python +python: + - "2.6" + - "2.7" + - "3.2" + - "3.3" + - "3.4" + - "3.5" +install: + - pip install . +script: nosetests --verbose tests/*.py @@ -0,0 +1,10 @@ +Maintainers: +David Bartle <captindave@gmail.com> + +Thanks: +Jeremy Jongsma - The first ofx-ba.py script +Jeffrey Paul - Encouraging my to improve this module past homebrew status +@jbms - Jumpstarting the python 3 support +Rudd-O - Encouraging security review and communication +@tgoetze - encoding and windows bug fixes +Everyone who uses this - I'm honored that you find this hobby project useful diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..60a1c8e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +FROM python:2.7-onbuild +MAINTAINER David Bartle <captindave@gmail.com> + +RUN mkdir -p /root/.local/share/python_keyring +RUN mkdir -p /export + +COPY keyringrc.cfg /root/.local/share/python_keyring + +RUN python setup.py install + +VOLUME /export +VOLUME /root/.local/share/python_keyring + +# so that ofxclient will download to the shared volume by default +WORKDIR /export + +ENTRYPOINT ["ofxclient", "-c", "/export/ofxconfig.ini"] diff --git a/PKG-INFO b/PKG-INFO deleted file mode 100644 index 5975bc3..0000000 --- a/PKG-INFO +++ /dev/null @@ -1,63 +0,0 @@ -Metadata-Version: 1.1 -Name: ofxclient -Version: 2.0.2 -Summary: OFX client for dowloading transactions from banks -Home-page: https://github.com/captin411/ofxclient -Author: David Bartle -Author-email: captindave@gmail.com -License: MIT License -Description: Overview - ========= - - Simple ofxclient command line utility and OFX client libraries for development. - - Full Documentation - ================== - - http://captin411.github.com/ofxclient/ - - Quick Start - =========== - - > $ ofxclient --download combined.ofx --open --verbose - - Security Notes - ============== - - Initial Setup - ------------- - - When using the command line tool, initial account setup uses a third party website. - The website http://ofxhome.com will be consulted in order to determine information about - banks. For example, the API url that your bank wants to use for their OFX communication. - - You will be transmitting the name of your bank to a third party over an insecure channel. - - Your password and username are not transmitted during the "search" phase. - - The username and password will be transmitted to the URL for your bank as provided by - ofxhome.com. You will be shown the URL that will be used. If the URL does not look - appropriate, or otherwise appears to be tampered with, then do not submit your username - and password during the setup phase. - - Bank Information Storage - ------------------------ - A configuration file `$HOME/ofxclient.ini` is used to store the information about the banks - that you want to download transactions from. - - Your username and password are stored encrypted however your account number, routing number, - bank name, and account type are not encrypted and are visible to anyone with access to this - file on your local computer. - - For full details on the config file, see: http://captin411.github.com/ofxclient/ - -Keywords: ofx,Open Financial Exchange,download transactions -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 @@ -1,44 +1 @@ -Overview -========= - -Simple ofxclient command line utility and OFX client libraries for development. - -Full Documentation -================== - -http://captin411.github.com/ofxclient/ - -Quick Start -=========== - -> $ ofxclient --download combined.ofx --open --verbose - -Security Notes -============== - -Initial Setup -------------- - -When using the command line tool, initial account setup uses a third party website. -The website http://ofxhome.com will be consulted in order to determine information about -banks. For example, the API url that your bank wants to use for their OFX communication. - -You will be transmitting the name of your bank to a third party over an insecure channel. - -Your password and username are not transmitted during the "search" phase. - -The username and password will be transmitted to the URL for your bank as provided by -ofxhome.com. You will be shown the URL that will be used. If the URL does not look -appropriate, or otherwise appears to be tampered with, then do not submit your username -and password during the setup phase. - -Bank Information Storage ------------------------- -A configuration file `$HOME/ofxclient.ini` is used to store the information about the banks -that you want to download transactions from. - -Your username and password are stored encrypted however your account number, routing number, -bank name, and account type are not encrypted and are visible to anyone with access to this -file on your local computer. - -For full details on the config file, see: http://captin411.github.com/ofxclient/ +README.md
\ No newline at end of file diff --git a/example/amex.py b/example/amex.py new file mode 100644 index 0000000..727c794 --- /dev/null +++ b/example/amex.py @@ -0,0 +1,19 @@ +from ofxclient import Institution + +inst = Institution( + id = '3101', + org = 'AMEX', + url = 'https://online.americanexpress.com/myca/ofxdl/desktop/desktopDownload.do?request_type=nl_ofxdownload', + username = 'genewilder', + password = 'ihatecandy' +) + +accounts = inst.accounts() +for a in accounts: + # a StringIO wrapped string of the raw OFX download + download = a.download(days=5) + print download.read() + + # an ofxparse.Statement object + statement = a.statement(days=5) + print statement.balance diff --git a/keyringrc.cfg b/keyringrc.cfg new file mode 100644 index 0000000..63b902a --- /dev/null +++ b/keyringrc.cfg @@ -0,0 +1,2 @@ +[backend] +default-keyring=keyrings.alt.file.EncryptedKeyring diff --git a/ofxclient.egg-info/PKG-INFO b/ofxclient.egg-info/PKG-INFO deleted file mode 100644 index 5975bc3..0000000 --- a/ofxclient.egg-info/PKG-INFO +++ /dev/null @@ -1,63 +0,0 @@ -Metadata-Version: 1.1 -Name: ofxclient -Version: 2.0.2 -Summary: OFX client for dowloading transactions from banks -Home-page: https://github.com/captin411/ofxclient -Author: David Bartle -Author-email: captindave@gmail.com -License: MIT License -Description: Overview - ========= - - Simple ofxclient command line utility and OFX client libraries for development. - - Full Documentation - ================== - - http://captin411.github.com/ofxclient/ - - Quick Start - =========== - - > $ ofxclient --download combined.ofx --open --verbose - - Security Notes - ============== - - Initial Setup - ------------- - - When using the command line tool, initial account setup uses a third party website. - The website http://ofxhome.com will be consulted in order to determine information about - banks. For example, the API url that your bank wants to use for their OFX communication. - - You will be transmitting the name of your bank to a third party over an insecure channel. - - Your password and username are not transmitted during the "search" phase. - - The username and password will be transmitted to the URL for your bank as provided by - ofxhome.com. You will be shown the URL that will be used. If the URL does not look - appropriate, or otherwise appears to be tampered with, then do not submit your username - and password during the setup phase. - - Bank Information Storage - ------------------------ - A configuration file `$HOME/ofxclient.ini` is used to store the information about the banks - that you want to download transactions from. - - Your username and password are stored encrypted however your account number, routing number, - bank name, and account type are not encrypted and are visible to anyone with access to this - file on your local computer. - - For full details on the config file, see: http://captin411.github.com/ofxclient/ - -Keywords: ofx,Open Financial Exchange,download transactions -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 diff --git a/ofxclient.egg-info/SOURCES.txt b/ofxclient.egg-info/SOURCES.txt deleted file mode 100644 index 2d63eac..0000000 --- a/ofxclient.egg-info/SOURCES.txt +++ /dev/null @@ -1,27 +0,0 @@ -CHANGELOG.md -LICENSE -MANIFEST.in -README -README.md -setup.cfg -setup.py -ofxclient/__init__.py -ofxclient/account.py -ofxclient/cli.py -ofxclient/client.py -ofxclient/config.py -ofxclient/institution.py -ofxclient/util.py -ofxclient/version.py -ofxclient.egg-info/PKG-INFO -ofxclient.egg-info/SOURCES.txt -ofxclient.egg-info/dependency_links.txt -ofxclient.egg-info/entry_points.txt -ofxclient.egg-info/not-zip-safe -ofxclient.egg-info/requires.txt -ofxclient.egg-info/top_level.txt -tests/__init__.py -tests/account.py -tests/institution.py -tests/ofxconfig.py -tests/secure_config.py
\ No newline at end of file diff --git a/ofxclient.egg-info/dependency_links.txt b/ofxclient.egg-info/dependency_links.txt deleted file mode 100644 index 8b13789..0000000 --- a/ofxclient.egg-info/dependency_links.txt +++ /dev/null @@ -1 +0,0 @@ - diff --git a/ofxclient.egg-info/entry_points.txt b/ofxclient.egg-info/entry_points.txt deleted file mode 100644 index d69b6d4..0000000 --- a/ofxclient.egg-info/entry_points.txt +++ /dev/null @@ -1,3 +0,0 @@ -[console_scripts] -ofxclient = ofxclient.cli:run - diff --git a/ofxclient.egg-info/not-zip-safe b/ofxclient.egg-info/not-zip-safe deleted file mode 100644 index 8b13789..0000000 --- a/ofxclient.egg-info/not-zip-safe +++ /dev/null @@ -1 +0,0 @@ - diff --git a/ofxclient.egg-info/requires.txt b/ofxclient.egg-info/requires.txt deleted file mode 100644 index c6c7b45..0000000 --- a/ofxclient.egg-info/requires.txt +++ /dev/null @@ -1,6 +0,0 @@ -argparse -keyring -lxml -ofxhome -ofxparse>0.8 -beautifulsoup4 diff --git a/ofxclient.egg-info/top_level.txt b/ofxclient.egg-info/top_level.txt deleted file mode 100644 index 3d93e4e..0000000 --- a/ofxclient.egg-info/top_level.txt +++ /dev/null @@ -1 +0,0 @@ -ofxclient diff --git a/ofxclient/account.py b/ofxclient/account.py index 98c2658..c1ebdaf 100644 --- a/ofxclient/account.py +++ b/ofxclient/account.py @@ -4,10 +4,12 @@ import datetime import hashlib try: # python 3 - from io import StringIO + from io import StringIO, BytesIO + IS_PYTHON_2 = False except ImportError: # python 2 from StringIO import StringIO + IS_PYTHON_2 = True import time from ofxparse import OfxParser, AccountType @@ -109,7 +111,10 @@ class Account(object): :type days: integer :rtype: :py:class:`ofxparser.Ofx` """ - return OfxParser.parse(self.download(days=days)) + if IS_PYTHON_2: + return OfxParser.parse(self.download(days=days)) + else: + return OfxParser.parse(BytesIO((((self.download(days=days)).read()).encode()))) def statement(self, days=60): """Download the :py:class:`ofxparse.Statement` given the time range diff --git a/ofxclient/cli.py b/ofxclient/cli.py index e09e0e6..114ae83 100644 --- a/ofxclient/cli.py +++ b/ofxclient/cli.py @@ -14,6 +14,7 @@ from ofxclient.account import BankAccount, BrokerageAccount, CreditCardAccount from ofxclient.config import OfxConfig from ofxclient.institution import Institution from ofxclient.util import combined_download +from ofxclient.client import DEFAULT_OFX_VERSION AUTO_OPEN_DOWNLOADS = 1 DOWNLOAD_DAYS = 30 @@ -30,6 +31,8 @@ def run(): parser.add_argument('-o', '--open', action='store_true') parser.add_argument('-v', '--verbose', action='store_true') parser.add_argument('-c', '--config', help='config file path') + parser.add_argument('--download-days', default=DOWNLOAD_DAYS, type=int, help='number of days to download (default: %s)' % DOWNLOAD_DAYS) + parser.add_argument('--ofx-version', default=DEFAULT_OFX_VERSION, type=int, help='ofx version to use for new accounts (default: %s)' % DEFAULT_OFX_VERSION) args = parser.parse_args() if args.config: @@ -47,9 +50,9 @@ def run(): if accounts: if args.account: a = GlobalConfig.account(args.account) - ofxdata = a.download(days=DOWNLOAD_DAYS) + ofxdata = a.download(days=args.download_days) else: - ofxdata = combined_download(accounts, days=DOWNLOAD_DAYS) + ofxdata = combined_download(accounts, days=args.download_days) args.download.write(ofxdata.read()) if args.open: open_with_ofx_handler(args.download.name) @@ -57,10 +60,10 @@ def run(): else: print("no accounts configured") - main_menu() + main_menu(args) -def main_menu(): +def main_menu(args): while 1: menu_title("Main\nEdit %s to\nchange descriptions or ofx options" % GlobalConfig.file_name) @@ -77,12 +80,12 @@ def main_menu(): choice = prompt().lower() if choice == 'a': - add_account_menu() + add_account_menu(args) elif choice == 'd': if not accounts: print("no accounts on file") else: - ofxdata = combined_download(accounts, days=DOWNLOAD_DAYS) + ofxdata = combined_download(accounts, days=args.download_days) wrote = write_and_handle_download( ofxdata, 'combined_download.ofx' @@ -92,10 +95,10 @@ def main_menu(): return elif int(choice) < len(accounts): account = accounts[int(choice)] - view_account_menu(account) + view_account_menu(account, args) -def add_account_menu(): +def add_account_menu(args): menu_title("Add account") while 1: print('------') @@ -124,11 +127,11 @@ def add_account_menu(): return elif int(choice) < len(found): bank = OFXHome.lookup(found[int(choice)]['id']) - if login_check_menu(bank): + if login_check_menu(bank, args): return -def view_account_menu(account): +def view_account_menu(account, args): while 1: menu_title(account.long_description()) @@ -147,7 +150,7 @@ def view_account_menu(account): print(" Broker ID: %s" % account.broker_id) print("Nerdy Info:") - print(" Download Up To: %s days" % DOWNLOAD_DAYS) + print(" Download Up To: %s days" % args.download_days) print(" Username: %s" % institution.username) print(" Local Account ID: %s" % account.local_id()) print(" Local Institution ID: %s" % institution.local_id()) @@ -165,14 +168,14 @@ def view_account_menu(account): menu_item('D', 'Download') choice = prompt().lower() if choice == 'd': - out = account.download(days=DOWNLOAD_DAYS) + out = account.download(days=args.download_days) wrote = write_and_handle_download(out, "%s.ofx" % account.local_id()) print("wrote: %s" % wrote) return -def login_check_menu(bank_info): +def login_check_menu(bank_info, args): print('------') print('Notice') print('------') @@ -202,7 +205,8 @@ def login_check_menu(bank_info): broker_id=bank_info['brokerid'], description=bank_info['name'], username=username, - password=password + password=password, + client_args={ofx_version: args.ofx_version} ) try: i.authenticate() diff --git a/ofxclient/client.py b/ofxclient/client.py index 028b16b..5a7dcc0 100644 --- a/ofxclient/client.py +++ b/ofxclient/client.py @@ -100,7 +100,7 @@ class Client: logging.debug(query) garbage, path = splittype(i.url) host, selector = splithost(path) - h = HTTPSConnection(host) + h = HTTPSConnection(host, timeout=60) h.request('POST', selector, query, { "Content-type": "application/x-ofx", diff --git a/ofxclient/institution.py b/ofxclient/institution.py index d3cd1b4..7e38096 100644 --- a/ofxclient/institution.py +++ b/ofxclient/institution.py @@ -3,10 +3,12 @@ from __future__ import unicode_literals import hashlib try: # python 3 - from io import StringIO + from io import StringIO, BytesIO + IS_PYTHON_2 = False except ImportError: # python 2 from StringIO import StringIO + IS_PYTHON_2 = Trues from bs4 import BeautifulSoup from ofxparse import OfxParser @@ -140,7 +142,10 @@ class Institution(object): resp = client.post(query) resp_handle = StringIO(resp) - parsed = OfxParser.parse(resp_handle) + if IS_PYTHON_2: + parsed = OfxParser.parse(resp_handle) + else: + parsed = OfxParser.parse(BytesIO((((resp_handle).read()).encode()))) return [Account.from_ofxparse(a, institution=self) for a in parsed.accounts] diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..5aea447 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,8 @@ +argparse ==1.4.1; python_version < '2.7' +beautifulsoup4 ==4.4.1 +keyring ==8.4.1 +ofxhome ==0.3.3 +ofxparse ==0.14 +lxml ==3.5.0 +keyrings.alt ==1.1.1 +pycrypto ==2.6.1 @@ -1,8 +1,5 @@ [egg_info] -tag_svn_revision = 0 -tag_build = -tag_date = 0 +tag_svn_revision = false [aliases] release = register sdist bdist_egg upload - |