attempt_play = False if cur_play.Off_Touchdown == 1 or cur_play.Def_Touchdown == 1: xpt_re = re.search('\((.*?)\)',cur_play.Play_Desc) if xpt_re: attempt_play = Play_Stats(game.Code, len(plays) + 1, game.Current_Qrt, drive.Start_Time, drive.Offense, drive.Defense, off_pnts, def_pnts, drive.Drive_Num) attempt_play.Play_Desc = xpt_re.group(1) attempt_play.Play_Type = "ATTEMPT" attempt_play.Spot = 3 attempt_play.TwoPt_Good = cur_play.TwoPt_Good attempt_play.TwoPt_Att = cur_play.TwoPt_Att attempt_play.Extra_Pt_Att = cur_play.Extra_Pt_Att attempt_play.Kick_Blocked = cur_play.Kick_Blocked attempt_play.Kick_Good = cur_play.Kick_Good attempt_play.Kicker = cur_play.Kicker if attempt_play.Extra_Pt_Att ==0 and attempt_play.TwoPt_Att == 0: attempt_play.Extra_Pt_Att = 1 if cur_play.Def_Touchdown == 1: attempt_play.Offense = cur_play.Defense attempt_play.Defense = cur_play.Offense attempt_play.Off_Points = cur_play.Def_Points attempt_play.Def_Points = cur_play.Off_Points attempt_play.Spot = 3 cur_play.TwoPt_Good = 0 cur_play.TwoPt_Att =0 cur_play.Extra_Pt_Att=0 cur_play.Kick_Blocked=0 cur_play.Kick_Good=0
def DictToPlay(play): newplay = Play_Stats(0, 0, 0, 0, 0, 0, 0, 0, 0) if play == False: return newplay newplay.Game_Code =play['Game Code'] newplay.Play_Number=int(play['Play Number']) newplay.Period_Number =int(play['Period Number']) newplay.Drive_Start =play['Drive Start'] try: newplay.Offense =play['Offense Team Code'] newplay.Defense =play['Defense Team Code'] except: newplay.Offense =play['Offense'] newplay.Defense =play['Defense'] try: newplay.Off_Points =int(play['Offense Points']) newplay.Def_Points =int(play['Defense Points']) except: newplay.Off_Points =int(play['Off Points']) newplay.Def_Points =int(play['Def Points']) newplay.Down =int(play['Down']) if play['Down'] != '' else 0 newplay.Distance =int(play['Distance']) if play['Distance'] != '' else 0 newplay.Spot =int(play['Spot']) if play['Spot'] != '' else 0 newplay.Play_Type =play['Play Type'] newplay.Drive_Number =int(play['Drive Number']) if play['Drive Number'] != '' else 0 newplay.Drive_Play =int(play['Drive Play']) if play['Drive Play'] != '' else 0 newplay.Play_Desc =play['Play Desc'] newplay.Play_Result =play['Play Result'] newplay.Yards_Gained =int(play['Yards Gained']) newplay.Off_Touchdown =int(play['Off Touchdown']) newplay.Def_Touchdown =int(play['Def Touchdown']) newplay.First_Down =int(play['First Down']) newplay.Completion =int(play['Completion']) newplay.Interception =int(play['Interception']) newplay.Fumble =int(play['Fumble']) newplay.Fumble_Lost =int(play['Fumble Lost']) newplay.Kick_Good =int(play['Kick Good']) newplay.TwoPt_Good =int(play['TwoPt Good']) newplay.Safety =int(play['Safety']) newplay.Kick_Yards =int(play['Kick Yards']) newplay.Touchback =int(play['Touchback']) newplay.Kickoff_OOB =int(play['Kickoff OOB']) newplay.Kickoff_Onsides =int(play['Kickoff Onsides']) newplay.Kick_Blocked =int(play['Kick Blocked']) newplay.Penalty =int(play['Penalty']) newplay.Penalty_Type =play['Penalty Type'] newplay.No_Play =int(play['No Play']) newplay.Rusher =play['Rusher'] newplay.Passer =play['Passer'] newplay.Receiver =play['Receiver'] newplay.Kicker =play['Kicker'] try: newplay.Forced_Fum =play['Forced Fum'] except: newplay.Forced_Fum =play['Forced_Fum'] newplay.Interceptor =play['Interceptor'] newplay.Sacker =play['Sacker'] newplay.Extra_Pt_Att =int(play['Extra Pt Att']) newplay.TwoPt_Att =int(play['TwoPt Att']) newplay.Unparsed =play['Unparsed Play Desc'] return newplay