Skip to content

Commit 2d4a40e

Browse files
committed
Update YFPY for 2021 - drop support for Python 3.5 and add support for newer Python versions
1 parent e17dc6d commit 2d4a40e

File tree

14 files changed

+326
-204
lines changed

14 files changed

+326
-204
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ dist/
1818
test/test_output/
1919
private*.json
2020
token*.json
21-
.env
21+
test/*.env
22+
!TEST/EXAMPLE.env

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
language: python
22

33
python:
4-
- "3.5"
54
- "3.6"
65
- "3.7"
76
- "3.8"
7+
- "3.9"
8+
- "3.10"
89

910
install:
1011
- pip install -r requirements.txt

README.md

Lines changed: 40 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,10 @@
4040

4141
### Table of Contents
4242
* [About](#about)
43-
* [Usage](#usage)
43+
* [Installation](#installation)
4444
* [Setup](#setup)
45+
* [Usage](#usage)
46+
* [Testing](#testing)
4547
* [Dependencies](#dependencies)
4648
* [Troubleshooting](#troubleshooting)
4749

@@ -50,24 +52,23 @@
5052
<a name="about"></a>
5153
### About
5254

53-
YFPY is a comprehensive wrapper around the Yahoo Fantasy Sports API. It allows for easy retrieval and parsing of almost any data you might wish to extract and use from any Yahoo fantasy league to which your Yahoo account has access (or for public leagues). The primary focus of this wrapper is on fantasy football (NFL), but it also supports usage with fantasy hockey (NHL), fantasy baseball (MLB), and fantasy basketball (NBA).
54-
55-
---
55+
YFPY is a comprehensive wrapper around the Yahoo Fantasy Sports API. It allows for easy retrieval and parsing of almost any data you might wish to extract and use from any Yahoo fantasy league to which your Yahoo account has access (or for public leagues). The primary focus of this wrapper is on fantasy football (NFL), but it also supports usage with fantasy hockey (NHL), fantasy baseball (MLB), and fantasy basketball (NBA).
5656

57-
<a name="usage"></a>
58-
### Usage
57+
---
5958

60-
* In your project directory, run
59+
<a name="installation"></a>
60+
### Installation
6161

62-
```
62+
* If you wish to use YFPY within another project, from within your project directory, run
63+
```shell
6364
pip install yfpy
6465
```
6566

6667
or add `yfpy` to your project `requirements.txt`.
67-
* Follow the instructions in the below [Setup](#setup) section.
68-
* See `test/test.py` for fully functional code snippets within the query tests that demonstrate how to use YFPY.
69-
* PLEASE NOTE: Assuming you followed the setup instructions correctly, the ***first*** time you use YFPY, a browser window will open up asking you to allow your app to access your Yahoo fantasy sports data. You ***MUST*** hit allow, and then copy the verification code that pops up into the command line prompt where it will now be asking for verification, hit enter, and the OAuth2 three-legged handshake should be complete and your data should have been successfully retrieved.
70-
* YFPY should have now generated a `token.json` for you in the same directory where you stored your `private.json` credentials, and for all subsequent runs of your app, you should be able to keep retrieving Yahoo fantasy sports data using YFPY without re-verifying, since the generated refresh token should now just renew whenever you use the same `token.json` file to authenticate your app.
68+
* If you wish to download and use YFPY locally, clone the git repository:
69+
```shell
70+
git clone git@github.com:uberfastman/yfpy.git
71+
```
7172

7273
---
7374

@@ -84,15 +85,40 @@ YFPY is a comprehensive wrapper around the Yahoo Fantasy Sports API. It allows f
8485
* `API Permissions` (**Required**): check the `Fantasy Sports` checkbox. You can leave the `Read` option selected (appears in an accordion expansion underneath the `Fantasy Sports` checkbox once you select it).
8586
* Click the `Create App` button.
8687
* Once the app is created, it should redirect you to a page for your app, which will show both a `Client ID` and a `Client Secret`.
87-
* Make a copy of `examples/EXAMPLE-private.json`, rename it to just `private.json`, and copy the `Client ID` and `Client Secret` values to their respective fields (make sure the strings are wrapped regular quotes (`""`), NOT formatted quotes (`“”`)). The path to this file will be needed to point YFPY to your credentials.
88+
* Make a copy of [`test/EXAMPLE-private.json`](test/EXAMPLE-private.json), rename it to just `private.json`, and copy the `Client ID` and `Client Secret` values to their respective fields (make sure the strings are wrapped regular quotes (`""`), NOT formatted quotes (`“”`)). The path to this file will be needed to point YFPY to your credentials.
8889
* Now you should be ready to initialize the OAuth2 connection between YFPY your Yahoo account.
8990

9091
---
9192

93+
<a name="usage"></a>
94+
### Usage
95+
96+
* Follow the instructions in the [Installation](#installation) and [Setup](#setup) sections.
97+
* The ***first*** time you use YFPY, a browser window will open up asking you to allow your app to access your Yahoo fantasy sports data. You ***MUST*** hit allow, and then copy the verification code that pops up into the command line prompt where it will now be asking for verification, hit enter, and the OAuth2 three-legged handshake should be complete and your data should have been successfully retrieved.
98+
* YFPY should have now generated a `token.json` for you in the same directory where you stored your `private.json` credentials, and for all subsequent runs of your app, you should be able to keep retrieving Yahoo fantasy sports data using YFPY without re-verifying, since the generated refresh token should now just renew whenever you use the same `token.json` file to authenticate your app.
99+
100+
---
101+
102+
<a name="testing"></a>
103+
### Testing
104+
105+
YFPY has a collection of fully functional code snippets that can be run using [pytest](https://docs.pytest.org/en/6.2.x/). These snippets demonstrate how to use YFPY to retrieve your Yahoo Fantasy Sports data.
106+
107+
* See [`test/test_yfpy.py`](test/test_yfpy.py) for the example code snippets.
108+
* Before running any tests, make a copy of [`test/EXAMPLE.env`](test/EXAMPLE.env) in the [`test`](test) directory and rename it to `.env`.
109+
* Copy your Yahoo `Client ID` and `Client Secret` into the environment variables in `.env` so that pytest can use them when hitting the Yahoo Fantasy Sports API.
110+
* You can invoke the pytest tests by first changing to the test directory from the root of the YFPY repository:
111+
* `cd test`
112+
* `pytest test_yfpy.py`
113+
* If you want to run the tests from elsewhere, you will need to allow pytest to use interactive prompts:
114+
* `pytest -s test/test_yfpy.py`
115+
116+
---
117+
92118
<a name="dependencies"></a>
93119
### Dependencies
94120

95-
YFPY has only been tested on macOS, but is written to be platform agnostic. It runs only in Python 3, and has only been tested with Python 3.7.
121+
YFPY has only been tested on macOS, but is written to be platform-agnostic. It runs only in Python 3, and has only been tested from Python 3.6 through Python 3.10.
96122

97123
Direct project dependencies can be viewed in `requirements.txt`, and all dependencies, including transitive dependencies, can be viewed in `dev-requirements.txt`.
98124

dev-requirements.txt

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
1-
attrs==20.2.0
2-
certifi==2020.6.20
3-
chardet==3.0.4
4-
idna==2.10
5-
iniconfig==1.0.1
6-
more-itertools==8.5.0
7-
packaging==20.4
1+
attrs==21.2.0
2+
certifi==2021.10.8
3+
charset-normalizer==2.0.7
4+
idna==3.3
5+
iniconfig==1.1.1
6+
packaging==21.0
87
pluggy==0.13.1
9-
py==1.9.0
10-
pyaml==20.4.0
8+
py==1.10.0
9+
pyaml==21.10.1
1110
pyparsing==2.4.7
12-
pytest==6.1.0
13-
python-dotenv==0.14.0
14-
PyYAML==5.3.1
11+
pytest==6.2.5
12+
python-dotenv==0.19.1
13+
PyYAML==6.0
1514
rauth==0.7.3
16-
requests==2.24.0
17-
six==1.15.0
15+
requests==2.26.0
1816
stringcase==1.2.0
19-
toml==0.10.1
20-
urllib3==1.25.10
17+
toml==0.10.2
18+
urllib3==1.26.7
2119
yahoo-oauth==1.1

requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
yahoo-oauth==1.1
22
stringcase~=1.2.0
3-
requests
4-
pytest~=6.1.0
5-
python-dotenv~=0.14.0
3+
requests~=2.26.0
4+
pytest~=6.2.5
5+
python-dotenv~=0.19.1

setup.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import os
22
import shutil
33
import subprocess
4+
from pathlib import Path
45

56
import setuptools
67

7-
version_file = os.path.join(os.path.dirname(__file__), "VERSION")
8+
version_file = Path(__file__).parent / "VERSION"
89

910
# noinspection PyBroadException
1011
try:
@@ -16,22 +17,18 @@
1617
pypi_version = git_version[1:]
1718

1819
with open(version_file, "w") as vf:
19-
vf.write("{}{}__version__ = \"{}\"{}".format(
20-
"# DO NOT EDIT - VERSIONING CONTROLLED BY GIT TAGS",
21-
os.linesep,
22-
git_version,
23-
os.linesep
24-
))
20+
vf.write(
21+
f"# DO NOT EDIT - VERSIONING CONTROLLED BY GIT TAGS{os.linesep}__version__ = \"{git_version}\"{os.linesep}")
2522

26-
if os.path.exists("build"):
23+
if Path("build").exists():
2724
print("Removing stale \"build\" directory before packaging...")
2825
shutil.rmtree("build")
2926

30-
if os.path.exists("dist"):
27+
if Path("dist").exists():
3128
print("Removing stale \"dist\" directory before packaging...")
3229
shutil.rmtree("dist")
3330

34-
if os.path.exists("yfpy.egg-info"):
31+
if Path("yfpy.egg-info").exists():
3532
print("Removing stale \"yfpy.egg-info\" directory before packaging...")
3633
shutil.rmtree("yfpy.egg-info")
3734

@@ -45,20 +42,21 @@
4542
name="yfpy",
4643
version=pypi_version,
4744
author="Wren J. R.",
48-
author_email="wrenjr@yahoo.com",
45+
author_email="uberfastman@uberfastman.dev",
4946
description="Python API wrapper for the Yahoo Fantasy Sports public API.",
5047
long_description=long_description,
5148
long_description_content_type="text/markdown",
5249
keywords="yahoo fantasy sports api wrapper nfl football nhl hockey mlb baseball nba basketball",
5350
url="https://github.com/uberfastman/yfpy",
54-
download_url="https://github.com/uberfastman/yfpy/archive/{}.tar.gz".format(git_version),
51+
download_url=f"https://github.com/uberfastman/yfpy/archive/{git_version}.tar.gz",
5552
packages=setuptools.find_packages(),
5653
classifiers=[
5754
"Programming Language :: Python :: 3",
58-
"Programming Language :: Python :: 3.5",
5955
"Programming Language :: Python :: 3.6",
6056
"Programming Language :: Python :: 3.7",
6157
"Programming Language :: Python :: 3.8",
58+
"Programming Language :: Python :: 3.9",
59+
"Programming Language :: Python :: 3.10",
6260
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
6361
"Operating System :: OS Independent",
6462
"Development Status :: 5 - Production/Stable",

test/EXAMPLE.env

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
YFPY_CONSUMER_KEY=YAHOO_DEVELOPER_APP_CONSUMER_KEY_STRING
2+
YFPY_CONSUMER_SECRET=YAHOO_DEVELOPER_APP_CONSUMER_SECRET_STRING

0 commit comments

Comments
 (0)