-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli.py
executable file
·35 lines (31 loc) · 1.27 KB
/
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
import yahoo_fantasy_api as yfa
from yahoo_oauth import OAuth2
class cli():
def __init__(self, passedOAuth):
self.oauth = passedOAuth
def getLeagueName(self,passedLeagueValue):
return yfa.League(self.oauth, passedLeagueValue).settings()['name']
def chooseLeague(self, possibleChoices,possibleLeagues):
print('Choose from the following League IDs:')
print('----------------------------------')
for index, league in enumerate(possibleLeagues):
leagueName = self.getLeagueName(league)
print(
f'Index: {index} League Name: {leagueName} League ID: {league}'
)
print('----------------------------------')
while True:
returnLeague = input(
"Input the index you're selecting or type -1 to exit: ")
try:
if returnLeague == '-1':
print('Exiting...')
exit()
elif int(returnLeague) > -1 and int(
returnLeague) <= possibleChoices:
return int(returnLeague)
break
else:
print('-Error: Invalid Index!-')
except ValueError:
print('-Error: Invalid Input!-')