def createInitTeams(self, dsn): app.storeT = StoreTeam(app.config['dsn']) newTeam = team('Turkey', 'Male', '1920', '4') app.storeT.addTeam(newTeam, dsn) newTeam2 = team('England', 'Male', '1936', '3') app.storeT.addTeam(newTeam2, dsn) newTeam3 = team('China', 'Male', '1906','5') app.storeT.addTeam(newTeam3, dsn) newTeam4 = team('Russia', 'Female', '1943','1') app.storeT.addTeam(newTeam4, dsn)
def readFromFile(readFile): if os.path.isfile(readFile): f = open(readFile, 'r') lines = f.readlines() del lines[0] #top line is header for line in lines: line=line.lower() while not -1 == line.find(",,"): line = line.replace(",,", ",0,") #gets rid of blanks line = line.replace(",**,", ",0,") #get rid of missings playerStats = line.split(',') numList = [1, 2, 3, 6, 7, 8, 10, 11, 12] #stats that are numbers for x in range(len(playerStats)): if x in numList: #print playerStats playerStats[x] = float(playerStats[x]) #makes the numbered stats numbers #uploads a play #occasionaly there will be no offensive team, this adds the offensive team from the previous play, seems to be pretty accurate. if "0" in playerStats[4]: playerStats[4]=tempPlay.offense tempPlay = play.play(*playerStats) # adds all the teams add = True for y in teamGroup: if y.name == tempPlay.offense: y.addPlay(tempPlay, True)#adds play if team is added add = False break if add: tempTeam = team.team(tempPlay.offense) tempTeam.addPlay(tempPlay, True) #adds if team needed adding teamGroup.append(tempTeam) #addsteam #same for Defense below add = True for y in teamGroup: if y.name == tempPlay.defense: y.addPlay(tempPlay, False) add = False break if add: tempTeam = team.team(tempPlay.defense) tempTeam.addPlay(tempPlay, False) teamGroup.append(tempTeam)
def read_team_list(filename = "teams.csv"): """ function readTeamList will read in the team list from a csv file (default value is teams.csv) The format for the file is: teamID, team Name The data is stored in a dictionary with the team ID as the key value Input: string filename Return: dict team dictionary """ teamDict = {} csvFile = open(filename,"r",newline='') csvReader = csv.reader(csvFile,dialect='excel') index = -1 for row in csvReader: if index >= 0: # # first row is the header newTeam = team.team(int(row[0]),row[1],index) teamDict[int(row[0])] = newTeam index = index + 1 return teamDict
def register(self): s1 = team.team() red = [] blue = [] arena = ["Balewadi", "Pandharpur", "Registhan"] teamname = s1.display(1) for i in range(len(teamname)): if i % 2 == 0: red.append(teamname[i]) else: blue.append(teamname[i]) if len(red) > len(blue): blue.append("BY") else: red.append("BY") i = 0 j = 0 counter = 1 while i < len(red) and j < len(blue): sql = "insert into COMPETITION values(%s,%s,%s,%s);" % ( ('"' + "C 0" + str(counter) + '"'), ('"' + str(random.choice(arena)) + '"'), ('"' + str(red[i]) + '"'), ('"' + str(blue[j]) + '"')) counter += 1 i += 1 j += 1 self.cursor.execute(sql) self.db.commit() print "Fixtures Preapared Successful.."
def teams(): dsn = app.config['dsn'] app.store = StoreTeam(dsn) if request.method == 'GET': allTeams = app.store.getAllTeams(dsn) elif 'delete' in request.form: ids = request.form.getlist('teams') for id in ids: app.store.deleteTeam(id, dsn) allTeams = app.store.getAllTeams(dsn) elif 'add' in request.form: nation = request.form['nationToAdd'] gender = request.form['genderToAdd'] foundDate = request.form['foundDateToAdd'] timesWon = request.form['timesWonToAdd'] newTeam = team(nation, gender, foundDate, timesWon) app.store.addTeam(newTeam, dsn) allTeams = app.store.getAllTeams(dsn) elif 'update' in request.form: ids = request.form.getlist('teams') id = ids[0] nation = request.form['nationToUpdate'] gender = request.form['genderToUpdate'] foundDate = request.form['foundDateToUpdate'] timesWon = request.form['timesWonToUpdate'] updatedTeam = team(nation, gender, foundDate, timesWon) app.store.updateTeam(updatedTeam, id, dsn) allTeams = app.store.getAllTeams(dsn) elif 'find' in request.form: nation = request.form['nationToFind'] gender = request.form['genderToFind'] foundDate = request.form['foundDateToFind'] timesWon = request.form['timesWonToFind'] findTeam = team(nation, gender, foundDate, timesWon) allTeams = app.store.selectTeams(findTeam, dsn) return render_template('teams.html', teams = allTeams)
def __init__(self, league_id, num_teams): name = "League_%d" % (league_id) self.name = name self.num_teams = num_teams self.team = [] print("Creating League %d (%s) with %d teams" % (league_id, self.name, num_teams)) for i in range(0, num_teams): name = "%s_%d" % (self.name, i) print("Creating team %d %s" % (i, name)) self.team.append(team.team(name, league_id))
def populateTeams(self): numTeams = 20 if self.year <= 1994: numTeams = 22 games = self.games teams = dict() num = 0 # interates though games and attempts to add both teams to the teams # dictionary. Breaks out of the loop when there are 20 teams. for i in range(len(games)): game = self.games[i] # TODO: Create refernce to team object if(not(game.home in teams)): teams[game.home] = team.team(game.home) num += 1 if(game.away not in teams): teams[game.away] = team.team(game.away) num += 1 if num >= numTeams: break return teams
def compute(start, stop): datadir = os.path.expanduser('~') + "/FSA/data/teamdatabyyear/" with open(os.path.expanduser('~') + '/FSA/1ia/features/teamHeaders.csv', 'r') as f: headers = f.readlines() headers = [h.strip() for h in headers] with open(os.path.expanduser('~') + '/FSA/1ia/features/headersForComputed.csv', 'r') as f: headersForComputed = f.readlines() headersForComputed = [h.strip() for h in headersForComputed] DVOA = load.getDVOA() DVOAheaders = DVOA.columns[3:].tolist() print headers + DVOAheaders # iterate over the years for year in range(start, stop+1): season = load.loadYear(year) print year yearDVOA = TFns.filter_table(DVOA, 'year', year) # iterate over the teams for t in season: teamDVOA = TFns.filter_table(yearDVOA, 'team', t) bye = [x for x in range(1,18) if x not in set(season[t]['week year'])] teamDVOA = teamDVOA[teamDVOA.week != bye] teamDVOA = teamDVOA.drop(['team','week','year'], axis=1) gen = team.team(season[t][headers], teamDVOA, season[t][headersForComputed]) features = gen.computeFeatures(3) features = np.append(np.matrix(season[t]['week year'][3:]).transpose(), features, axis=1) computedHeaders = ['record_vs_spread', 'avg_closing_ability', 'comeback_record'] computedFeatures = gen.computeComplexFeatures(3) features = np.concatenate((features, computedFeatures.transpose()), axis=1) features = features.tolist() featuresdir = os.path.expanduser('~') + "/FSA/data/teamfeaturesbyyear/features%d/" % year if not os.path.exists(featuresdir): os.makedirs(featuresdir) with open(featuresdir + t + '.csv', 'w') as g: g.write(','.join(['week'] + headers + DVOAheaders + computedHeaders) + '\n') for game in features: g.write(','.join([str(x) for x in game]) + '\n')
''' a = assignment() a.getById(4) print a.data[0]['title'] ''' ''' a = assignment() a.getAllByUser(3) a.getDataTable() ''' ''' t = team() print t.data newRow = {'project':'8', 'user':'******', 'position':'0'} t.addRow(newRow) print t.data t.verify_new('8') print t.data ''' ''' t = team() t.getAllByProject('8') t.getDataTable() ''' ''' t = team() print t.getTeamList('8') ''' t = team() print t.getAllByUser('3')
last = False current = False writer = csv.writer(sys.stdout) chdir(textDir) print "Started Run" while True: for file in glob("*.txt"): # glob scans a directory and i use it to return all the file names scanned = open('scanned.config', 'a+') # this file is written to when it has checked csvfile = open('finalrankings.csv', 'a+') writer = csv.writer(csvfile) with open(file, "r") as f: for line in f: Team = team(literal_eval(line)) # hackity hack hack hack. at least it's more secure than eval if Team.TeamIdentity() not in scanned.read(): try: scanned.seek(0) scanned.write(Team.TeamIdentity() + '\n') except IOError: print "Error writing to scanned file, WILL NOT SAVE CURRENT DATA" continue rowToWrite = [Team.MatchPercentage(), Team.TeamIdentity()] print str(rowToWrite) writer.writerow(rowToWrite) else: print "This has already been analyzed!" scanned.close csvfile.close sleep(.1)
def make_teams(self): self.teams = [] players = self.players self.teams.append(team(players[0], players[2])) self.teams.append(team(players[1], players[3]))
def edit_user(uid): if checkSession(3): return redirect("/") if session['currentPage'] != "/user/" + uid: session['lastPage'] += ", " + session['currentPage'] session['currentPage'] = "/user/" + uid print session['lastPage'] print session['currentPage'] u = user() emsg = '' assignMsg = '' teamMsg = '' assignmentSel = request.args.get('assignmentSelector') if assignmentSel == None: assignmentSel = 0 if request.args.get('action') == 'update': u.getById(uid) u.data[0]['fname'] = request.form.get('fname') u.data[0]['lname'] = request.form.get('lname') u.data[0]['email'] = request.form.get('email') u.data[0]['role'] = request.form.get('role') u.data[0]['pw'] = request.form.get('pw') u.data[0]['pw2'] = request.form.get('pw2') u.data[0]['phoneNumber'] = request.form.get('phoneNumber') u.data[0]['gradDate'] = request.form.get('gradDate') u.data[0]['major'] = request.form.get('major') if u.verify_update(): u.update() emsg = "<p style='color:green'>User updated.</p>" else: emsg = "<p style='color:red'>" + u.getErrorHTML() + "</p>" if request.args.get('action') == 'insert': u.createBlank() u.data[0]['fname'] = request.form.get('fname') u.data[0]['lname'] = request.form.get('lname') u.data[0]['email'] = request.form.get('email') u.data[0]['role'] = request.form.get('role') u.data[0]['pw'] = request.form.get('pw') u.data[0]['pw2'] = request.form.get('pw2') u.data[0]['phoneNumber'] = request.form.get('phoneNumber') u.data[0]['gradDate'] = request.form.get('gradDate') u.data[0]['major'] = request.form.get('major') if u.verify_new(): u.insert() emsg = '<p style="color:green">User added.</p>' else: emsg = "<p style='color:red'>" + u.getErrorHTML() + "</p>" if request.args.get('team') == 'add': t = team() t.createBlank() t.data[0]['project'] = request.form.get('project') t.data[0]['user'] = uid if t.verify_new(t.data[0]['project']): t.insert() teamMsg = '<p style="color:green">Project added.</p>' else: teamMsg = "<p style='color:red'>" + t.getErrorHTML() + "</p>" if request.args.get('team') == 'remove': t = team() t.deleteByUser(uid, str(request.form.get('project'))) teamMsg = '<p style="color: green; margin-bottom: 1em">' + t.returnUserName(uid) + " has been removed from " + t.returnProjectName(request.form.get('project')) + "</p>" if request.args.get('assignment') == "add": a = assignment() a.createBlank() a.data[0]['title'] = request.form.get('title') a.data[0]['description'] = request.form.get('description') a.data[0]['assignedTo'] = uid a.data[0]['dueDate'] = request.form.get('dueDate') a.data[0]['project'] = request.form.get('project') if a.verify_new(): a.insert() assignMsg = '<p style="color: green; margin-bottom: 1em">Assignment Added</p>' else: assignMsg = '<p style="color: red; margin-bottom: 1em">' + a.getErrorHTML() + "</p>" if request.args.get('back') == "true": updatePath() if uid == 'new': u.createBlank() w = 'Add New User' act = 'insert' hide = "display: none" col1 = "col-sm-4" col3 = "<div class='col-sm-4'></div>" cta = "Add User" else: u.getById(uid) w = 'Account Information' act = 'update' hide = "" col1 = "col-sm-8" col3 = "" cta = "Update Account Information" html = '''<div class="row"> <div class="col-sm-2"> <form id="backFunction" action="''' + goBack() + '''?back=true" method="POST"> <input type="submit" class="button-secondary" value="Back"> </form> </div> <div class="col-sm-8"> <h1 align="center" id="user_title_main" style="''' + hide +'''">''' + u.data[0]['fname'].upper() + ''' ''' + u.data[0]['lname'].upper() + '''</h1> </div> <div class="col-sm-2"></div> </div> <h3 align="center" style="margin: 0;''' + hide + '''">''' + u.data[0]['major'] + '''</h3> <div class='row'> <div class="''' + col1 + '''"> <h2 style="''' + hide +'''">Projects</h2> <p style="''' + hide + '''">''' + teamMsg + '''</p> <div style="''' + hide + '''" id="userProjects">''' t = team() html += t.getProjects(uid) html += '''</div> <h2 style="''' + hide + '''">Assignments</h2> <p style="''' + hide + '''">''' + assignMsg + '''</p> <div id="userAssignments" style="''' + hide + '''">''' a = assignment() html += a.getUserAssignments(uid, assignmentSel) html += ''' </div> </div> <div align='center' class='col-sm-4'> <h2 id='user_form_title'>''' + w + '''</h2>''' + emsg + ''' <form align='left' id='user_form' action="/user/''' + str(uid) + '''?action=''' + act + '''" method="POST"> <p class='labels'>First Name</p> <input name="fname" required type="text" value="''' + u.data[0]['fname'] + '''"/><br/> <p class='labels'>Last Name</p> <input name="lname" required type="text" value="''' + u.data[0]['lname'] + '''"/><br/> <p class='labels'>Email</p> <input name="email" required type="text" value="''' + u.data[0]['email'] + '''"/><br/> <p class='labels'>Password</p> <input name="pw" type="password" value=""/><br/> <p class='labels'>Retype Password</p> <input name="pw2" type="password" value=""/><br/> <p class='labels'>Role</p>'''+ u.getRoleMenu() +''' <p class='labels'>Phone Number</p> <input name='phoneNumber' required type="text" value="''' + u.data[0]['phoneNumber'] + '''"/><br/> <p class='labels'>Expected Graduation</p> <input name='gradDate' type='text' id="datepicker" placeholder="YYYY" value="''' + str(u.data[0]['gradDate']) + '''"/> <p class='labels'>Major</p> <input name='major' type='text' value="''' + u.data[0]['major'] + '''"/> <br><br> <input type="submit" class='button-primary' value="''' + cta + '''"/> </form> <a href="/users?delete=''' + uid + '''" onclick="return confirm('Are you sure you want to delete this user?')" style="color: #C2C2C2; font-size: 80%;''' + hide + '''">Delete User</a> </div>''' + col3 + ''' </div> ''' return header() + html + footer()
myPlayers.append(newPlayer('Dario', 'Saric', 'PHO')) myPlayers.append(newPlayer('Collin', 'Sexton', 'CLE')) myPlayers.append(newPlayer('Tobias', 'Harris', 'PHI')) myPlayers.append(newPlayer("De'Aaron", 'Fox', 'SAC')) myPlayers.append(newPlayer('Joe', 'Harris', 'BKN')) myPlayers.append(newPlayer('Kent', 'Bazemore', 'POR')) myPlayers.append(newPlayer('Mo', 'Bamba', 'ORL')) myPlayers.append(newPlayer('Dillon', 'Brooks', 'MEM')) ''' #Add to the team all the players from ESPN Fantasy #TODO Automated inseriment through ESPN Fantasy website with Selenium Webscraping: # https://fantasy.espn.com/basketball/team?leagueId=28348224&teamId=7&seasonId=2020 myTeam = team() myTeam.addPlayer('Dwight', 'Howard', 'LAL') myTeam.addPlayer('Shai', 'Gilgeous-Alexander', 'OKC') myTeam.addPlayer('Zach', 'LaVine', 'CHI') myTeam.addPlayer('Rudy', 'Gobert', 'UTA') myTeam.addPlayer('Khris', 'Middleton', 'MIL') myTeam.addPlayer('Dario', 'Saric', 'PHO') myTeam.addPlayer('Collin', 'Sexton', 'CLE') myTeam.addPlayer('Tobias', 'Harris', 'PHI') myTeam.addPlayer("De'Aaron", 'Fox', 'SAC') myTeam.addPlayer('Joe', 'Harris', 'BKN') myTeam.addPlayer('Kent', 'Bazemore', 'POR') myTeam.addPlayer('Mohamed', 'Bamba', 'ORL') myTeam.addPlayer('Dillon', 'Brooks', 'MEM') # print(myTeam)
def test_valid_schedule_year(self): self.assertEqual(team(2015).year, 2015, "The correct year was fetched")
def test_invalid_team_year(self): with self.assertRaises(CONNECTION_TO_WEBSITE_ERROR): team(9999)
def interpret_team_intent(self, intent, slot_dictionary): response_dictionary = {} # set intent of response dicitonary response_dictionary['intent'] = intent # set month of response dictionary year = None if 'value' in slot_dictionary['year']: # Alexa could not determine year if slot_dictionary['year']['value'] == "?": response_dictionary = None return response_dictionary year = int(slot_dictionary['year']['value']) response_dictionary['year'] = slot_dictionary['year']['value'] else: year = int(datetime.datetime.now().year) response_dictionary['year'] = datetime.datetime.now().year # set team_stat_type in response dictionary team_stat_type = None if 'value' in slot_dictionary['team_stat_type']: team_stat_type = slot_dictionary['team_stat_type']['resolutions']['resolutionsPerAuthority'][0]['values'][0]['value']['name'] response_dictionary['team_stat_type'] = slot_dictionary['team_stat_type']['resolutions']['resolutionsPerAuthority'][0]['values'][0]['value']['name'] else: response_dictionary = None return response_dictionary # set team_stat_value in response dictionary t = team(year) if t.cannot_connect_to_website: return None response_dictionary['grammar_type'] = 'number' if team_stat_type == 'games': response_dictionary['team_stat_value'] = t.fetch_num_of_games() elif team_stat_type == 'at bats': response_dictionary['team_stat_value'] = t.fetch_num_of_at_bats() elif team_stat_type == 'runs': response_dictionary['team_stat_value'] = t.fetch_num_of_runs() elif team_stat_type == 'hits': response_dictionary['team_stat_value'] = t.fetch_num_of_hits() elif team_stat_type == 'doubles': response_dictionary['team_stat_value'] = t.fetch_num_of_doubles() elif team_stat_type == 'triples': response_dictionary['team_stat_value'] = t.fetch_num_of_triples() elif team_stat_type == 'home runs': response_dictionary['team_stat_value'] = t.fetch_num_of_home_runs() elif team_stat_type == 'runs batted in': response_dictionary['team_stat_value'] = t.fetch_num_of_runs_batted_in() elif team_stat_type == 'extra base hits': response_dictionary['team_stat_value'] = t.fetch_num_of_extra_base_hits() elif team_stat_type == 'total bases': response_dictionary['team_stat_value'] = t.fetch_num_of_total_bases() elif team_stat_type == 'walks': response_dictionary['team_stat_value'] = t.fetch_num_of_walks() elif team_stat_type == 'hit by pitches': response_dictionary['team_stat_value'] = t.fetch_num_of_hit_by_pitches() elif team_stat_type == 'strikeouts': response_dictionary['team_stat_value'] = t.fetch_num_of_strikeouts() elif team_stat_type == 'sacrifice flies': response_dictionary['team_stat_value'] = t.fetch_num_of_sacrifice_flies() elif team_stat_type == 'sacrifice hits': response_dictionary['team_stat_value'] = t.fetch_num_of_sacrifice_hits() elif team_stat_type == 'hits into double play': response_dictionary['team_stat_value'] = t.fetch_num_of_hit_into_double_play() elif team_stat_type == 'stolen bases': response_dictionary['team_stat_value'] = t.fetch_num_of_stolen_bases() elif team_stat_type == 'caught stealing': response_dictionary['team_stat_value'] = t.fetch_num_of_caught_stealing() response_dictionary['grammar_type'] = 'occurances' elif team_stat_type == 'batting average': response_dictionary['team_stat_value'] = t.fetch_batting_average() response_dictionary['grammar_type'] = 'value' elif team_stat_type == 'on base percentage': response_dictionary['team_stat_value'] = t.fetch_on_base_percentage() response_dictionary['grammar_type'] = 'value' elif team_stat_type == 'slugging percentage': response_dictionary['team_stat_value'] = t.fetch_slugging_percentage() response_dictionary['grammar_type'] = 'value' elif team_stat_type == 'earned run average': response_dictionary['team_stat_value'] = t.fetch_earned_run_average() response_dictionary['grammar_type'] = 'value' elif team_stat_type == 'shutouts': response_dictionary['team_stat_value'] = t.fetch_num_of_shutouts() elif team_stat_type == 'at bats against': response_dictionary['team_stat_value'] = t.fetch_num_of_at_bats_against() elif team_stat_type == 'batting average against': response_dictionary['team_stat_value'] = t.fetch_batting_average_against() response_dictionary['grammar_type'] = 'value' elif team_stat_type == 'home attendance': response_dictionary['team_stat_value'] = t.fetch_home_attendance() pluralresponse_dictionary['grammar_type'] = 'value' elif team_stat_type == 'home attendance average': response_dictionary['team_stat_value'] = t.fetch_home_attendance_average() response_dictionary['grammar_type'] = 'value' else: response_dictionary = None return response_dictionary
def getProjectAssignments(self, id, s): if id == "new": return "" self.data = [] p = project() t = team() p.getById(id) msg = '' if str(s) == "2": self.getAllByProject(id) msg = '''<p>''' + p.data[0][ 'name'] + ''' does not have any assignments</p>''' elif str(s) == "0": self.getIncompleteByProject(id) msg = '''<p>''' + p.data[0][ 'name'] + ''' does not have any incomplete assignments</p>''' elif str(s) == "1": self.getCompleteByProject(id) msg = '''<p>''' + p.data[0][ 'name'] + ''' has not completed an assignment</p>''' html = ''' <div class="row"> <div class="col-sm-0"></div> <div class="col-sm-4"> <form id="assignmentToggle" action="/project/''' + str( p.data[0]['id']) + '''" method="GET">''' html += self.returnAssignmentSelector() html += ''' </form> </div> <div class="col-sm-8"></div> </div> ''' if len(self.data) == 0: html += msg else: i = 0 html += ''' <table style="width:100%" id="user_table"> <tr align="left" style="background-color:#2EB4ED; color:#EAEAEA; font-size: 1.13em;"> <td><b>Assignment<b></td> <td><b>Assigned To</b></td> <td><b>Due Date</b></td> </tr> ''' for row in self.data: c = '#2EB4ED' if i % 2 == 0: c = '#016C9B' html += '''<tr style="background-color:''' + c + '''; color:#EAEAEA"> <td><a href="../assignment/''' + str( row['id']) + '''">''' + row['title'] + '''</a></td> <td><a href="../user/''' + str( row['assignedTo']) + '''">''' + self.returnUserName( row['assignedTo']) + '''</a></td> <td>''' + str(row['dueDate']) + '''</td> </tr>''' i += 1 html += "</table>" html += ''' <div class="row" style="margin-top: 2em" align="center"> <div class="col-sm-1"></div> <div class="col-sm-3"> <p class="button-primary" id="addAssignmentButton" onclick="toggleAddAssignment()">Create Assignment</p> </div> <div class="col-sm-1"></div> <div class="col-sm-3"></div> <div class="col-sm-4"></div> </div> ''' html += '''<div class="row" id="assignmentForm"> <div class="col-sm-1"></div> <form id="addAssignment" action="/project/''' + str( p.data[0] ['id']) + '''?assignment=add" method="POST" class="col-sm-5"> <p class="labels">Title</p> <input type="text" required name="title"> <p class="labels">Description</p> <textarea style="height: 10em; width: 100%;" name="description" form="addAssignment"></textarea> <p class="labels">User</p>''' + t.returnTeamList( p.data[0]['id']) + ''' <p class="labels">Due Date</p> <input type="text" id="datepicker" required name="dueDate"/> <br><br> <input type="submit" value="Create" class="button-primary"/> </form> <div class="col-sm-6"></div> </div>''' return html
count = 0 teams[currentTeam].setDriveAvgs(driveAvgs(numberOfDrives, plays, scorePercent, toPercent, playsPerDrive, yardsPerDrive, start, time, ptsPerDrive)) if count == 0: numberOfDrives = 0 plays = 0 scorePercent = 0 toPercent = 0 playsPerDrive = 0 yardsPerDrive = 0 start = 0 time = 0 ptsPerDrive = 0 if (currText == "League Total" or currText == "Avg Team" or currText == "Avg Tm/G"): break currentTeam = currText + " " + str(year) teams[currentTeam] = team() elif count == 2: numberOfDrives = float(currText) elif (count == 3): plays = float(currText) elif (count == 4): scorePercent = float(currText) elif (count == 5): toPercent = float(currText) elif (count == 6): playsPerDrive = float(currText) elif (count == 7): yardsPerDrive = float(currText) elif (count == 8): start = float(currText.replace("Own", "")) elif (count == 9):
import round import team Slovensko = team.team("Slovensko", 1) Cesko = team.team("Cesko", 2) Ukrajina = team.team("Ukrajina", 3) kolo = round.round((Slovensko, Cesko, Ukrajina)) kolo.getGames()
from character import warrior, mage, priest from enemy import goblin, murloc from team import team from combat import combat #**************************************Place character into World*************# warrior_gar = warrior("Orc", "Garrosh") mage_jen = mage("human", "Jaina") priest_and = priest("human", "Anduin") my_team = team([warrior_gar, mage_jen, priest_and], 1) enemy1 = goblin(1) enemy2 = goblin(1) enemy3 = murloc(1) enemy_team = team([enemy1, enemy2, enemy3], 0) first_combat = combat(my_team, enemy_team) first_combat.combat_start() #**************************************Eof************************************#
class TestTeam(unittest.TestCase): print ("Testing team") valid_2018_team = team(2018) def text_no_specified_year(self): self.assertEqual(team(None).year, datetime.datetime.now().year, "The current year was not used when no year specified") def test_invalid_team_year(self): with self.assertRaises(CONNECTION_TO_WEBSITE_ERROR): team(9999) def test_valid_team_year(self): self.assertEqual(team(2015).year, 2015, "The correct year was fetched") def test_fetch_num_of_games(self): self.assertEqual(self.__class__.valid_2018_team.fetch_num_of_games(), "39", "The correct number of games was not fetched") def test_fetch_num_of_at_bats(self): self.assertEqual(self.__class__.valid_2018_team.fetch_num_of_at_bats(), "1376", "The correct number of at bats was not fetched") def test_fetch_num_of_runs(self): self.assertEqual(self.__class__.valid_2018_team.fetch_num_of_runs(), "271", "The correct number of runs was not fetched") def test_fetch_num_of_hits(self): self.assertEqual(self.__class__.valid_2018_team.fetch_num_of_hits(), "402", "The correct number of hits was not fetched") def test_fetch_num_of_doubles(self): self.assertEqual(self.__class__.valid_2018_team.fetch_num_of_doubles(), "91", "The correct number of doubles was not fetched") def test_fetch_num_of_triples(self): self.assertEqual(self.__class__.valid_2018_team.fetch_num_of_triples(), "10", "The correct number of triples was not fetched") def test_fetch_num_of_home_runs(self): self.assertEqual(self.__class__.valid_2018_team.fetch_num_of_home_runs(), "23", "The correct number of home runs was not fetched") def test_fetch_num_of_runs_batted_in(self): self.assertEqual(self.__class__.valid_2018_team.fetch_num_of_runs_batted_in(), "234", "The correct number of RBIs was not fetched") def test_fetch_num_of_extra_base_hits(self): self.assertEqual(self.__class__.valid_2018_team.fetch_num_of_extra_base_hits(), "124", "The correct number of extra base hits was not fetched") def test_fetch_num_of_total_bases(self): self.assertEqual(self.__class__.valid_2018_team.fetch_num_of_total_bases(), "582", "The correct number of total bases was not fetched") def test_fetch_num_of_walks(self): self.assertEqual(self.__class__.valid_2018_team.fetch_num_of_walks(), "135", "The correct number of walks was not fetched") def test_fetch_num_of_hit_by_pitches(self): self.assertEqual(self.__class__.valid_2018_team.fetch_num_of_hit_by_pitches(), "60", "The correct number of hit by pitches was not fetched") def test_fetch_num_of_strikeouts(self): self.assertEqual(self.__class__.valid_2018_team.fetch_num_of_strikeouts(), "250", "The correct number of strikeouts was not fetched") #tests getter for number of sac flies def test_fetch_num_of_sacrifice_flies(self): self.assertEqual(self.__class__.valid_2018_team.fetch_num_of_sacrifice_flies(),"27","The correct number of sacrifice flies was not fetched") #tests getter for number of sac hits def test_fetch_num_of_sacrifice_hits(self): self.assertEqual(self.__class__.valid_2018_team.fetch_num_of_sacrifice_hits(), "12", "The correct number of sacrifice hits was not fetched") #tests getter for number of hits into a double play def test_fetch_num_of_hits_into_double_play(self): self.assertEqual(self.__class__.valid_2018_team.fetch_num_of_hit_into_double_play(), "22", "The correct number of hits into double play was not fetched") #tests getter for number of stolen bases def test_fetch_num_of_stolen_bases(self): self.assertEqual(self.__class__.valid_2018_team.fetch_num_of_stolen_bases(), "93", "The correct number of stolen bases was not fetched") #tests getter for number of times caught stealing def test_fetch_num_of_caught_stealing(self): self.assertEqual(self.__class__.valid_2018_team.fetch_num_of_caught_stealing(), "14", "The correct number of times caught stealing was not fetched") #tests getter for batting average def test_fetch_num_of_batting_average(self): self.assertEqual(self.__class__.valid_2018_team.fetch_batting_average(), ".292", "The correct batting average was not fetched") #tests getter for on base percentage def test_fetch_on_base_percentage(self): self.assertEqual(self.__class__.valid_2018_team.fetch_on_base_percentage(), ".374", "The correct on base percetage was not fetched") #tests getter for slugging percentage def test_fetch_slugging_percentage(self): self.assertEqual(self.__class__.valid_2018_team.fetch_slugging_percentage(), ".423", "The correct slugging percentage was not fetched") #tests getter for earned run average (ERA) def test_fetch_earned_run_average(self): self.assertEqual(self.__class__.valid_2018_team.fetch_earned_run_average(), "3.64", "The correct earned run average was not fetched") #tests getter for shutuouts def test_fetch_num_of__shutouts(self): self.assertEqual(self.__class__.valid_2018_team.fetch_num_of_shutouts(), "3", "The correct number of shutouts was not fetched") #tests getter for number of at bats againsts def test_fetch_num_of_at_bats_against(self): self.assertEqual(self.__class__.valid_2018_team.fetch_num_of_at_bats_against(), "1309", "The correct number of at bats against was not fetched") #tests getter for batting average against def test_fetch_batting_average_against(self): self.assertEqual(self.__class__.valid_2018_team.fetch_batting_average_against(), ".248", "The correct batting average against was not fetched") #tests getter for home attendance def test_fetch_home_attendance(self): self.assertEqual(self.__class__.valid_2018_team.fetch_home_attendance(), "3045", "The correct number for home attendance was not fetched") #tests getter for home attendance average def test_fetch_home_attendance_average(self): self.assertEqual(self.__class__.valid_2018_team.fetch_home_attendance_average(), "203", "The correct number for home attendance average was not fetched")
def edit_project(pid): if checkSession(3): return redirect("/") if session['currentPage'] != "/project/" + pid: session['lastPage'] += ", " + session['currentPage'] session['currentPage'] = "/project/" + pid print session['lastPage'] print session['currentPage'] p = project() emsg = '' teamMsg = '' assignMsg = '' assignmentSel = request.args.get('assignmentSelector') if assignmentSel == None: assignmentSel = 0 if request.args.get('action') == 'update': p.getById(pid) p.data[0]['name'] = request.form.get('name') p.data[0]['description'] = request.form.get('description') p.data[0]['status'] = request.form.get('status') if 'logo' in request.files: p.data[0]['logo'] = request.files['logo'].filename if p.verify_update(): p.update() if 'logo' in request.files: file_save = logos.save(request.files['logo']) emsg = "<p style='color:green'>Project updated.</p>" else: emsg = "<p style='color:red'>" + p.getErrorHTML() + "</p>" if request.args.get('action') == 'insert': p.createBlank() p.data[0]['name'] = request.form.get('name') p.data[0]['description'] = request.form.get('description') p.data[0]['status'] = request.form.get('status') if ('logo' in request.files): filename = logos.save(request.files['logo']) p.data[0]['logo'] = filename if p.verify_new(): p.insert() emsg = '<p style="color:green">Project added.</p>' else: emsg = "<p style='color:red'>" + p.getErrorHTML() + "</p>" if request.args.get('team') == 'add': t = team() t.createBlank() t.data[0]['user'] = request.form.get('user') t.data[0]['position'] = request.form.get('position') t.data[0]['project'] = pid print t.data if t.verify_new(pid): print t.data t.insert() teamMsg = '<p style="color: green; margin-bottom: 1em">User Added</p>' else: teamMsg = '<p style="color: red; margin-bottom: 1em">' + t.getErrorHTML() + "</p>" if request.args.get('team') == 'remove': t = team() t.deleteByUser(request.form.get('user'), pid) teamMsg = '<p style="color: green; margin-bottom: 1em">' + t.returnUserName(request.form.get('user')) + " has been removed from this project</p>" if request.args.get('assignment') == "add": a = assignment() a.createBlank() a.data[0]['title'] = request.form.get('title') a.data[0]['description'] = request.form.get('description') a.data[0]['assignedTo'] = request.form.get('user') a.data[0]['dueDate'] = request.form.get('dueDate') a.data[0]['project'] = pid if a.verify_new(): a.insert() assignMsg = '<p style="color: green; margin-bottom: 1em">Assignment Added</p>' else: assignMsg = '<p style="color: red; margin-bottom: 1em">' + a.getErrorHTML() + "</p>" if request.args.get('back') == "true": updatePath() if pid == 'new': p.createBlank() w = 'Add New Project' act = 'insert' hide = "display: none" col1 = "col-sm-4" col3 = "<div class='col-sm-4'></div>" cta = "Add Project" else: p.getById(pid) w = 'Project Information' act = 'update' hide = "" col1 = "col-sm-8" col3 = "" cta = "Update Project" if p.data[0]['logo'] == '': src = "" else: src = "src='../static/Images/" + p.data[0]['logo'] + "'" html = '''<div class="row"> <div class="col-sm-2"> <form id="backFunction" action="''' + goBack() + '''?back=true" method="POST"> <input type="submit" class="button-secondary" value="Back"> </form> </div> <div class="col-sm-8"> <h1 id="user_title_main" align="center" style="''' + hide +'''">''' + p.data[0]['name'].upper() + '''</h1> </div> <div class="col-sm-2"></div> </div> <div class='row'> <div class="''' + col1 + '''"> <h2 style="''' + hide +'''">Team</h2>''' + teamMsg + ''' <div style="''' + hide + '''" id="projectTeam">''' t = team() html += t.getTeam(pid) html += '''</div> <h2 style="''' + hide +'''">Assignments</h2> <div style="''' + hide + '''" id="projectAssignments">''' a = assignment() html += a.getProjectAssignments(pid, assignmentSel) html += ''' </div> </div> <div align='center' class='col-sm-4'> <h2 id='user_form_title'>''' + w + '''</h2>''' + emsg + ''' <form align='left' enctype="multipart/form-data" id='project_form' action="/project/''' + str(pid) + '''?action=''' + act + '''" method="POST"> <p class='labels'>Name</p> <input name="name" required type="text" value="''' + p.data[0]['name'] + '''"/><br/> <p class='labels'>Description</p> <textarea name="description" style="width:100%; height: 12em" required form="project_form">''' + p.data[0]['description'] + '''</textarea> <p class='labels'>Status</p>''' + p.getStatusMenu() + ''' <p class='labels'>Logo</p> <img id="project_logo" ''' + src + '''/><br/> <input name="logo" type="file" accept="image/*"/ value="''' + p.data[0]['logo'] + '''"> <br> <input type="submit" class='button-primary' value="''' + cta + '''"/> </form> <a href="/projects?delete=''' + pid + '''" onclick="return confirm('Are you sure you want to delete ''' + p.data[0]['name'] + '''?');" style="color: #C2C2C2; font-size: 80%; ''' + hide + '''">Delete Project</a> </div>''' + col3 + ''' </div> ''' return header() + html + footer()
def text_no_specified_year(self): self.assertEqual(team(None).year, datetime.datetime.now().year, "The current year was not used when no year specified")
import random import volunteer import staff import team import comp from tabulate import tabulate while True: choice = input( "\n1.Register\n2.Display Records\n3.Fixtures\n4.Exit\n\n>>> ") if choice == 1: choice = input("\n1.Team\n2. Volunteer\n3.Staff\n4.Exit\n\n>>> ") if choice == 1: while True: s = team.team() s.register() choice = raw_input("Add more? [Y/n] ") if choice.lower() == "y": pass elif choice.lower() == "n": break else: print "Please enter valid choice" elif choice == 2: while True: s = volunteer.volunteer() s.register() choice = raw_input("Add more? [Y/n] ") if choice.lower() == "y":