-
Notifications
You must be signed in to change notification settings - Fork 0
/
tgf-cli.py
43 lines (35 loc) · 1.36 KB
/
tgf-cli.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env python3
'''
# tgf-cli.py
# interactive search of player_game_finder
# shows defense vs. position (team totals)
'''
import logging
import click
from nfl.tgf import TeamGameFinder
@click.command()
@click.option('-y', '--seas', default=None, type=click.IntRange(2010, 2021),
help='NFL season')
@click.option('-p', '--pos', type=click.Choice(['qb', 'wr', 'te', 'rb']),
default=None, help='Player position')
@click.option('-o', '--opp', type=str, default=None,
help='Team code')
@click.option('-t', '--thresh', type=click.FloatRange(0, 20), default=0,
help='Fantasy points threshold')
@click.option('-h', '--path', type=str, default='/tmp',
help='Save path')
@click.option('-c', '--cache_name', type=str, default='pgf-cli',
help='Name for cache')
def run(seas, pos, opp, thresh, path, cache_name):
logger = logging.getLogger(__name__)
hdlr = logging.FileHandler(f"{path}/tgf.log")
formatter = logging.Formatter("%(asctime)s %(levelname)s %(message)s")
hdlr.setFormatter(formatter)
logger.addHandler(hdlr)
logger.setLevel(logging.ERROR)
tgf = TeamGameFinder(seas=seas, pos=pos, opp=opp,
thresh=thresh, path=path,
cache_name=cache_name)
tgf.cmdloop()
if __name__ == '__main__':
run()