Browse Source

Restructure project

Move modules into sensible locations.
Introduce method of compiling documentation with Sphinx.
Ian Adam Naval 5 years ago
parent
commit
558d2d477b

+ 1
- 0
docs/.gitignore View File

@@ -0,0 +1 @@
1
+_build

+ 192
- 0
docs/Makefile View File

@@ -0,0 +1,192 @@
1
+# Makefile for Sphinx documentation
2
+#
3
+
4
+# You can set these variables from the command line.
5
+SPHINXOPTS    =
6
+SPHINXBUILD   = sphinx-build
7
+PAPER         =
8
+BUILDDIR      = _build
9
+
10
+# User-friendly check for sphinx-build
11
+ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)
12
+$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/)
13
+endif
14
+
15
+# Internal variables.
16
+PAPEROPT_a4     = -D latex_paper_size=a4
17
+PAPEROPT_letter = -D latex_paper_size=letter
18
+ALLSPHINXOPTS   = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
19
+# the i18n builder cannot share the environment and doctrees with the others
20
+I18NSPHINXOPTS  = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
21
+
22
+.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest coverage gettext
23
+
24
+help:
25
+	@echo "Please use \`make <target>' where <target> is one of"
26
+	@echo "  html       to make standalone HTML files"
27
+	@echo "  dirhtml    to make HTML files named index.html in directories"
28
+	@echo "  singlehtml to make a single large HTML file"
29
+	@echo "  pickle     to make pickle files"
30
+	@echo "  json       to make JSON files"
31
+	@echo "  htmlhelp   to make HTML files and a HTML help project"
32
+	@echo "  qthelp     to make HTML files and a qthelp project"
33
+	@echo "  applehelp  to make an Apple Help Book"
34
+	@echo "  devhelp    to make HTML files and a Devhelp project"
35
+	@echo "  epub       to make an epub"
36
+	@echo "  latex      to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
37
+	@echo "  latexpdf   to make LaTeX files and run them through pdflatex"
38
+	@echo "  latexpdfja to make LaTeX files and run them through platex/dvipdfmx"
39
+	@echo "  text       to make text files"
40
+	@echo "  man        to make manual pages"
41
+	@echo "  texinfo    to make Texinfo files"
42
+	@echo "  info       to make Texinfo files and run them through makeinfo"
43
+	@echo "  gettext    to make PO message catalogs"
44
+	@echo "  changes    to make an overview of all changed/added/deprecated items"
45
+	@echo "  xml        to make Docutils-native XML files"
46
+	@echo "  pseudoxml  to make pseudoxml-XML files for display purposes"
47
+	@echo "  linkcheck  to check all external links for integrity"
48
+	@echo "  doctest    to run all doctests embedded in the documentation (if enabled)"
49
+	@echo "  coverage   to run coverage check of the documentation (if enabled)"
50
+
51
+clean:
52
+	rm -rf $(BUILDDIR)/*
53
+
54
+html:
55
+	$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
56
+	@echo
57
+	@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
58
+
59
+dirhtml:
60
+	$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
61
+	@echo
62
+	@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
63
+
64
+singlehtml:
65
+	$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
66
+	@echo
67
+	@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
68
+
69
+pickle:
70
+	$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
71
+	@echo
72
+	@echo "Build finished; now you can process the pickle files."
73
+
74
+json:
75
+	$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
76
+	@echo
77
+	@echo "Build finished; now you can process the JSON files."
78
+
79
+htmlhelp:
80
+	$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
81
+	@echo
82
+	@echo "Build finished; now you can run HTML Help Workshop with the" \
83
+	      ".hhp project file in $(BUILDDIR)/htmlhelp."
84
+
85
+qthelp:
86
+	$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
87
+	@echo
88
+	@echo "Build finished; now you can run "qcollectiongenerator" with the" \
89
+	      ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
90
+	@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/LibreBudget.qhcp"
91
+	@echo "To view the help file:"
92
+	@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/LibreBudget.qhc"
93
+
94
+applehelp:
95
+	$(SPHINXBUILD) -b applehelp $(ALLSPHINXOPTS) $(BUILDDIR)/applehelp
96
+	@echo
97
+	@echo "Build finished. The help book is in $(BUILDDIR)/applehelp."
98
+	@echo "N.B. You won't be able to view it unless you put it in" \
99
+	      "~/Library/Documentation/Help or install it in your application" \
100
+	      "bundle."
101
+
102
+devhelp:
103
+	$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
104
+	@echo
105
+	@echo "Build finished."
106
+	@echo "To view the help file:"
107
+	@echo "# mkdir -p $$HOME/.local/share/devhelp/LibreBudget"
108
+	@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/LibreBudget"
109
+	@echo "# devhelp"
110
+
111
+epub:
112
+	$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
113
+	@echo
114
+	@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
115
+
116
+latex:
117
+	$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
118
+	@echo
119
+	@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
120
+	@echo "Run \`make' in that directory to run these through (pdf)latex" \
121
+	      "(use \`make latexpdf' here to do that automatically)."
122
+
123
+latexpdf:
124
+	$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
125
+	@echo "Running LaTeX files through pdflatex..."
126
+	$(MAKE) -C $(BUILDDIR)/latex all-pdf
127
+	@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
128
+
129
+latexpdfja:
130
+	$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
131
+	@echo "Running LaTeX files through platex and dvipdfmx..."
132
+	$(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
133
+	@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
134
+
135
+text:
136
+	$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
137
+	@echo
138
+	@echo "Build finished. The text files are in $(BUILDDIR)/text."
139
+
140
+man:
141
+	$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
142
+	@echo
143
+	@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
144
+
145
+texinfo:
146
+	$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
147
+	@echo
148
+	@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
149
+	@echo "Run \`make' in that directory to run these through makeinfo" \
150
+	      "(use \`make info' here to do that automatically)."
151
+
152
+info:
153
+	$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
154
+	@echo "Running Texinfo files through makeinfo..."
155
+	make -C $(BUILDDIR)/texinfo info
156
+	@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
157
+
158
+gettext:
159
+	$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
160
+	@echo
161
+	@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
162
+
163
+changes:
164
+	$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
165
+	@echo
166
+	@echo "The overview file is in $(BUILDDIR)/changes."
167
+
168
+linkcheck:
169
+	$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
170
+	@echo
171
+	@echo "Link check complete; look for any errors in the above output " \
172
+	      "or in $(BUILDDIR)/linkcheck/output.txt."
173
+
174
+doctest:
175
+	$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
176
+	@echo "Testing of doctests in the sources finished, look at the " \
177
+	      "results in $(BUILDDIR)/doctest/output.txt."
178
+
179
+coverage:
180
+	$(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) $(BUILDDIR)/coverage
181
+	@echo "Testing of coverage in the sources finished, look at the " \
182
+	      "results in $(BUILDDIR)/coverage/python.txt."
183
+
184
+xml:
185
+	$(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
186
+	@echo
187
+	@echo "Build finished. The XML files are in $(BUILDDIR)/xml."
188
+
189
+pseudoxml:
190
+	$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
191
+	@echo
192
+	@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."

+ 35
- 0
docs/api.rst View File

@@ -0,0 +1,35 @@
1
+API
2
+===
3
+
4
+Formatters
5
+----------
6
+
7
+Console
8
+~~~~~~~
9
+
10
+.. automodule:: librebudget.formatters.console
11
+   :members:
12
+
13
+
14
+Scrapers
15
+--------
16
+
17
+Common
18
+~~~~~~
19
+
20
+.. automodule:: librebudget.scrapers.common
21
+   :members:
22
+
23
+Bank of America
24
+~~~~~~~~~~~~~~~
25
+
26
+.. automodule:: librebudget.scrapers.bank_of_america
27
+   :members:
28
+
29
+
30
+
31
+Core
32
+----
33
+
34
+.. automodule:: librebudget_core
35
+   :members:

+ 290
- 0
docs/conf.py View File

@@ -0,0 +1,290 @@
1
+#!/usr/bin/env python3
2
+# -*- coding: utf-8 -*-
3
+#
4
+# LibreBudget documentation build configuration file, created by
5
+# sphinx-quickstart on Wed Jul 15 18:50:45 2015.
6
+#
7
+# This file is execfile()d with the current directory set to its
8
+# containing dir.
9
+#
10
+# Note that not all possible configuration values are present in this
11
+# autogenerated file.
12
+#
13
+# All configuration values have a default; values that are commented out
14
+# serve to show the default.
15
+
16
+import sys
17
+import os
18
+import shlex
19
+import sphinx_rtd_theme
20
+
21
+# If extensions (or modules to document with autodoc) are in another directory,
22
+# add these directories to sys.path here. If the directory is relative to the
23
+# documentation root, use os.path.abspath to make it absolute, like shown here.
24
+#sys.path.insert(0, os.path.abspath('.'))
25
+
26
+# -- General configuration ------------------------------------------------
27
+
28
+# If your documentation needs a minimal Sphinx version, state it here.
29
+#needs_sphinx = '1.0'
30
+
31
+# Add any Sphinx extension module names here, as strings. They can be
32
+# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
33
+# ones.
34
+extensions = [
35
+    'sphinx.ext.autodoc',
36
+    'sphinx.ext.coverage',
37
+    'sphinx.ext.viewcode',
38
+]
39
+
40
+# Add any paths that contain templates here, relative to this directory.
41
+templates_path = ['_templates']
42
+
43
+# The suffix(es) of source filenames.
44
+# You can specify multiple suffix as a list of string:
45
+# source_suffix = ['.rst', '.md']
46
+source_suffix = '.rst'
47
+
48
+# The encoding of source files.
49
+#source_encoding = 'utf-8-sig'
50
+
51
+# The master toctree document.
52
+master_doc = 'index'
53
+
54
+# General information about the project.
55
+project = 'LibreBudget'
56
+copyright = '2015, Ian Adam Naval'
57
+author = 'Ian Adam Naval'
58
+
59
+# The version info for the project you're documenting, acts as replacement for
60
+# |version| and |release|, also used in various other places throughout the
61
+# built documents.
62
+#
63
+# The short X.Y version.
64
+version = '0.1'
65
+# The full version, including alpha/beta/rc tags.
66
+release = '0.1'
67
+
68
+# The language for content autogenerated by Sphinx. Refer to documentation
69
+# for a list of supported languages.
70
+#
71
+# This is also used if you do content translation via gettext catalogs.
72
+# Usually you set "language" from the command line for these cases.
73
+language = None
74
+
75
+# There are two options for replacing |today|: either, you set today to some
76
+# non-false value, then it is used:
77
+#today = ''
78
+# Else, today_fmt is used as the format for a strftime call.
79
+#today_fmt = '%B %d, %Y'
80
+
81
+# List of patterns, relative to source directory, that match files and
82
+# directories to ignore when looking for source files.
83
+exclude_patterns = ['_build']
84
+
85
+# The reST default role (used for this markup: `text`) to use for all
86
+# documents.
87
+#default_role = None
88
+
89
+# If true, '()' will be appended to :func: etc. cross-reference text.
90
+#add_function_parentheses = True
91
+
92
+# If true, the current module name will be prepended to all description
93
+# unit titles (such as .. function::).
94
+#add_module_names = True
95
+
96
+# If true, sectionauthor and moduleauthor directives will be shown in the
97
+# output. They are ignored by default.
98
+#show_authors = False
99
+
100
+# The name of the Pygments (syntax highlighting) style to use.
101
+pygments_style = 'sphinx'
102
+
103
+# A list of ignored prefixes for module index sorting.
104
+#modindex_common_prefix = []
105
+
106
+# If true, keep warnings as "system message" paragraphs in the built documents.
107
+#keep_warnings = False
108
+
109
+# If true, `todo` and `todoList` produce output, else they produce nothing.
110
+todo_include_todos = False
111
+
112
+
113
+# -- Options for HTML output ----------------------------------------------
114
+
115
+# The theme to use for HTML and HTML Help pages.  See the documentation for
116
+# a list of builtin themes.
117
+html_theme = 'sphinx_rtd_theme'
118
+
119
+# Theme options are theme-specific and customize the look and feel of a theme
120
+# further.  For a list of options available for each theme, see the
121
+# documentation.
122
+#html_theme_options = {}
123
+
124
+# Add any paths that contain custom themes here, relative to this directory.
125
+html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
126
+
127
+# The name for this set of Sphinx documents.  If None, it defaults to
128
+# "<project> v<release> documentation".
129
+#html_title = None
130
+
131
+# A shorter title for the navigation bar.  Default is the same as html_title.
132
+#html_short_title = None
133
+
134
+# The name of an image file (relative to this directory) to place at the top
135
+# of the sidebar.
136
+#html_logo = None
137
+
138
+# The name of an image file (within the static path) to use as favicon of the
139
+# docs.  This file should be a Windows icon file (.ico) being 16x16 or 32x32
140
+# pixels large.
141
+#html_favicon = None
142
+
143
+# Add any paths that contain custom static files (such as style sheets) here,
144
+# relative to this directory. They are copied after the builtin static files,
145
+# so a file named "default.css" will overwrite the builtin "default.css".
146
+html_static_path = ['_static']
147
+
148
+# Add any extra paths that contain custom files (such as robots.txt or
149
+# .htaccess) here, relative to this directory. These files are copied
150
+# directly to the root of the documentation.
151
+#html_extra_path = []
152
+
153
+# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
154
+# using the given strftime format.
155
+#html_last_updated_fmt = '%b %d, %Y'
156
+
157
+# If true, SmartyPants will be used to convert quotes and dashes to
158
+# typographically correct entities.
159
+#html_use_smartypants = True
160
+
161
+# Custom sidebar templates, maps document names to template names.
162
+#html_sidebars = {}
163
+
164
+# Additional templates that should be rendered to pages, maps page names to
165
+# template names.
166
+#html_additional_pages = {}
167
+
168
+# If false, no module index is generated.
169
+#html_domain_indices = True
170
+
171
+# If false, no index is generated.
172
+#html_use_index = True
173
+
174
+# If true, the index is split into individual pages for each letter.
175
+#html_split_index = False
176
+
177
+# If true, links to the reST sources are added to the pages.
178
+#html_show_sourcelink = True
179
+
180
+# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
181
+#html_show_sphinx = True
182
+
183
+# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
184
+#html_show_copyright = True
185
+
186
+# If true, an OpenSearch description file will be output, and all pages will
187
+# contain a <link> tag referring to it.  The value of this option must be the
188
+# base URL from which the finished HTML is served.
189
+#html_use_opensearch = ''
190
+
191
+# This is the file name suffix for HTML files (e.g. ".xhtml").
192
+#html_file_suffix = None
193
+
194
+# Language to be used for generating the HTML full-text search index.
195
+# Sphinx supports the following languages:
196
+#   'da', 'de', 'en', 'es', 'fi', 'fr', 'h', 'it', 'ja'
197
+#   'nl', 'no', 'pt', 'ro', 'r', 'sv', 'tr'
198
+#html_search_language = 'en'
199
+
200
+# A dictionary with options for the search language support, empty by default.
201
+# Now only 'ja' uses this config value
202
+#html_search_options = {'type': 'default'}
203
+
204
+# The name of a javascript file (relative to the configuration directory) that
205
+# implements a search results scorer. If empty, the default will be used.
206
+#html_search_scorer = 'scorer.js'
207
+
208
+# Output file base name for HTML help builder.
209
+htmlhelp_basename = 'LibreBudgetdoc'
210
+
211
+# -- Options for LaTeX output ---------------------------------------------
212
+
213
+latex_elements = {
214
+# The paper size ('letterpaper' or 'a4paper').
215
+#'papersize': 'letterpaper',
216
+
217
+# The font size ('10pt', '11pt' or '12pt').
218
+#'pointsize': '10pt',
219
+
220
+# Additional stuff for the LaTeX preamble.
221
+#'preamble': '',
222
+
223
+# Latex figure (float) alignment
224
+#'figure_align': 'htbp',
225
+}
226
+
227
+# Grouping the document tree into LaTeX files. List of tuples
228
+# (source start file, target name, title,
229
+#  author, documentclass [howto, manual, or own class]).
230
+latex_documents = [
231
+  (master_doc, 'LibreBudget.tex', 'LibreBudget Documentation',
232
+   'Ian Adam Naval', 'manual'),
233
+]
234
+
235
+# The name of an image file (relative to this directory) to place at the top of
236
+# the title page.
237
+#latex_logo = None
238
+
239
+# For "manual" documents, if this is true, then toplevel headings are parts,
240
+# not chapters.
241
+#latex_use_parts = False
242
+
243
+# If true, show page references after internal links.
244
+#latex_show_pagerefs = False
245
+
246
+# If true, show URL addresses after external links.
247
+#latex_show_urls = False
248
+
249
+# Documents to append as an appendix to all manuals.
250
+#latex_appendices = []
251
+
252
+# If false, no module index is generated.
253
+#latex_domain_indices = True
254
+
255
+
256
+# -- Options for manual page output ---------------------------------------
257
+
258
+# One entry per manual page. List of tuples
259
+# (source start file, name, description, authors, manual section).
260
+man_pages = [
261
+    (master_doc, 'librebudget', 'LibreBudget Documentation',
262
+     [author], 1)
263
+]
264
+
265
+# If true, show URL addresses after external links.
266
+#man_show_urls = False
267
+
268
+
269
+# -- Options for Texinfo output -------------------------------------------
270
+
271
+# Grouping the document tree into Texinfo files. List of tuples
272
+# (source start file, target name, title, author,
273
+#  dir menu entry, description, category)
274
+texinfo_documents = [
275
+  (master_doc, 'LibreBudget', 'LibreBudget Documentation',
276
+   author, 'LibreBudget', 'One line description of project.',
277
+   'Miscellaneous'),
278
+]
279
+
280
+# Documents to append as an appendix to all manuals.
281
+#texinfo_appendices = []
282
+
283
+# If false, no module index is generated.
284
+#texinfo_domain_indices = True
285
+
286
+# How to display URL addresses: 'footnote', 'no', or 'inline'.
287
+#texinfo_show_urls = 'footnote'
288
+
289
+# If true, do not generate a @detailmenu in the "Top" node's menu.
290
+#texinfo_no_detailmenu = False

+ 23
- 0
docs/index.rst View File

@@ -0,0 +1,23 @@
1
+.. LibreBudget documentation master file, created by
2
+   sphinx-quickstart on Wed Jul 15 18:50:45 2015.
3
+   You can adapt this file completely to your liking, but it should at least
4
+   contain the root `toctree` directive.
5
+
6
+Welcome to LibreBudget
7
+======================
8
+
9
+Contents:
10
+
11
+.. toctree::
12
+   :maxdepth: 2
13
+
14
+   api
15
+
16
+
17
+Indices and tables
18
+==================
19
+
20
+* :ref:`genindex`
21
+* :ref:`modindex`
22
+* :ref:`search`
23
+

librebudget/core/__init__.py → librebudget/__init__.py View File


librebudget/core/migrations/__init__.py → librebudget/formatters/__init__.py View File


formatters/console.py → librebudget/formatters/console.py View File

@@ -1,10 +1,21 @@
1
+"""Basic console formatter."""
2
+
3
+
1 4
 class ConsoleFormatter(object):
2
-    """Formats data to be printed to a console."""
5
+    """Formats data to be printed to a console.
6
+
7
+    :param account_data: The account data from the
8
+        `librebudget.scrapers.Scraper`."""
3 9
 
4 10
     def __init__(self, account_data):
5 11
         self.account_data = account_data
6 12
 
7 13
     def as_string(self):
14
+        """Formats the account data as a string.
15
+
16
+        :return: The data formatted as a CSV string
17
+
18
+        """
8 19
         result = ''
9 20
         for account in self.account_data['accounts']:
10 21
             name = account['name']
@@ -46,6 +57,5 @@ def main():
46 57
     print(ConsoleFormatter(data).as_string())
47 58
 
48 59
 
49
-
50 60
 if __name__ == '__main__':
51 61
     main()

librebudget/librebudget/__init__.py → librebudget/scrapers/__init__.py View File


scrapers/bank_of_america.py → librebudget/scrapers/bank_of_america.py View File

@@ -6,7 +6,7 @@ from selenium import webdriver
6 6
 from selenium.common.exceptions import NoSuchElementException
7 7
 from bs4 import BeautifulSoup
8 8
 
9
-from scrapers.common import BankWebAuthenticator, BankScraper
9
+from librebudget.scrapers.common import BankWebAuthenticator, BankScraper
10 10
 
11 11
 
12 12
 class BankOfAmericaWebAuthenticator(BankWebAuthenticator):
@@ -24,14 +24,16 @@ class BankOfAmericaWebAuthenticator(BankWebAuthenticator):
24 24
         driver.find_element_by_id("id").send_keys(username)
25 25
         driver.find_element_by_id("hp-sign-in-btn").click()
26 26
         try:
27
-            driver.find_element_by_id("tlpvt-passcode-input").send_keys(password)
27
+            driver.find_element_by_id("tlpvt-passcode-input").send_keys(
28
+                password)
28 29
             driver.find_element_by_id("passcode-confirm-sk-submit").click()
29 30
         except NoSuchElementException:
30 31
             # Prompt user for challenge page
31 32
             soup = BeautifulSoup(driver.page_source)
32 33
             prompt = soup.select('label[for=tlpvt-challenge-answer]')[0].text
33 34
             answer = input(prompt.strip())
34
-            driver.find_element_by_id("tlpvt-challenge-answer").send_keys(answer)
35
+            driver.find_element_by_id("tlpvt-challenge-answer").send_keys(
36
+                answer)
35 37
             driver.find_element_by_id("verify-cq-submit").click()
36 38
         return "Your request can't be completed:" not in driver.page_source
37 39
 
@@ -69,7 +71,7 @@ class BankOfAmericaBankScraper(BankScraper):
69 71
             soup = BeautifulSoup(self.driver.page_source)
70 72
             rows = soup.select('.transaction-records tr')
71 73
             transactions = [self._tr_to_transaction(row) for row in rows]
72
-            account['transactions'] += [e for e in transactions if e]  # filter None
74
+            account['transactions'] += [e for e in transactions if e]
73 75
             self.driver.find_element_by_partial_link_text('Previous').click()
74 76
         return account
75 77
 
@@ -88,7 +90,6 @@ class BankOfAmericaBankScraper(BankScraper):
88 90
             return None
89 91
 
90 92
 
91
-
92 93
 def main():
93 94
     driver = webdriver.PhantomJS()
94 95
     credentials = (input("username: "), getpass("password: "))

scrapers/common.py → librebudget/scrapers/common.py View File

@@ -1,7 +1,5 @@
1 1
 """Module for bank website scraping interfaces and base classes."""
2 2
 
3
-from selenium.webdriver.remote.webdriver import WebDriver
4
-
5 3
 
6 4
 class BankWebAuthenticator(object):
7 5
 
@@ -15,14 +13,14 @@ class BankWebAuthenticator(object):
15 13
 
16 14
 class BankScraper(object):
17 15
     """Generic interface for a Web scraper that pulls information from
18
-    bank websites."""
16
+    bank websites.
19 17
 
20
-    def __init__(self, driver, authenticator):
21
-        """Initializes the BankScraper
18
+    :param driver: A Selenium web driver
19
+    :param authenticator: A BankWebAuthenticator
22 20
 
23
-        :param driver: A Selenium web driver
24
-        :param authenticator: A BankWebAuthenticator
25
-        """
21
+    """
22
+
23
+    def __init__(self, driver, authenticator):
26 24
         assert isinstance(authenticator, BankWebAuthenticator)
27 25
         self.driver = driver
28 26
         self.authenticator = authenticator

librebudget/librebudget/settings.py → librebudget/settings.py View File

@@ -36,7 +36,7 @@ INSTALLED_APPS = (
36 36
     'django.contrib.sessions',
37 37
     'django.contrib.messages',
38 38
     'django.contrib.staticfiles',
39
-    'core'
39
+    'librebudget_core'
40 40
 )
41 41
 
42 42
 MIDDLEWARE_CLASSES = (

librebudget/librebudget/urls.py → librebudget/urls.py View File


librebudget/librebudget/wsgi.py → librebudget/wsgi.py View File


scrapers/__init__.py → librebudget_core/__init__.py View File


librebudget/core/admin.py → librebudget_core/admin.py View File


+ 0
- 0
librebudget_core/migrations/__init__.py View File


librebudget/core/models.py → librebudget_core/models.py View File


librebudget/core/static/img/key162.png → librebudget_core/static/img/key162.png View File


librebudget/core/static/img/logo.svg → librebudget_core/static/img/logo.svg View File


librebudget/core/static/img/shield20.png → librebudget_core/static/img/shield20.png View File


librebudget/core/static/img/sprint.png → librebudget_core/static/img/sprint.png View File


librebudget/core/templates/core/index.html → librebudget_core/templates/core/index.html View File


librebudget/core/templates/core/layout.html → librebudget_core/templates/core/layout.html View File


librebudget/core/tests.py → librebudget_core/tests.py View File


librebudget/core/urls.py → librebudget_core/urls.py View File


librebudget/core/views.py → librebudget_core/views.py View File

@@ -1,4 +1,5 @@
1 1
 from django.shortcuts import render
2 2
 
3
+
3 4
 def home(request):
4 5
     return render(request, 'core/index.html')

librebudget/manage.py → manage.py View File


librebudget/sample.env → sample.env View File


+ 3
- 4
setup.py View File

@@ -1,10 +1,9 @@
1 1
 from distutils.core import setup
2 2
 
3 3
 setup(name='librebudget',
4
-      version='1.0',
4
+      version='0.1',
5 5
       description='Free personal finance tool',
6
-      author='Ian Naval',
6
+      author='Ian Adam Naval',
7 7
       author_email='ianonavy@gmail.com',
8 8
       url='https://git.ianonavy.com/ianonavy/librebudget',
9
-      packages=['scrapers', 'librebudget'],
10
-     )
9
+      packages=['librebudget', 'librebudget_core'])

Loading…
Cancel
Save