-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3786a2c
commit 01fb3ed
Showing
9 changed files
with
266 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: Upload release to PyPI | ||
|
||
on: | ||
push: | ||
tags: | ||
- '*' | ||
|
||
jobs: | ||
pypi-publish: | ||
name: Upload release to PyPI | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: pypi | ||
url: https://pypi.org/project/sportify/ | ||
permissions: | ||
id-token: write | ||
steps: | ||
- name: Checkout source | ||
uses: actions/checkout@main | ||
- name: Install Python 3.12 | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.12' | ||
- name: Install build tool | ||
run: >- | ||
pip install build | ||
- name: Build package | ||
run: >- | ||
python -m build | ||
- name: Publish to PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
__pycache__ | ||
*.pyc | ||
*.pyc | ||
dist | ||
_version.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.PHONY: clean build install run test | ||
DEFAULT: install | ||
|
||
clean: | ||
rm -rf dist .tox | ||
build: clean | ||
python3 -m build | ||
install: build | ||
pipx install dist/*.tar.gz --force | ||
run: | ||
sportify |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
[build-system] | ||
requires = ["hatchling", "hatch-vcs"] | ||
build-backend = "hatchling.build" | ||
|
||
[project] | ||
dynamic = ["version"] | ||
name = "sportify" | ||
description = "Fetch sports data from CLI" | ||
readme = "README.md" | ||
requires-python = ">=3.7" | ||
license = {file = "LICENSE"} | ||
keywords = ["sports", "athletics", "data", "executable", "application", "cli", "espn"] | ||
authors = [ | ||
{name = "Jacob A. Thompson", email = "jacobalthompson@gmail.com"} | ||
] | ||
maintainers = [ | ||
{name = "Jacob A. Thompson", email = "jacobalthompson@gmail.com"} | ||
] | ||
classifiers = [ | ||
"Development Status :: 5 - Production/Stable", | ||
"Topic :: Games/Entertainment", | ||
"License :: OSI Approved :: MIT License", | ||
"Programming Language :: Python :: 3", | ||
"Programming Language :: Python :: 3.7", | ||
"Programming Language :: Python :: 3.8", | ||
"Programming Language :: Python :: 3.9", | ||
"Programming Language :: Python :: 3.10", | ||
"Programming Language :: Python :: 3.11", | ||
"Programming Language :: Python :: 3.12", | ||
"Programming Language :: Python :: 3.13", | ||
"Programming Language :: Python :: 3 :: Only", | ||
] | ||
dependencies = ["python-dateutil", "requests", "simple_term_menu"] | ||
|
||
[project.urls] | ||
"Homepage" = "https://github.com/jacob-thompson/sportify" | ||
"Bug Reports" = "https://github.com/jacob-thompson/sportify/issues" | ||
|
||
[project.gui-scripts] | ||
sportify = "sportify.main:main" | ||
|
||
[tool.hatch.version] | ||
source = "vcs" | ||
|
||
[tool.hatch.build.hooks.vcs] | ||
version-file = "_version.py" |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from .sportify import * | ||
|
||
def main(): | ||
print(f"{PROJECT} {PROJECT_URL}") | ||
|
||
leagues = list(MENU_DATA.keys()) | ||
try: # get input & request output | ||
menu = Menu(leagues, title = "LEAGUE", clear_screen = True) | ||
entry = menu.show() | ||
selected_league = leagues[entry] | ||
|
||
teams = [MENU_DATA[league] for league in leagues if league == selected_league] | ||
assert teams != [] | ||
|
||
submenu = Menu(teams[0], title = "TEAM", clear_screen = True) | ||
entry = submenu.show() | ||
selected_team = teams[0][entry] | ||
|
||
data = request_data(selected_league.split()[1], selected_team.split()[1]) | ||
except BadAPIRequest as error: | ||
print(error) | ||
raise SystemExit(EXIT_FAIL) | ||
except TypeError: # occurs when user presses Escape or Q to quit | ||
raise SystemExit(EXIT_OK) | ||
except AssertionError: # impossible | ||
print(UNEXPECTED) | ||
raise SystemExit(EXIT_FAIL) | ||
|
||
output(data) | ||
raise SystemExit(EXIT_OK) | ||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
PROJECT = "sportify" | ||
PROJECT_URL = f"https://github.com/jacob-thompson/{PROJECT}" | ||
API_URL = "https://site.api.espn.com/apis/site/v2/sports/" | ||
|
||
ERR = "ERROR:" | ||
REPORT = f"PLEASE SUBMIT AN ISSUE REPORT:\n\t{PROJECT_URL}/issues" | ||
UNEXPECTED = f"{ERR} AN UNEXPECTED ERROR HAS OCCURRED\n{REPORT}" | ||
|
||
SPORTS = { | ||
"football": { | ||
"NFL" | ||
}, | ||
"basketball": { | ||
"NBA" | ||
}, | ||
"baseball": { | ||
"MLB" | ||
}, | ||
"hockey": { | ||
"NHL" | ||
} | ||
} | ||
|
||
MENU_DATA = { | ||
"[1] NFL": [ | ||
"[1] ARI", "[2] ATL", "[3] BAL", "[4] BUF", | ||
"[5] CAR", "[6] CHI", "[7] CIN", "[8] CLE", | ||
"[9] DAL", "[0] DEN", "[a] DET", "[b] GB", | ||
"[c] HOU", "[d] IND", "[e] JAX", "[f] KC", | ||
"[g] LV", "[h] LAC", "[i] LAR", "[j] MIA", | ||
"[k] MIN", "[l] NE", "[m] NO", "[n] NYG", | ||
"[o] NYJ", "[p] PHI", "[q] PIT", "[r] SF", | ||
"[s] SEA", "[t] TB", "[u] TEN", "[v] WSH" | ||
], | ||
"[2] NBA": [ | ||
"[1] ATL", "[2] BOS", "[3] BKN", "[4] CHA", | ||
"[5] CHI", "[6] CLE", "[7] DAL", "[8] DEN", | ||
"[9] DET", "[0] GS", "[a] HOU", "[b] IND", | ||
"[c] LAC", "[d] LAL", "[e] MEM", "[f] MIA", | ||
"[g] MIL", "[h] MIN", "[i] NO", "[j] NY", | ||
"[k] OKC", "[l] ORL", "[m] PHI", "[n] PHX", | ||
"[o] POR", "[p] SAC", "[q] SA", "[r] TOR", | ||
"[s] UTAH", "[t] WSH" | ||
], | ||
"[3] MLB": [ | ||
"[1] ARI", "[2] ATL", "[3] BAL", "[4] BOS", | ||
"[5] CHW", "[6] CHC", "[7] CIN", "[8] CLE", | ||
"[9] COL", "[0] DET", "[a] HOU", "[b] KC", | ||
"[c] LAA", "[d] LAD", "[e] MIA", "[f] MIL", | ||
"[g] MIN", "[h] NYY", "[i] NYM", "[j] OAK", | ||
"[k] PHI", "[l] PIT", "[m] SD", "[n] SF", | ||
"[o] SEA", "[p] STL", "[q] TB", "[r] TEX", | ||
"[s] TOR", "[t] WSH" | ||
], | ||
"[4] NHL": [ | ||
"[1] ANA", "[2] BOS", "[3] BUF", "[4] CGY", | ||
"[5] CAR", "[6] CHI", "[7] COL", "[8] CBJ", | ||
"[9] DAL", "[0] DET", "[a] EDM", "[b] FLA", | ||
"[c] LA", "[d] MIN", "[e] MTL", "[f] NSH", | ||
"[g] NJ", "[h] NYI", "[i] NYR", "[j] OTT", | ||
"[k] PHI", "[l] PIT", "[m] SJ", "[n] SEA", | ||
"[o] STL", "[p] TB", "[q] TOR", "[r] UTAH", | ||
"[s] VAN", "[t] VGK", "[u] WSH", "[v] WPG" | ||
] | ||
} | ||
|
||
API_OK = 200 | ||
EXIT_OK = 0 | ||
EXIT_FAIL = 1 |
Oops, something went wrong.