-
Notifications
You must be signed in to change notification settings - Fork 0
/
scrap.py
118 lines (86 loc) · 3.5 KB
/
scrap.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
## scrap.py ####################################################################
## the scrap console: imported in the standard python interpreter ##############
################################################################################
from sys import argv
from scrapParam import *
import team
import __main__
from distStats import *
from scipy.stats import norm
from pygit2 import Repository
import statSelect
import teamStatTable
import teamStatGraph
import teamSummary
import readata
import teamStatRanker
import playerSummary
import seasonSummary
def getModulesList():
return [teamStatTable, teamStatGraph, teamSummary, readata, teamStatRanker, playerSummary, seasonSummary]
def printModulesList():
for module in getModulesList():
print module.__name__
print module
##print module.moduleId()
def getModuleByName(moduleName):
for module in getModulesList:
if(module.__name__ == moduleName):
return module
print "Unable to find module named %s, returning empty list instead" % moduleName
return []
## intentional crash here
def printModuleDescription(module):
print module.description()
def modules():
for module in getModulesList():
print module.__name__
def modulesInfo():
for module in getModulesList():
print module.__name__
print module
printModuleDescription(module)
def task(module):
module.task(seasons, params)
def info():
currentBranch = Repository('.').head.shorthand
print "Scrap Version %s on branch %s" % ("blah", currentBranch)
flatTeams = [individualTeam for yearTeamList in [season.Teams for season in seasons] for individualTeam in yearTeamList]
print "Currently loaded %i seasons in %i leagues with %i teams\n" % (len(seasons), len(set([ssn.getLeagueId() for ssn in seasons])), len(flatTeams))
print "Available task modules:\n"
modules()
def help():
## Oh wont you pleaaaaaase pleaaaaaaaaaaase help meeeee
print "Scrap Parameters are stored in scrap.params, run scrap.params.info()"
print "for information about the params\n"
print "Run scrap.modules() for a list of the available task modules\n"
print "scrap.[module name].getModuleDescription() for information on what"
print "each module does\n"
print "scrap.task([module name]) will run whatever that module is supposed to do"
if(__name__ == "scrap"):
printTitleBox("The Scrap Project")
seasons = []
loadParams = []
with open('./data/consoleLoadManifest.csv', 'rb') as foo:
loadParams = [[line.split(',')[0], line.split(',')[1].rstrip()] for line in foo]
print loadParams
for seasonBlock in loadParams:
seasons += getAllSeasons(seasonBlock[0], seasonBlock[1])
##seasons += getAllSeasons('watMu', 'beginner') + getAllSeasons('watMu', 'intermediate') + getAllSeasons('watMu', 'advanced') + getAllSeasons('watMu', 'allstar')
##seasons += getAllSeasons('wha', 'everything')
##seasons += getAllSeasons('nhl', 'current')
params = scrapParams('nhl', 'everything')
if(hasattr(__main__, '__file__')):
print "scrap imported in external module"
clearTerminal()
else:
clearTerminal()
printTitleBox("The Scrap Project")
print "type scrap.help() for information on how to use this module\nscrap.info() for diagnostics"
elif(__name__ == "__main__"):
printTitleBox("The Scrap Project")
print "The scrap.py module is meant to be run inside of the python"
print "interpreter, in order to reduce overhead time reloading resources"
print "with the new seasonParts system\n"
print "Please run the python interpreter in the directory where scrap is"
print "located and import scrap to proceed"