├── .editorconfig ├── .gitignore ├── .travis.yml ├── AUTHORS.rst ├── CONTRIBUTING.rst ├── HISTORY.rst ├── LICENSE ├── MANIFEST.in ├── Makefile ├── README.md ├── README.rst ├── docs ├── Makefile ├── authors.rst ├── conf.py ├── contributing.rst ├── history.rst ├── index.rst ├── installation.rst ├── make.bat ├── readme.rst └── usage.rst ├── fflib ├── Tables │ └── __init__.py ├── __init__.py ├── cbs │ └── __init__.py ├── common │ ├── __init__.py │ ├── json_converter.py │ ├── pretty.py │ └── table.py ├── espn │ ├── __init__.py │ ├── dao.py │ ├── parser.py │ └── team.py ├── fflib.py ├── nfl │ └── __init__.py └── yahoo │ └── __init__.py ├── requirements.txt ├── setup.cfg ├── setup.py ├── tests ├── __init__.py ├── test_fflib.py └── test_html.py └── tox.ini /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | 3 | root = true 4 | 5 | [*] 6 | indent_style = space 7 | indent_size = 4 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | charset = utf-8 11 | end_of_line = lf 12 | 13 | [*.bat] 14 | indent_style = tab 15 | end_of_line = crlf 16 | 17 | [LICENSE] 18 | insert_final_newline = false 19 | 20 | [Makefile] 21 | indent_style = tab 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.py[cod] 2 | 3 | # C extensions 4 | *.so 5 | 6 | # Packages 7 | *.egg 8 | *.egg-info 9 | dist 10 | build 11 | eggs 12 | parts 13 | bin 14 | var 15 | sdist 16 | develop-eggs 17 | .installed.cfg 18 | lib 19 | lib64 20 | 21 | # Installer logs 22 | pip-log.txt 23 | 24 | # Unit test / coverage reports 25 | .coverage 26 | .tox 27 | nosetests.xml 28 | htmlcov 29 | 30 | # Translations 31 | *.mo 32 | 33 | # Mr Developer 34 | .mr.developer.cfg 35 | .project 36 | .pydevproject 37 | 38 | # Complexity 39 | output/*.html 40 | output/*/index.html 41 | 42 | # Sphinx 43 | docs/_build 44 | 45 | # Config 46 | config.ini 47 | .idea/** 48 | .idea/*/* 49 | .idea/dictionaries -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # Config file for automatic testing at travis-ci.org 2 | 3 | language: python 4 | 5 | python: 6 | - "3.4" 7 | - "3.3" 8 | - "2.7" 9 | - "2.6" 10 | - "pypy" 11 | 12 | # command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors 13 | install: pip install -r requirements.txt 14 | 15 | # command to run tests, e.g. python setup.py test 16 | script: python setup.py test 17 | -------------------------------------------------------------------------------- /AUTHORS.rst: -------------------------------------------------------------------------------- 1 | ======= 2 | Credits 3 | ======= 4 | 5 | Development Lead 6 | ---------------- 7 | 8 | * Tyler Barber 9 | 10 | Contributors 11 | ------------ 12 | 13 | None yet. Why not be the first? 14 | -------------------------------------------------------------------------------- /CONTRIBUTING.rst: -------------------------------------------------------------------------------- 1 | ============ 2 | Contributing 3 | ============ 4 | 5 | Contributions are welcome, and they are greatly appreciated! Every 6 | little bit helps, and credit will always be given. 7 | 8 | You can contribute in many ways: 9 | 10 | Types of Contributions 11 | ---------------------- 12 | 13 | Report Bugs 14 | ~~~~~~~~~~~ 15 | 16 | Report bugs at https://github.com/twbarber/fflib/issues. 17 | 18 | If you are reporting a bug, please include: 19 | 20 | * Your operating system name and version. 21 | * Any details about your local setup that might be helpful in troubleshooting. 22 | * Detailed steps to reproduce the bug. 23 | 24 | Fix Bugs 25 | ~~~~~~~~ 26 | 27 | Look through the GitHub issues for bugs. Anything tagged with "bug" 28 | is open to whoever wants to implement it. 29 | 30 | Implement Features 31 | ~~~~~~~~~~~~~~~~~~ 32 | 33 | Look through the GitHub issues for features. Anything tagged with "feature" 34 | is open to whoever wants to implement it. 35 | 36 | Write Documentation 37 | ~~~~~~~~~~~~~~~~~~~ 38 | 39 | fflib could always use more documentation, whether as part of the 40 | official fflib docs, in docstrings, or even on the web in blog posts, 41 | articles, and such. 42 | 43 | Submit Feedback 44 | ~~~~~~~~~~~~~~~ 45 | 46 | The best way to send feedback is to file an issue at https://github.com/twbarber/fflib/issues. 47 | 48 | If you are proposing a feature: 49 | 50 | * Explain in detail how it would work. 51 | * Keep the scope as narrow as possible, to make it easier to implement. 52 | * Remember that this is a volunteer-driven project, and that contributions 53 | are welcome :) 54 | 55 | Get Started! 56 | ------------ 57 | 58 | Ready to contribute? Here's how to set up `fflib` for local development. 59 | 60 | 1. Fork the `fflib` repo on GitHub. 61 | 2. Clone your fork locally:: 62 | 63 | $ git clone git@github.com:your_name_here/fflib.git 64 | 65 | 3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development:: 66 | 67 | $ mkvirtualenv fflib 68 | $ cd fflib/ 69 | $ python setup.py develop 70 | 71 | 4. Create a branch for local development:: 72 | 73 | $ git checkout -b name-of-your-bugfix-or-feature 74 | 75 | Now you can make your changes locally. 76 | 77 | 5. When you're done making changes, check that your changes pass flake8 and the tests, including testing other Python versions with tox:: 78 | 79 | $ flake8 fflib tests 80 | $ python setup.py test 81 | $ tox 82 | 83 | To get flake8 and tox, just pip install them into your virtualenv. 84 | 85 | 6. Commit your changes and push your branch to GitHub:: 86 | 87 | $ git add . 88 | $ git commit -m "Your detailed description of your changes." 89 | $ git push origin name-of-your-bugfix-or-feature 90 | 91 | 7. Submit a pull request through the GitHub website. 92 | 93 | Pull Request Guidelines 94 | ----------------------- 95 | 96 | Before you submit a pull request, check that it meets these guidelines: 97 | 98 | 1. The pull request should include tests. 99 | 2. If the pull request adds functionality, the docs should be updated. Put 100 | your new functionality into a function with a docstring, and add the 101 | feature to the list in README.rst. 102 | 3. The pull request should work for Python 2.6, 2.7, 3.3, and 3.4, and for PyPy. Check 103 | https://travis-ci.org/twbarber/fflib/pull_requests 104 | and make sure that the tests pass for all supported Python versions. 105 | 106 | Tips 107 | ---- 108 | 109 | To run a subset of tests:: 110 | 111 | $ python -m unittest tests.test_fflib 112 | -------------------------------------------------------------------------------- /HISTORY.rst: -------------------------------------------------------------------------------- 1 | .. :changelog: 2 | 3 | History 4 | ------- 5 | 6 | 0.0.1 (2015-08-17) 7 | --------------------- 8 | 9 | * First release on PyPI. 10 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, Tyler Barber 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 6 | * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 7 | 8 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 9 | 10 | * Neither the name of fflib nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 11 | 12 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include AUTHORS.rst 2 | include CONTRIBUTING.rst 3 | include HISTORY.rst 4 | include LICENSE 5 | include README.rst 6 | 7 | recursive-include tests * 8 | recursive-exclude * __pycache__ 9 | recursive-exclude * *.py[co] 10 | 11 | recursive-include docs *.rst conf.py Makefile make.bat 12 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: clean-pyc clean-build docs clean 2 | 3 | help: 4 | @echo "clean - remove all build, test, coverage and Python artifacts" 5 | @echo "clean-build - remove build artifacts" 6 | @echo "clean-pyc - remove Python file artifacts" 7 | @echo "clean-test - remove test and coverage artifacts" 8 | @echo "lint - check style with flake8" 9 | @echo "test - run tests quickly with the default Python" 10 | @echo "test-all - run tests on every Python version with tox" 11 | @echo "coverage - check code coverage quickly with the default Python" 12 | @echo "docs - generate Sphinx HTML documentation, including API docs" 13 | @echo "release - package and upload a release" 14 | @echo "dist - package" 15 | @echo "install - install the package to the active Python's site-packages" 16 | 17 | clean: clean-build clean-pyc clean-test 18 | 19 | clean-build: 20 | rm -fr build/ 21 | rm -fr dist/ 22 | rm -fr .eggs/ 23 | find . -name '*.egg-info' -exec rm -fr {} + 24 | find . -name '*.egg' -exec rm -f {} + 25 | 26 | clean-pyc: 27 | find . -name '*.pyc' -exec rm -f {} + 28 | find . -name '*.pyo' -exec rm -f {} + 29 | find . -name '*~' -exec rm -f {} + 30 | find . -name '__pycache__' -exec rm -fr {} + 31 | 32 | clean-test: 33 | rm -fr .tox/ 34 | rm -f .coverage 35 | rm -fr htmlcov/ 36 | 37 | lint: 38 | flake8 fflib tests 39 | 40 | test: 41 | python setup.py test 42 | 43 | test-all: 44 | tox 45 | 46 | coverage: 47 | coverage run --source fflib setup.py test 48 | coverage report -m 49 | coverage html 50 | open htmlcov/index.html 51 | 52 | docs: 53 | rm -f docs/fflib.rst 54 | rm -f docs/modules.rst 55 | sphinx-apidoc -o docs/ fflib 56 | $(MAKE) -C docs clean 57 | $(MAKE) -C docs html 58 | open docs/_build/html/index.html 59 | 60 | release: clean 61 | python setup.py sdist upload 62 | python setup.py bdist_wheel upload 63 | 64 | dist: clean 65 | python setup.py sdist 66 | python setup.py bdist_wheel 67 | ls -l dist 68 | 69 | install: clean 70 | python setup.py install 71 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This Project is no longer Maintained 2 | ==================================== 3 | 4 | # fflib 5 | 6 | fflib gives access to various fantasy football league data across multiple latforms. The library is intended to provide 7 | easy access to standings, rosters, free agent, and weekly matchups for use by league managers. 8 | 9 | Currently, the only platform supported is ESPN. Others will be added in the future. 10 | 11 | fflib is available as both a web service, and python library, with additional language support planned. 12 | 13 | # espn 14 | 15 | In order to use fflib with your ESPN fantasy football data, your league will have to be open to the public. To do this, 16 | your commisioner will need nable this option in the League's settings. Simply visit: 17 | 18 | http://games.espn.go.com/ffl/leaguesetup/settings?leagueId= 19 | 20 | Make sure to replace the token with your actual league id that can be found in the address bar when 21 | you're at your league's home page. Under Basic settings, select 'Yes' from the 'Make League Viewable to Public' 22 | dropdown. Afterwards, you'll be able to access league data using this library. 23 | 24 | ## Current Planned Features 25 | 26 | - Pull League Standings, and Detail Standings 27 | - Pull Rosters from Individual Teams 28 | - Pull Free Agency List per League 29 | - Pull Transaction Counter per League 30 | - Pull Matchup Information per Matchup 31 | - Pull Leage Scoring Settings 32 | 33 | ## Config Example 34 | 35 | [espn] 36 | 37 | user.league = 574839 38 | user.season = 2015 39 | 40 | ## Display Text Based Tables 41 | 42 | +--------+---+---+---+------+----+ 43 | | TEAM | W | L | T | PCT | GB | 44 | +--------+---+---+---+------+----+ 45 | | Team 1 | 0 | 0 | 0 | .000 | -- | 46 | | Team 2 | 0 | 0 | 0 | .000 | -- | 47 | | Team 3 | 0 | 0 | 0 | .000 | -- | 48 | | Team 4 | 0 | 0 | 0 | .000 | -- | 49 | | Team 5 | 0 | 0 | 0 | .000 | -- | 50 | | Team 6 | 0 | 0 | 0 | .000 | -- | 51 | +--------+---+---+---+------+----+ 52 | 53 | ## Standings 54 | 55 | ## Teams 56 | 57 | ## Scoreboard 58 | 59 | ## Transactions 60 | 61 | ## Free Agency 62 | 63 | ## League Settings 64 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | =============================== 2 | fflib 3 | =============================== 4 | 5 | .. image:: https://img.shields.io/travis/twbarber/fflib.svg 6 | :target: https://travis-ci.org/twbarber/fflib 7 | 8 | .. image:: https://img.shields.io/pypi/v/fflib.svg 9 | :target: https://pypi.python.org/pypi/fflib 10 | 11 | 12 | Python Library for interacting with Fantasy Football Leagues. 13 | 14 | * Free software: BSD license 15 | * Documentation: https://fflib.readthedocs.org. 16 | 17 | Features 18 | -------- 19 | 20 | * TODO 21 | -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 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 gettext 23 | 24 | help: 25 | @echo "Please use \`make ' where 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 " devhelp to make HTML files and a Devhelp project" 34 | @echo " epub to make an epub" 35 | @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" 36 | @echo " latexpdf to make LaTeX files and run them through pdflatex" 37 | @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx" 38 | @echo " text to make text files" 39 | @echo " man to make manual pages" 40 | @echo " texinfo to make Texinfo files" 41 | @echo " info to make Texinfo files and run them through makeinfo" 42 | @echo " gettext to make PO message catalogs" 43 | @echo " changes to make an overview of all changed/added/deprecated items" 44 | @echo " xml to make Docutils-native XML files" 45 | @echo " pseudoxml to make pseudoxml-XML files for display purposes" 46 | @echo " linkcheck to check all external links for integrity" 47 | @echo " doctest to run all doctests embedded in the documentation (if enabled)" 48 | 49 | clean: 50 | rm -rf $(BUILDDIR)/* 51 | 52 | html: 53 | $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html 54 | @echo 55 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." 56 | 57 | dirhtml: 58 | $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml 59 | @echo 60 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." 61 | 62 | singlehtml: 63 | $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml 64 | @echo 65 | @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." 66 | 67 | pickle: 68 | $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle 69 | @echo 70 | @echo "Build finished; now you can process the pickle files." 71 | 72 | json: 73 | $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json 74 | @echo 75 | @echo "Build finished; now you can process the JSON files." 76 | 77 | htmlhelp: 78 | $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp 79 | @echo 80 | @echo "Build finished; now you can run HTML Help Workshop with the" \ 81 | ".hhp project file in $(BUILDDIR)/htmlhelp." 82 | 83 | qthelp: 84 | $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp 85 | @echo 86 | @echo "Build finished; now you can run "qcollectiongenerator" with the" \ 87 | ".qhcp project file in $(BUILDDIR)/qthelp, like this:" 88 | @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/fflib.qhcp" 89 | @echo "To view the help file:" 90 | @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/fflib.qhc" 91 | 92 | devhelp: 93 | $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp 94 | @echo 95 | @echo "Build finished." 96 | @echo "To view the help file:" 97 | @echo "# mkdir -p $$HOME/.local/share/devhelp/fflib" 98 | @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/fflib" 99 | @echo "# devhelp" 100 | 101 | epub: 102 | $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub 103 | @echo 104 | @echo "Build finished. The epub file is in $(BUILDDIR)/epub." 105 | 106 | latex: 107 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 108 | @echo 109 | @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." 110 | @echo "Run \`make' in that directory to run these through (pdf)latex" \ 111 | "(use \`make latexpdf' here to do that automatically)." 112 | 113 | latexpdf: 114 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 115 | @echo "Running LaTeX files through pdflatex..." 116 | $(MAKE) -C $(BUILDDIR)/latex all-pdf 117 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 118 | 119 | latexpdfja: 120 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 121 | @echo "Running LaTeX files through platex and dvipdfmx..." 122 | $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja 123 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 124 | 125 | text: 126 | $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text 127 | @echo 128 | @echo "Build finished. The text files are in $(BUILDDIR)/text." 129 | 130 | man: 131 | $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man 132 | @echo 133 | @echo "Build finished. The manual pages are in $(BUILDDIR)/man." 134 | 135 | texinfo: 136 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 137 | @echo 138 | @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." 139 | @echo "Run \`make' in that directory to run these through makeinfo" \ 140 | "(use \`make info' here to do that automatically)." 141 | 142 | info: 143 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 144 | @echo "Running Texinfo files through makeinfo..." 145 | make -C $(BUILDDIR)/texinfo info 146 | @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." 147 | 148 | gettext: 149 | $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale 150 | @echo 151 | @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." 152 | 153 | changes: 154 | $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes 155 | @echo 156 | @echo "The overview file is in $(BUILDDIR)/changes." 157 | 158 | linkcheck: 159 | $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck 160 | @echo 161 | @echo "Link check complete; look for any errors in the above output " \ 162 | "or in $(BUILDDIR)/linkcheck/output.txt." 163 | 164 | doctest: 165 | $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest 166 | @echo "Testing of doctests in the sources finished, look at the " \ 167 | "results in $(BUILDDIR)/doctest/output.txt." 168 | 169 | xml: 170 | $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml 171 | @echo 172 | @echo "Build finished. The XML files are in $(BUILDDIR)/xml." 173 | 174 | pseudoxml: 175 | $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml 176 | @echo 177 | @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." 178 | -------------------------------------------------------------------------------- /docs/authors.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../AUTHORS.rst 2 | -------------------------------------------------------------------------------- /docs/conf.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # fflib documentation build configuration file, created by 5 | # sphinx-quickstart on Tue Jul 9 22:26:36 2013. 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 | 19 | # If extensions (or modules to document with autodoc) are in another 20 | # directory, add these directories to sys.path here. If the directory is 21 | # relative to the documentation root, use os.path.abspath to make it 22 | # absolute, like shown here. 23 | # sys.path.insert(0, os.path.abspath('.')) 24 | 25 | # Get the project root dir, which is the parent dir of this 26 | cwd = os.getcwd() 27 | project_root = os.path.dirname(cwd) 28 | 29 | # Insert the project root dir as the first element in the PYTHONPATH. 30 | # This lets us ensure that the source package is imported, and that its 31 | # version is used. 32 | sys.path.insert(0, project_root) 33 | 34 | import fflib 35 | 36 | # -- General configuration --------------------------------------------- 37 | 38 | # If your documentation needs a minimal Sphinx version, state it here. 39 | # needs_sphinx = '1.0' 40 | 41 | # Add any Sphinx extension module names here, as strings. They can be 42 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones. 43 | extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode'] 44 | 45 | # Add any paths that contain templates here, relative to this directory. 46 | templates_path = ['_templates'] 47 | 48 | # The suffix of source filenames. 49 | source_suffix = '.rst' 50 | 51 | # The encoding of source files. 52 | # source_encoding = 'utf-8-sig' 53 | 54 | # The master toctree document. 55 | master_doc = 'index' 56 | 57 | # General information about the project. 58 | project = u'fflib' 59 | copyright = u'2015, Tyler Barber' 60 | 61 | # The version info for the project you're documenting, acts as replacement 62 | # for |version| and |release|, also used in various other places throughout 63 | # the built documents. 64 | # 65 | # The short X.Y version. 66 | version = fflib.__version__ 67 | # The full version, including alpha/beta/rc tags. 68 | release = fflib.__version__ 69 | 70 | # The language for content autogenerated by Sphinx. Refer to documentation 71 | # for a list of supported languages. 72 | # language = None 73 | 74 | # There are two options for replacing |today|: either, you set today to 75 | # some non-false value, then it is used: 76 | # today = '' 77 | # Else, today_fmt is used as the format for a strftime call. 78 | # today_fmt = '%B %d, %Y' 79 | 80 | # List of patterns, relative to source directory, that match files and 81 | # directories to ignore when looking for source files. 82 | exclude_patterns = ['_build'] 83 | 84 | # The reST default role (used for this markup: `text`) to use for all 85 | # documents. 86 | # default_role = None 87 | 88 | # If true, '()' will be appended to :func: etc. cross-reference text. 89 | # add_function_parentheses = True 90 | 91 | # If true, the current module name will be prepended to all description 92 | # unit titles (such as .. function::). 93 | # add_module_names = True 94 | 95 | # If true, sectionauthor and moduleauthor directives will be shown in the 96 | # output. They are ignored by default. 97 | # show_authors = False 98 | 99 | # The name of the Pygments (syntax highlighting) style to use. 100 | pygments_style = 'sphinx' 101 | 102 | # A list of ignored prefixes for module index sorting. 103 | # modindex_common_prefix = [] 104 | 105 | # If true, keep warnings as "system message" paragraphs in the built 106 | # documents. 107 | # keep_warnings = False 108 | 109 | 110 | # -- Options for HTML output ------------------------------------------- 111 | 112 | # The theme to use for HTML and HTML Help pages. See the documentation for 113 | # a list of builtin themes. 114 | html_theme = 'default' 115 | 116 | # Theme options are theme-specific and customize the look and feel of a 117 | # theme further. For a list of options available for each theme, see the 118 | # documentation. 119 | # html_theme_options = {} 120 | 121 | # Add any paths that contain custom themes here, relative to this directory. 122 | # html_theme_path = [] 123 | 124 | # The name for this set of Sphinx documents. If None, it defaults to 125 | # " v documentation". 126 | # html_title = None 127 | 128 | # A shorter title for the navigation bar. Default is the same as 129 | # html_title. 130 | # html_short_title = None 131 | 132 | # The name of an image file (relative to this directory) to place at the 133 | # top of the sidebar. 134 | # html_logo = None 135 | 136 | # The name of an image file (within the static path) to use as favicon 137 | # of the docs. This file should be a Windows icon file (.ico) being 138 | # 16x16 or 32x32 pixels large. 139 | # html_favicon = None 140 | 141 | # Add any paths that contain custom static files (such as style sheets) 142 | # here, relative to this directory. They are copied after the builtin 143 | # static files, so a file named "default.css" will overwrite the builtin 144 | # "default.css". 145 | html_static_path = ['_static'] 146 | 147 | # If not '', a 'Last updated on:' timestamp is inserted at every page 148 | # bottom, using the given strftime format. 149 | # html_last_updated_fmt = '%b %d, %Y' 150 | 151 | # If true, SmartyPants will be used to convert quotes and dashes to 152 | # typographically correct entities. 153 | # html_use_smartypants = True 154 | 155 | # Custom sidebar templates, maps document names to template names. 156 | # html_sidebars = {} 157 | 158 | # Additional templates that should be rendered to pages, maps page names 159 | # to template names. 160 | # html_additional_pages = {} 161 | 162 | # If false, no module index is generated. 163 | # html_domain_indices = True 164 | 165 | # If false, no index is generated. 166 | # html_use_index = True 167 | 168 | # If true, the index is split into individual pages for each letter. 169 | # html_split_index = False 170 | 171 | # If true, links to the reST sources are added to the pages. 172 | # html_show_sourcelink = True 173 | 174 | # If true, "Created using Sphinx" is shown in the HTML footer. 175 | # Default is True. 176 | # html_show_sphinx = True 177 | 178 | # If true, "(C) Copyright ..." is shown in the HTML footer. 179 | # Default is True. 180 | # html_show_copyright = True 181 | 182 | # If true, an OpenSearch description file will be output, and all pages 183 | # will contain a tag referring to it. The value of this option 184 | # must be the base URL from which the finished HTML is served. 185 | # html_use_opensearch = '' 186 | 187 | # This is the file name suffix for HTML files (e.g. ".xhtml"). 188 | # html_file_suffix = None 189 | 190 | # Output file base name for HTML help builder. 191 | htmlhelp_basename = 'fflibdoc' 192 | 193 | 194 | # -- Options for LaTeX output ------------------------------------------ 195 | 196 | latex_elements = { 197 | # The paper size ('letterpaper' or 'a4paper'). 198 | # 'papersize': 'letterpaper', 199 | 200 | # The font size ('10pt', '11pt' or '12pt'). 201 | # 'pointsize': '10pt', 202 | 203 | # Additional stuff for the LaTeX preamble. 204 | # 'preamble': '', 205 | } 206 | 207 | # Grouping the document tree into LaTeX files. List of tuples 208 | # (source start file, target name, title, author, documentclass 209 | # [howto/manual]). 210 | latex_documents = [ 211 | ('index', 'fflib.tex', 212 | u'fflib Documentation', 213 | u'Tyler Barber', 'manual'), 214 | ] 215 | 216 | # The name of an image file (relative to this directory) to place at 217 | # the top of the title page. 218 | # latex_logo = None 219 | 220 | # For "manual" documents, if this is true, then toplevel headings 221 | # are parts, not chapters. 222 | # latex_use_parts = False 223 | 224 | # If true, show page references after internal links. 225 | # latex_show_pagerefs = False 226 | 227 | # If true, show URL addresses after external links. 228 | # latex_show_urls = False 229 | 230 | # Documents to append as an appendix to all manuals. 231 | # latex_appendices = [] 232 | 233 | # If false, no module index is generated. 234 | # latex_domain_indices = True 235 | 236 | 237 | # -- Options for manual page output ------------------------------------ 238 | 239 | # One entry per manual page. List of tuples 240 | # (source start file, name, description, authors, manual section). 241 | man_pages = [ 242 | ('index', 'fflib', 243 | u'fflib Documentation', 244 | [u'Tyler Barber'], 1) 245 | ] 246 | 247 | # If true, show URL addresses after external links. 248 | # man_show_urls = False 249 | 250 | 251 | # -- Options for Texinfo output ---------------------------------------- 252 | 253 | # Grouping the document tree into Texinfo files. List of tuples 254 | # (source start file, target name, title, author, 255 | # dir menu entry, description, category) 256 | texinfo_documents = [ 257 | ('index', 'fflib', 258 | u'fflib Documentation', 259 | u'Tyler Barber', 260 | 'fflib', 261 | 'One line description of project.', 262 | 'Miscellaneous'), 263 | ] 264 | 265 | # Documents to append as an appendix to all manuals. 266 | # texinfo_appendices = [] 267 | 268 | # If false, no module index is generated. 269 | # texinfo_domain_indices = True 270 | 271 | # How to display URL addresses: 'footnote', 'no', or 'inline'. 272 | # texinfo_show_urls = 'footnote' 273 | 274 | # If true, do not generate a @detailmenu in the "Top" node's menu. 275 | # texinfo_no_detailmenu = False 276 | -------------------------------------------------------------------------------- /docs/contributing.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../CONTRIBUTING.rst 2 | -------------------------------------------------------------------------------- /docs/history.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../HISTORY.rst 2 | -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- 1 | .. fflib documentation master file, created by 2 | sphinx-quickstart on Tue Jul 9 22:26:36 2013. 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 fflib's documentation! 7 | ====================================== 8 | 9 | Contents: 10 | 11 | .. toctree:: 12 | :maxdepth: 2 13 | 14 | readme 15 | installation 16 | usage 17 | contributing 18 | authors 19 | history 20 | 21 | Indices and tables 22 | ================== 23 | 24 | * :ref:`genindex` 25 | * :ref:`modindex` 26 | * :ref:`search` 27 | 28 | -------------------------------------------------------------------------------- /docs/installation.rst: -------------------------------------------------------------------------------- 1 | ============ 2 | Installation 3 | ============ 4 | 5 | At the command line:: 6 | 7 | $ easy_install fflib 8 | 9 | Or, if you have virtualenvwrapper installed:: 10 | 11 | $ mkvirtualenv fflib 12 | $ pip install fflib 13 | -------------------------------------------------------------------------------- /docs/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | REM Command file for Sphinx documentation 4 | 5 | if "%SPHINXBUILD%" == "" ( 6 | set SPHINXBUILD=sphinx-build 7 | ) 8 | set BUILDDIR=_build 9 | set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . 10 | set I18NSPHINXOPTS=%SPHINXOPTS% . 11 | if NOT "%PAPER%" == "" ( 12 | set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% 13 | set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS% 14 | ) 15 | 16 | if "%1" == "" goto help 17 | 18 | if "%1" == "help" ( 19 | :help 20 | echo.Please use `make ^` where ^ is one of 21 | echo. html to make standalone HTML files 22 | echo. dirhtml to make HTML files named index.html in directories 23 | echo. singlehtml to make a single large HTML file 24 | echo. pickle to make pickle files 25 | echo. json to make JSON files 26 | echo. htmlhelp to make HTML files and a HTML help project 27 | echo. qthelp to make HTML files and a qthelp project 28 | echo. devhelp to make HTML files and a Devhelp project 29 | echo. epub to make an epub 30 | echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter 31 | echo. text to make text files 32 | echo. man to make manual pages 33 | echo. texinfo to make Texinfo files 34 | echo. gettext to make PO message catalogs 35 | echo. changes to make an overview over all changed/added/deprecated items 36 | echo. xml to make Docutils-native XML files 37 | echo. pseudoxml to make pseudoxml-XML files for display purposes 38 | echo. linkcheck to check all external links for integrity 39 | echo. doctest to run all doctests embedded in the documentation if enabled 40 | goto end 41 | ) 42 | 43 | if "%1" == "clean" ( 44 | for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i 45 | del /q /s %BUILDDIR%\* 46 | goto end 47 | ) 48 | 49 | 50 | %SPHINXBUILD% 2> nul 51 | if errorlevel 9009 ( 52 | echo. 53 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 54 | echo.installed, then set the SPHINXBUILD environment variable to point 55 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 56 | echo.may add the Sphinx directory to PATH. 57 | echo. 58 | echo.If you don't have Sphinx installed, grab it from 59 | echo.http://sphinx-doc.org/ 60 | exit /b 1 61 | ) 62 | 63 | if "%1" == "html" ( 64 | %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html 65 | if errorlevel 1 exit /b 1 66 | echo. 67 | echo.Build finished. The HTML pages are in %BUILDDIR%/html. 68 | goto end 69 | ) 70 | 71 | if "%1" == "dirhtml" ( 72 | %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml 73 | if errorlevel 1 exit /b 1 74 | echo. 75 | echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. 76 | goto end 77 | ) 78 | 79 | if "%1" == "singlehtml" ( 80 | %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml 81 | if errorlevel 1 exit /b 1 82 | echo. 83 | echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. 84 | goto end 85 | ) 86 | 87 | if "%1" == "pickle" ( 88 | %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle 89 | if errorlevel 1 exit /b 1 90 | echo. 91 | echo.Build finished; now you can process the pickle files. 92 | goto end 93 | ) 94 | 95 | if "%1" == "json" ( 96 | %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json 97 | if errorlevel 1 exit /b 1 98 | echo. 99 | echo.Build finished; now you can process the JSON files. 100 | goto end 101 | ) 102 | 103 | if "%1" == "htmlhelp" ( 104 | %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp 105 | if errorlevel 1 exit /b 1 106 | echo. 107 | echo.Build finished; now you can run HTML Help Workshop with the ^ 108 | .hhp project file in %BUILDDIR%/htmlhelp. 109 | goto end 110 | ) 111 | 112 | if "%1" == "qthelp" ( 113 | %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp 114 | if errorlevel 1 exit /b 1 115 | echo. 116 | echo.Build finished; now you can run "qcollectiongenerator" with the ^ 117 | .qhcp project file in %BUILDDIR%/qthelp, like this: 118 | echo.^> qcollectiongenerator %BUILDDIR%\qthelp\fflib.qhcp 119 | echo.To view the help file: 120 | echo.^> assistant -collectionFile %BUILDDIR%\qthelp\fflib.ghc 121 | goto end 122 | ) 123 | 124 | if "%1" == "devhelp" ( 125 | %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp 126 | if errorlevel 1 exit /b 1 127 | echo. 128 | echo.Build finished. 129 | goto end 130 | ) 131 | 132 | if "%1" == "epub" ( 133 | %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub 134 | if errorlevel 1 exit /b 1 135 | echo. 136 | echo.Build finished. The epub file is in %BUILDDIR%/epub. 137 | goto end 138 | ) 139 | 140 | if "%1" == "latex" ( 141 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 142 | if errorlevel 1 exit /b 1 143 | echo. 144 | echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. 145 | goto end 146 | ) 147 | 148 | if "%1" == "latexpdf" ( 149 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 150 | cd %BUILDDIR%/latex 151 | make all-pdf 152 | cd %BUILDDIR%/.. 153 | echo. 154 | echo.Build finished; the PDF files are in %BUILDDIR%/latex. 155 | goto end 156 | ) 157 | 158 | if "%1" == "latexpdfja" ( 159 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 160 | cd %BUILDDIR%/latex 161 | make all-pdf-ja 162 | cd %BUILDDIR%/.. 163 | echo. 164 | echo.Build finished; the PDF files are in %BUILDDIR%/latex. 165 | goto end 166 | ) 167 | 168 | if "%1" == "text" ( 169 | %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text 170 | if errorlevel 1 exit /b 1 171 | echo. 172 | echo.Build finished. The text files are in %BUILDDIR%/text. 173 | goto end 174 | ) 175 | 176 | if "%1" == "man" ( 177 | %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man 178 | if errorlevel 1 exit /b 1 179 | echo. 180 | echo.Build finished. The manual pages are in %BUILDDIR%/man. 181 | goto end 182 | ) 183 | 184 | if "%1" == "texinfo" ( 185 | %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo 186 | if errorlevel 1 exit /b 1 187 | echo. 188 | echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo. 189 | goto end 190 | ) 191 | 192 | if "%1" == "gettext" ( 193 | %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale 194 | if errorlevel 1 exit /b 1 195 | echo. 196 | echo.Build finished. The message catalogs are in %BUILDDIR%/locale. 197 | goto end 198 | ) 199 | 200 | if "%1" == "changes" ( 201 | %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes 202 | if errorlevel 1 exit /b 1 203 | echo. 204 | echo.The overview file is in %BUILDDIR%/changes. 205 | goto end 206 | ) 207 | 208 | if "%1" == "linkcheck" ( 209 | %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck 210 | if errorlevel 1 exit /b 1 211 | echo. 212 | echo.Link check complete; look for any errors in the above output ^ 213 | or in %BUILDDIR%/linkcheck/output.txt. 214 | goto end 215 | ) 216 | 217 | if "%1" == "doctest" ( 218 | %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest 219 | if errorlevel 1 exit /b 1 220 | echo. 221 | echo.Testing of doctests in the sources finished, look at the ^ 222 | results in %BUILDDIR%/doctest/output.txt. 223 | goto end 224 | ) 225 | 226 | if "%1" == "xml" ( 227 | %SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml 228 | if errorlevel 1 exit /b 1 229 | echo. 230 | echo.Build finished. The XML files are in %BUILDDIR%/xml. 231 | goto end 232 | ) 233 | 234 | if "%1" == "pseudoxml" ( 235 | %SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml 236 | if errorlevel 1 exit /b 1 237 | echo. 238 | echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml. 239 | goto end 240 | ) 241 | 242 | :end 243 | -------------------------------------------------------------------------------- /docs/readme.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../README.rst 2 | -------------------------------------------------------------------------------- /docs/usage.rst: -------------------------------------------------------------------------------- 1 | ======== 2 | Usage 3 | ======== 4 | 5 | To use fflib in a project:: 6 | 7 | import fflib 8 | -------------------------------------------------------------------------------- /fflib/Tables/__init__.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Tyler' 2 | -------------------------------------------------------------------------------- /fflib/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | __author__ = 'Tyler Barber' 4 | __email__ = 'tylerwbarber@gmail.com' 5 | __version__ = '0.0.1' 6 | 7 | __all__ = ['fflib', 'fflib.League', 'espn', 'espn.dao'] 8 | -------------------------------------------------------------------------------- /fflib/cbs/__init__.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Tyler' 2 | -------------------------------------------------------------------------------- /fflib/common/__init__.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Tyler' 2 | 3 | __all__ = ['pretty', 'table', 'table.StandingsTable'] 4 | -------------------------------------------------------------------------------- /fflib/common/json_converter.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Tyler' 2 | -------------------------------------------------------------------------------- /fflib/common/pretty.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Tyler' 2 | 3 | -------------------------------------------------------------------------------- /fflib/common/table.py: -------------------------------------------------------------------------------- 1 | import re 2 | 3 | 4 | class Table(object): 5 | 6 | def __init__(self, title, columns): 7 | self.title = title 8 | self.columns = columns 9 | self.rows = [] 10 | 11 | def add_row(self, values): 12 | self.rows.append(values) 13 | 14 | 15 | class StandingsTable(Table): 16 | 17 | def __init__(self, html): 18 | parsed_html = self.parse_html(html) 19 | self.division = parsed_html[0] 20 | columns = parsed_html[1] 21 | data = parsed_html[2:(len(parsed_html))] 22 | Table.__init__(self, 'Standings', columns) 23 | self.standings(data) 24 | 25 | def __repr__(self): 26 | return str(self.rows) 27 | 28 | def standings(self, data): 29 | for team in data: 30 | entry = StandingsEntry(*team) 31 | self.add_row(entry) 32 | 33 | 34 | class StandingsDetailTable(Table): 35 | def __init__(self, html): 36 | parsed_html = self.parse_html(html) 37 | self.division = parsed_html[0] 38 | columns = parsed_html[1] 39 | data = parsed_html[2:(len(parsed_html))] 40 | Table.__init__(self, 'Standings Detail', columns) 41 | self.detail(data) 42 | 43 | def __repr__(self): 44 | return str(self.rows) 45 | 46 | def detail(self, data): 47 | for team in data: 48 | entry = DetailStandingsEntry(*team) 49 | self.add_row(entry) 50 | 51 | 52 | class RosterTable(Table): 53 | 54 | def __init__(self, html): 55 | parsed_html = self.parse_html(html) 56 | columns = parsed_html[1] 57 | data = parsed_html[2:(len(parsed_html))] 58 | Table.__init__(self, 'Roster', columns) 59 | self.populate(data) 60 | 61 | def __repr__(self): 62 | return str(self.rows) 63 | 64 | def populate(self, data): 65 | starters = data[0:9] 66 | bench = data[11:len(data) - 1] 67 | full = starters + bench 68 | for i, team in enumerate(full, start=1): 69 | if len(team) == 12: 70 | team = self.scrub_bye(team) 71 | elif len(team) == 10: 72 | team = self.scrub_empty(team) 73 | entry = RosterEntry(*team) 74 | self.add_row(entry) 75 | 76 | def scrub_empty(self, team): 77 | team.extend(('--', '--', '--')) 78 | return team 79 | 80 | def scrub_bye(self, team): 81 | team.insert(4, '** BYE **') 82 | return team 83 | 84 | 85 | class FreeAgentTable(Table): 86 | 87 | def __init__(self, html): 88 | parsed_html = self.parse_html(html) 89 | columns = parsed_html[1] 90 | data = parsed_html[2:(len(parsed_html))] 91 | Table.__init__(self, 'Free Agents', columns) 92 | self.populate(data) 93 | 94 | def __repr__(self): 95 | return str(self.rows) 96 | 97 | def populate(self, data): 98 | for i, team in enumerate(data, start=1): 99 | if len(team) == 12: 100 | team = self.scrub_bye(team) 101 | elif len(team) == 10: 102 | team = self.scrub_empty(team) 103 | entry = FreeAgentEntry(*team) 104 | self.add_row(entry) 105 | 106 | def scrub_empty(self, team): 107 | team.extend(('--', '--', '--')) 108 | return team 109 | 110 | def scrub_bye(self, team): 111 | team.insert(4, '** BYE **') 112 | return team 113 | 114 | 115 | class BasicSettingsTable(Table): 116 | def __init__(self, basic_html, team_html): 117 | Table.__init__(self, 'BasicSettings', ['Key', 'Value']) 118 | self.basic_settings(basic_html) 119 | self.division_settings(team_html) 120 | 121 | def basic_settings(self, html): 122 | parsed_html = self.parse_html(html) 123 | self.league = parsed_html[1][1] 124 | self.teams = parsed_html[2][1] 125 | 126 | def division_settings(self, html): 127 | divisions = self.parse_divisions(html) 128 | self.num_divisions = len(divisions.keys()) 129 | 130 | def parse_divisions(self, table): 131 | divs = table.findAll("tr", {"class": re.compile("row*")}) 132 | data = {} 133 | for div in divs: 134 | div_name = div.find("td", {"class": re.compile("settingLabel")}).text.strip() 135 | table = div.find("table").findAll("td") 136 | team_list = [] 137 | for team in table: 138 | team_list.append(team.text.strip()) 139 | data[div_name] = team_list 140 | return data 141 | 142 | 143 | class StandingsEntry(object): 144 | 145 | def __init__(self, name, win, loss, tie, pct, gb): 146 | self.name = name 147 | self.win = win 148 | self.loss = loss 149 | self.tie = tie 150 | self.pct = pct 151 | self.gb = gb 152 | 153 | def __repr__(self): 154 | string = ( 155 | 'Team:\t' + self.name + '\n' + 156 | 'Wins:\t' + self.win + '\n' + 157 | 'Loses:\t' + self.loss + '\n' + 158 | 'Ties:\t' + self.tie + '\n' + 159 | 'Pct:\t' + self.pct + '\n' + 160 | 'GB:\t' + self.gb 161 | ) 162 | return string 163 | 164 | def values(self): 165 | values = [ 166 | self.name, 167 | self.win, 168 | self.loss, 169 | self.tie, 170 | self.pct, 171 | self.gb 172 | ] 173 | return values 174 | 175 | 176 | class RosterEntry(object): 177 | 178 | def __init__(self, slot, player_team_pos, opp, status, prk, pts, avg, last, proj, oprk, start, own, add): 179 | self.slot = slot.encode('utf-8').strip() 180 | self.player_team_pos = player_team_pos.encode('utf-8').strip() 181 | self.opp = opp.encode('utf-8').strip() 182 | self.status = status.encode('utf-8').strip() 183 | self.prk = prk.encode('utf-8').strip() 184 | self.pts = pts.encode('utf-8').strip() 185 | self.avg = avg.encode('utf-8').strip() 186 | self.last = last.encode('utf-8').strip() 187 | self.proj = proj.encode('utf-8').strip() 188 | self.oprk = oprk.encode('utf-8').strip() 189 | self.start = start.encode('utf-8').strip() 190 | self.own = own.encode('utf-8').strip() 191 | self.add = add.encode('utf-8').strip() 192 | 193 | def __repr__(self): 194 | string = ( 195 | 'Slot:\t' + self.slot + '\n' + 196 | 'Player:\t' + self.player_team_pos + '\n' + 197 | 'Opponent:\t' + self.opp + '\n' + 198 | 'Status:\t' + self.status + '\n' + 199 | 'Prk:\t' + self.prk + '\n' + 200 | 'Pts:\t' + self.pts + '\n' + 201 | 'Avg:\t' + self.avg + '\n' + 202 | 'Last:\t' + self.last + '\n' + 203 | 'Proj:\t' + self.proj + '\n' + 204 | 'Oprk:\t' + self.oprk + '\n' + 205 | 'Start:\t' + self.start + '\n' + 206 | 'Own:\t' + self.own + '\n' + 207 | 'Add/Drop:\t' + self.add 208 | ) 209 | return string 210 | 211 | def values(self): 212 | values = [ 213 | self.slot, 214 | self.player_team_pos, 215 | self.opp, 216 | self.status, 217 | self.prk, 218 | self.pts, 219 | self.avg, 220 | self.last, 221 | self.proj, 222 | self.oprk, 223 | self.start, 224 | self.own, 225 | self.add 226 | ] 227 | return values 228 | 229 | 230 | class FreeAgentEntry(object): 231 | def __init__(self, player_team_pos, team, opp, status, prk, pts, avg, last, proj, oprk, start, own, add): 232 | self.player_team_pos = player_team_pos.encode('utf-8').strip() 233 | self.team = team.encode('utf-8').strip() 234 | self.opp = opp.encode('utf-8').strip() 235 | self.status = status.encode('utf-8').strip() 236 | self.prk = prk.encode('utf-8').strip() 237 | self.pts = pts.encode('utf-8').strip() 238 | self.avg = avg.encode('utf-8').strip() 239 | self.last = last.encode('utf-8').strip() 240 | self.proj = proj.encode('utf-8').strip() 241 | self.oprk = oprk.encode('utf-8').strip() 242 | self.start = start.encode('utf-8').strip() 243 | self.own = own.encode('utf-8').strip() 244 | self.add = add.encode('utf-8').strip() 245 | 246 | def __repr__(self): 247 | string = ( 248 | 'Player:\t' + self.player_team_pos + '\n' + 249 | 'Team:\t' + self.team + '\n' + 250 | 'Opponent:\t' + self.opp + '\n' + 251 | 'Status:\t' + self.status + '\n' + 252 | 'Prk:\t' + self.prk + '\n' + 253 | 'Pts:\t' + self.pts + '\n' + 254 | 'Avg:\t' + self.avg + '\n' + 255 | 'Last:\t' + self.last + '\n' + 256 | 'Proj:\t' + self.proj + '\n' + 257 | 'Oprk:\t' + self.oprk + '\n' + 258 | 'Start:\t' + self.start + '\n' + 259 | 'Own:\t' + self.own + '\n' + 260 | 'Add/Drop:\t' + self.add 261 | ) 262 | return string 263 | 264 | def values(self): 265 | values = [ 266 | self.player_team_pos, 267 | self.team, 268 | self.opp, 269 | self.status, 270 | self.prk, 271 | self.pts, 272 | self.avg, 273 | self.last, 274 | self.proj, 275 | self.oprk, 276 | self.start, 277 | self.own, 278 | self.add 279 | ] 280 | return values 281 | 282 | 283 | class DetailStandingsEntry(object): 284 | def __init__(self, club, pf, pa, home, away, div, streak): 285 | club_info = self.parse_club(club) 286 | if len(club_info) == 1: 287 | self.team = club_info[0] 288 | self.owner = '' 289 | else: 290 | self.team = club_info[0] 291 | self.owner = club_info[1] 292 | self.pf = pf 293 | self.pa = pa 294 | self.home = home 295 | self.away = away 296 | self.div = div 297 | self.streak = streak 298 | 299 | def __repr__(self): 300 | string = ( 301 | 'Team:\t' + self.team + '\n' + 302 | 'Owner:\t' + self.owner + '\n' + 303 | 'PF:\t' + self.pf + '\n' + 304 | 'PA:\t' + self.pa + '\n' + 305 | 'Home:\t' + self.home + '\n' + 306 | 'Away:\t' + self.away + '\n' + 307 | 'Div:\t' + self.div + '\n' + 308 | 'Streak:\t' + self.streak + '\n' 309 | ) 310 | return string 311 | 312 | def parse_club(self, club): 313 | club_info = club.split('(') 314 | if len(club_info) == 1: 315 | return club_info 316 | club_info[0] = club_info[0][:-1] 317 | club_info[1] = club_info[1][:-1] 318 | return club_info 319 | -------------------------------------------------------------------------------- /fflib/espn/__init__.py: -------------------------------------------------------------------------------- 1 | __all__ = ['dao', 'dao.EspnDao'] 2 | -------------------------------------------------------------------------------- /fflib/espn/dao.py: -------------------------------------------------------------------------------- 1 | from bs4 import BeautifulSoup 2 | import mechanize 3 | import re 4 | from fflib.common.table import StandingsTable, StandingsDetailTable, RosterTable, BasicSettingsTable, FreeAgentTable 5 | from fflib.espn.parser import Parser 6 | 7 | 8 | class EspnDao(object): 9 | 10 | def __init__(self, config): 11 | self.config = dict(config.items('espn')) 12 | self.league = self.config.get('user.league') 13 | self.season = self.config.get('user.season') 14 | self.browser = self.connect() 15 | self.basic_settings() 16 | 17 | def connect(self): 18 | return mechanize.Browser() 19 | 20 | def standings(self): 21 | 22 | html = self.standings_html() 23 | tables = Parser.standings_values(html) 24 | standings_map = {} 25 | standings_map["east"] = StandingsTable(tables[0]) 26 | standings_map["west"] = StandingsTable(tables[1]) 27 | return standings_map 28 | 29 | def standings_detail(self): 30 | 31 | html = self.standings_html() 32 | soup = BeautifulSoup(html, "html.parser") 33 | tables = soup.findAll("table", {"class": "tableBody"}) 34 | standings_map = {} 35 | standings_map["east"] = StandingsDetailTable(tables[2]) 36 | standings_map["west"] = StandingsDetailTable(tables[3]) 37 | return standings_map 38 | 39 | def roster(self, team): 40 | html = self.roster_html(team) 41 | soup = BeautifulSoup(html, "html.parser") 42 | roster_html = soup.find("table", id=re.compile('playertable_')) 43 | roster_table = RosterTable(roster_html) 44 | return roster_table 45 | 46 | def rosters(self): 47 | x = 1 48 | rosters = {} 49 | while x <= 12: 50 | rosters[x] = self.roster(x) 51 | x += 1 52 | return rosters 53 | 54 | def free_agents(self): 55 | html = self.free_agent_html() 56 | free_agent_table = FreeAgentTable(html) 57 | return free_agent_table 58 | 59 | def basic_settings(self): 60 | html = self.settings_html() 61 | soup = BeautifulSoup(html, "html.parser") 62 | basic_html = soup.find("div", {"name": re.compile("basic")}).find("table") 63 | team_html = soup.find("div", {"name": re.compile("info")}).find("table") 64 | table = BasicSettingsTable(basic_html, team_html) 65 | 66 | def standings_html(self): 67 | url = UrlConstants.STANDINGS_URL.format(self.league, self.season) 68 | return self.get_html(url) 69 | 70 | def standings_detail_html(self): 71 | url = UrlConstants.STANDINGS_URL.format(self.league, self.season) 72 | return self.get_html(url) 73 | 74 | def roster_html(self, team): 75 | url = UrlConstants.ROSTER_URL.format(self.league, team, self.season) 76 | return self.get_html(url) 77 | 78 | def free_agent_html(self): 79 | url = UrlConstants.FA_URL.format(self.league, self.season) 80 | return self.get_html(url) 81 | 82 | def settings_html(self): 83 | url = UrlConstants.SETTINGS_URL.format(self.league) 84 | return self.get_html(url) 85 | 86 | def get_html(self, url): 87 | self.browser.open(url) 88 | return self.browser.response().read() 89 | 90 | 91 | class UrlConstants: 92 | 93 | STANDINGS_URL = 'http://games.espn.go.com/ffl/standings?leagueId={0}&seasonId={1}' 94 | SCOREBOARD_URL = 'http://games.espn.go.com/ffl/scoreboard?leagueId={0}&seasonId={1}' 95 | ROSTER_URL = 'http://games.espn.go.com/ffl/clubhouse?leagueId={0}&teamId={1}&seasonId={2}' 96 | FA_URL = 'http://games.espn.go.com/ffl/freeagency?leagueId={0}&seasonId={1}' 97 | SCORING_URL = 'http://games.espn.go.com/ffl/}eaders?leagueId={0}&teamId={1}&scoringPeriodId={2}' 98 | WAIVER_URL = 'http://games.espn.go.com/ffl/tools/waiverorder?leagueId={0}' 99 | SETTINGS_URL = 'http://games.espn.go.com/ffl/leaguesetup/settings?leagueId={0}' 100 | -------------------------------------------------------------------------------- /fflib/espn/parser.py: -------------------------------------------------------------------------------- 1 | import re 2 | from bs4 import BeautifulSoup 3 | 4 | 5 | class Parser(object): 6 | 7 | def parse_rows(self, table): 8 | rows = table.findAll('tr') 9 | data = [] 10 | for row in rows: 11 | cols = row.findAll('td') 12 | cols = [ele.text.strip() for ele in cols] 13 | data.append([ele for ele in cols if ele]) 14 | return data 15 | 16 | def scrub_empty(self, team): 17 | team.extend(('--', '--', '--')) 18 | return team 19 | 20 | def scrub_bye(self, team): 21 | team.insert(4, '** BYE **') 22 | return team 23 | 24 | def standings_values(self, html): 25 | soup = BeautifulSoup(html, "html.parser") 26 | tables = soup.findAll("table", {"class": "tableBody"}) 27 | values = parse 28 | return tables 29 | 30 | def standings_detail_values(self, html): 31 | return 32 | 33 | def roster_values(self, html): 34 | return 35 | 36 | def free_agent_values(self, html): 37 | soup = BeautifulSoup(html, "html.parser") 38 | free_agent_html = soup.find("table", id=re.compile('playertable_')) 39 | return 40 | -------------------------------------------------------------------------------- /fflib/espn/team.py: -------------------------------------------------------------------------------- 1 | class Team(object): 2 | 3 | def __init__(self, name=None, owner=None, roster=None): 4 | self.name = name 5 | self.owner = owner 6 | self.roster = roster 7 | 8 | 9 | 10 | 11 | class Roster(object): 12 | 13 | def __init__(self, players): 14 | self.parse_roster(players) 15 | 16 | def parse_roster(self, players): 17 | 18 | self.qb 19 | se\ 20 | -------------------------------------------------------------------------------- /fflib/fflib.py: -------------------------------------------------------------------------------- 1 | import ConfigParser 2 | from espn.dao import EspnDao 3 | 4 | 5 | class League(object): 6 | 7 | def __init__(self, platform): 8 | if platform in ['ESPN']: 9 | self.platform = 'ESPN' 10 | self.config = self.config() 11 | self.dao = EspnDao(self.config) 12 | 13 | def teams(self): 14 | return 15 | 16 | def team(self, team_name): 17 | return 18 | 19 | def team(self, team_id): 20 | return 21 | 22 | def standings(self, division): 23 | tables = self.dao.standings(division) 24 | return tables 25 | 26 | def detail_standings(self): 27 | tables = self.dao.standings_detail() 28 | return tables 29 | 30 | def free_agents(self): 31 | tables = self.dao.free_agents() 32 | return tables 33 | 34 | def settings(self): 35 | return 36 | 37 | def config(self): 38 | parser = ConfigParser.RawConfigParser() 39 | parser.read('../config.ini') 40 | return parser 41 | -------------------------------------------------------------------------------- /fflib/nfl/__init__.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Tyler' 2 | -------------------------------------------------------------------------------- /fflib/yahoo/__init__.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Tyler' 2 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | mechanize 2 | wheel==0.23.0 3 | -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [wheel] 2 | universal = 1 3 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | try: 6 | from setuptools import setup 7 | except ImportError: 8 | from distutils.core import setup 9 | 10 | with open('README.rst') as readme_file: 11 | readme = readme_file.read() 12 | 13 | with open('HISTORY.rst') as history_file: 14 | history = history_file.read().replace('.. :changelog:', '') 15 | 16 | requirements = [ 17 | # TODO: put package requirements here 18 | ] 19 | 20 | test_requirements = [ 21 | # TODO: put package test requirements here 22 | ] 23 | 24 | setup( 25 | name='fflib', 26 | version='0.0.1', 27 | description="Python Library for interacting with Fantasy Football Leagues.", 28 | long_description=readme + '\n\n' + history, 29 | author="Tyler Barber", 30 | author_email='tylerwbarber@gmail.com', 31 | url='https://github.com/twbarber/fflib', 32 | packages=[ 33 | 'fflib', 34 | ], 35 | package_dir={'fflib': 36 | 'fflib'}, 37 | include_package_data=True, 38 | install_requires=requirements, 39 | license="BSD", 40 | zip_safe=False, 41 | keywords='fflib', 42 | classifiers=[ 43 | 'Development Status :: 2 - Pre-Alpha', 44 | 'Intended Audience :: Developers', 45 | 'License :: OSI Approved :: BSD License', 46 | 'Natural Language :: English', 47 | "Programming Language :: Python :: 2", 48 | 'Programming Language :: Python :: 2.6', 49 | 'Programming Language :: Python :: 2.7', 50 | 'Programming Language :: Python :: 3', 51 | 'Programming Language :: Python :: 3.3', 52 | 'Programming Language :: Python :: 3.4', 53 | ], 54 | test_suite='tests', 55 | tests_require=test_requirements 56 | ) 57 | -------------------------------------------------------------------------------- /tests/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | -------------------------------------------------------------------------------- /tests/test_fflib.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | """ 5 | test_fflib 6 | ---------------------------------- 7 | 8 | Tests for `fflib` module. 9 | """ 10 | from fflib import fflib 11 | 12 | """ 13 | league = fflib.League('ESPN') 14 | standings_map = league.standings() 15 | print(standings_map["east"].rows) 16 | print(standings_map["west"].rows) 17 | """ 18 | league = fflib.League('ESPN') 19 | standings_map = league.free_agents() 20 | print(standings_map) 21 | 22 | """ 23 | table = PrettyTable(standings_w.columns) 24 | table.align[standings_w.columns[0]] = 'l' 25 | for i, row in enumerate(standings_w.rows, start=1): 26 | table.add_row(standings_w.rows[i].values()) 27 | print(table) 28 | 29 | class TestFflib(unittest.TestCase): 30 | def setUp(self): 31 | pass 32 | 33 | def test_something(self): 34 | pass 35 | 36 | def tearDown(self): 37 | pass 38 | """ 39 | -------------------------------------------------------------------------------- /tests/test_html.py: -------------------------------------------------------------------------------- 1 | import mechanize 2 | from bs4 import BeautifulSoup, SoupStrainer 3 | import re 4 | 5 | league = "574839" 6 | season = "2015" 7 | 8 | 9 | def standings_html(): 10 | url = UrlConstants.STANDINGS_URL.format(league, season) 11 | return get_html(url) 12 | 13 | 14 | def standings_detail_html(): 15 | url = UrlConstants.STANDINGS_URL.format(league, season) 16 | return get_html(url) 17 | 18 | 19 | def roster_html(team): 20 | url = UrlConstants.ROSTER_URL.format(league, team, season) 21 | return get_html(url) 22 | 23 | 24 | def free_agent_html(team): 25 | url = UrlConstants.FA_URL.format(team) 26 | return self.get_html(url) 27 | 28 | 29 | def transaction_html(): 30 | url = UrlConstants.TRANSACTIONS_URL.format(self.league) 31 | return self.get_html(url) 32 | 33 | 34 | def settings_html(): 35 | url = UrlConstants.TRANSACTIONS_URL.format(self.league) 36 | return self.get_html(url) 37 | 38 | 39 | def get_html(url): 40 | browser = mechanize.Browser() 41 | browser.open(url) 42 | return browser.response().read() 43 | 44 | 45 | class UrlConstants: 46 | 47 | STANDINGS_URL = 'http://games.espn.go.com/ffl/standings?leagueId={0}&seasonId={1}' 48 | SCOREBOARD_URL = 'http://games.espn.go.com/ffl/scoreboard?leagueId={0}&seasonId={1}' 49 | ROSTER_URL = 'http://games.espn.go.com/ffl/clubhouse?leagueId={0}&teamId={1}&seasonId={2}' 50 | FA_URL = 'http://games.espn.go.com/ffl/freeagency?leagueId={0}&teamId={1}' 51 | SCORING_URL = 'http://games.espn.go.com/ffl/}eaders?leagueId={0}&teamId={1}&scoringPeriodId={2}' 52 | WAIVER_URL = 'http://games.espn.go.com/ffl/tools/waiverorder?leagueId={0}' 53 | TRANSACTIONS_URL = 'http://games.espn.go.com/ffl/tools/transactioncounter?leagueId={0}' 54 | SETTINGS_URL = 'http://games.espn.go.com/ffl/leaguesetup/settings?leagueId={0}' 55 | 56 | 57 | ROSTER_URL = 'http://games.espn.go.com/ffl/clubhouse?leagueId={0}&teamId={1}&seasonId={2}' 58 | 59 | only_tags_with_id_link2 = SoupStrainer(id=re.compile("playertable_")) 60 | 61 | -------------------------------------------------------------------------------- /tox.ini: -------------------------------------------------------------------------------- 1 | [tox] 2 | envlist = py26, py27, py33, py34 3 | 4 | [testenv] 5 | setenv = 6 | PYTHONPATH = {toxinidir}:{toxinidir}/fflib 7 | commands = python setup.py test 8 | deps = 9 | -r{toxinidir}/requirements.txt 10 | --------------------------------------------------------------------------------