-
Notifications
You must be signed in to change notification settings - Fork 0
/
teamStatRanker.py
65 lines (49 loc) · 2.16 KB
/
teamStatRanker.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
## teamStatRanker.py ###########################################################
## Rank all teams in a given sample based on a given stat ######################
################################################################################
from sys import argv
from scrapParam import *
import statSelect
def moduleId():
return "teamStatRanker"
def description():
output = "The teamStatRanker module is used to obtain a list of the team stat values\n"
output += "for a given stat, sort the list by stat value, and print the list in\n"
output += "a prettified form to the console\n"
return output
def exampleCommand():
output = "python teamStatRanker.py nhl everything desc False CPQI\n"
output += "python teamStatRanker.py nhl everything desc True POT\n"
return output
def task(seasons, parameters):
seasons = filterSeasonsByParams(seasons, parameters)
stat = statSelect.getTargetStatContainer(parameters.getTargetStatName(), seasons, parameters.getLeagueId(), parameters.getLevelId())
if(parameters.getSortOrder() == 'asc'):
stat.printSortedContainer(parameters.getPlayoffTeamsOnly())
elif(parameters.getSortOrder() == 'desc'):
stat.printReverseSortedContainer(parameters.getPlayoffTeamsOnly())
stat.printStatBounds(parameters.getPlayoffTeamsOnly())
if(__name__ == "__main__"):
try:
leagueId = argv[1]
## ie 'watMu'
levelId = argv[2]
## ie 'beginner'
_sortOrder = argv[3]
if(_sortOrder not in ['asc', 'desc']):
print "Bad sort order argument %s supplied, must be either asc or desc" % _sortOrder
playoffTeamsOnly = argv[4]
if(playoffTeamsOnly == "True"):
playoffTeamsOnly = True
elif(playoffTeamsOnly == "False"):
playoffTeamsOnly = False
else:
print "Unable to parse option 'playoffTeamsOnly' as %s" % playoffTeamsOnly
targetStatName = argv[5]
except IndexError:
print "Arguments %s failing due to index error, see example commands for %s:\n" % (tuple(argv[1:]), argv[0])
print exampleCommand()
exit()
seasons = getAllSeasons(leagueId, levelId)
parameters = scrapParams(leagueId, levelId, playoffTeamsOnly, [], [], "Linear", targetStatName, independentStatName="None", sortOrder=_sortOrder)
task(seasons, parameters)