tpy:
from S22.trends import query from S22.trends import pull_trends import PyQL.py_tools from datetime import datetime import traceback import glob, time, os, re import PyQL.py_tools import cPickle import urllib import KS2.ks from KS2.ks import TREND_TOP,TREND_SUP,trend_file_top,current_season from KS2.page_logger import visitor_log import pandas as pd import math import KS2.client_tools from KS2.subscriber_tools import beta_testers, vault_access client_info = KS2.client_tools.client_info({'client': __d.get("client","guest")}) box_s = { 'nfl': '/home/jameyer/S2/NFL/Source/Data/NFL/Box/_Column/', 'nba': '/home/jameyer/S2/NBA/Source/Data/NBA/Box/_Column/Game/', 'ncaafb': '/home/jameyer/S2/NCAAFB/Source/Data/Covers/Box/_Column/', 'ncaabb': '/home/jameyer/S2/NCAABB/Data/Covers/Box/_Column/Game/', 'mlb': '/home/jameyer/S2/MLB/Source/Data/MLB/Box/_Column/Game/', 'nhl': '/home/jameyer/S2/NHL/Data/Covers/Box/_Column/Game/', 'wnba': '/home/jameyer/S2/WNBA/Source/Data/WNBA/Box/_Column/Game/' } trend_sets = { 'NFL': '/home/jameyer/S2/NFL/Source/Data/NFL/Schedule/_Column/', 'NBA': '/home/jameyer/S2/NBA/Source/Data/NBA/Schedule/_Column/', 'MLB': '/home/jameyer/S2/MLB/Source/Data/MLB/Schedule/_Column/', 'NCAAFB': '/home/jameyer/S2/NCAAFB/Source/Data/Covers/Schedule/_Column/', 'NCAABB': '/home/jameyer/S2/NCAABB/Data/Schedule/_Column/', 'NHL': '/home/jameyer/S2/NHL/Data/Covers/Schedule/_Column/', 'WNBA': '/home/jameyer/S2/WNBA/Source/Data/WNBA/Schedule/_Column/' } if datetime.now().month in [2, 3, 4, 5]: default = 'NBA' elif datetime.now().month in [9, 10, 11, 12, 1]: default = 'NFL' else: default = 'MLB' sport = __d.get("filter", default) client = __d.get("client", 'guest') owner = client _type_ = __d.get("typ", ".*") _foc_ = __d.get("foc", "*") _per_ = __d.get("per", "FG") period = _per_ _page_ = __d.get("pg", 1) _sort_ = __d.get("sort", '_pval') with open('%steam.pkl'%box_s[sport.lower()], 'rb') as f: teams = cPickle.load(f) teams = [x for x in list(set(teams)) if x] pth = glob.glob("/home/kscREV1/KS/Vault/"+sport.lower()+".csv") if ((len(pth) > 0) and (client != 'guest')): info = "Trend Vault last updated at "+str(time.strftime("%Y-%m-%d %I:%M %p %Z", time.localtime(os.path.getmtime(pth[0])))) visitor_log('vault',client,1) elif client == 'guest': info = 'Viewing in Guest Mode, please log-in to access and save personal trends' owner = 'admin' else: info = '' trends = pd.read_csv('/home/kscREV1/KS/Vault/%s.csv'%sport.lower()) schedule = pull_trends(str(sport), 'admin')['_schedule'] t2v = {'ATS': 'ats margin', 'OU': 'ou margin', 'SU': 'margin', 'RL': 'rl margin', 'PL': 'pl margin', 'ML': 'margin'} if _type_ != '.*': trends = trends[trends['type']==t2v[_type_.upper()]] if _foc_ not in ['*', 'league']: trends = trends[trends[_foc_] == 1] trends = trends.reset_index(drop=True) elif _foc_ == 'league': trends = trends[(trends['player'] == 0) & (trends['team'] == 0) & (trends['coach'] == 0)] trends = trends.reset_index(drop=True) if 'period' in list(trends): trends = trends[trends['period'] == _per_] else: trends['period'] = 'FG' trends = trends[trends['period'] == _per_] pyql_url = '' if 'pyql' in __d: pyql_url = '&pyql=%s'%urllib.quote(__d['pyql']) pyql = __d['pyql'].split(' or ') pqA0 = re.findall('\(([0-9]{8},[A-z\s]+)\)', pyql[0])[0].split(',') pqA0[0] = int(pqA0[0]) pqA1 = re.findall('(wins|losses)', pyql[0]) pqB0 = re.findall('\(([0-9]{8},[A-z\s]+)\)', pyql[1])[0].split(',') pqB0[0] = int(pqB0[0]) pqB1 = re.findall('(wins|losses)', pyql[1]) # filter trends if pqA1 != pqB1: trends = trends[ ((trends['active'].str.find(str(tuple(pqA0))) != -1) & (trends['play'] == 1.0)) | ((trends['active'].str.find(str(tuple(pqB0))) != -1) & (trends['play'] == -1.0))] elif 'wins>losses' in __d['pyql']: trends = trends[ ((trends['active'].str.find(str(tuple(pqA0))) != -1) & (trends['play'] == 1.0)) | ((trends['active'].str.find(str(tuple(pqB0))) != -1) & (trends['play'] == 1.0))] elif 'wins<losses' in __d['pyql']: trends = trends[ ((trends['active'].str.find(str(tuple(pqA0))) != -1) & (trends['play'] == -1.0)) | ((trends['active'].str.find(str(tuple(pqB0))) != -1) & (trends['play'] == -1.0))] import re options = list(schedule) options.sort() if len(options) > 0: _date_ = __d.get("date", options[0]) #int(PyQL.py_tools.today()) else: _date_ = __d.get("date", int(PyQL.py_tools.today())) if sport in ['NFL','NCAAFB'] and options: if sport == 'NFL': import NFL.date_tools as week_calc else: import NCAAFB.date_tools as week_calc if _date_ > 10000000: _date_ = week_calc.find_week_from_date(_date_) week = week_calc.find_week_from_date(options[0]) weeks = {} for option in options: week = week_calc.find_week_from_date(option) if week not in weeks: weeks[week] = [] weeks[week] += [option] options = list(weeks) options.sort() week0 = _date_ # options = [option for option in options if week_calc.find_week_from_date(option) == week] else: pass # options = [options[0]] if _date_ != 0 and _date_ > 1000000: trends = trends[trends['active'].str.find(str(_date_)) != -1] elif _date_ != 0 and 'weeks' in locals(): trends = eval('trends[(%s)]'%')|('.join(["trends['active'].str.find(str(%s)) != -1"%x for x in weeks[_date_]])) sort_arrows = ['','','',''] arrow_dir = '' ascending = False; _lsort_ = _sort_ if _sort_[0] == '_': ascending = True; _sort_ = _sort_[1:] arrow_dir = ' sorting-arrow-up' pageT = len(trends) i0 = min(max(0, 100*(_page_-1)), pageT) trends['roi'] = pd.to_numeric(trends['roi'], errors='coerce') trends['profit'] = pd.to_numeric(trends['profit'], errors='coerce') if _sort_ == 'roi': sort_arrows[3] = ' active%s'%arrow_dir trends = trends.loc[trends.roi.sort_values(ascending=ascending).index].iloc[i0:i0+100] elif _sort_ == 'profit': sort_arrows[2] = ' active%s'%arrow_dir trends = trends.loc[trends.profit.sort_values(ascending=ascending).index].iloc[i0:i0+100] elif _sort_ == 'record': sort_arrows[1] = ' active%s'%arrow_dir trends = trends.loc[(trends['wins']/trends[['wins','losses']].sum(axis=1)).sort_values(ascending=ascending).index].iloc[i0:i0+100] elif _sort_ == 'pval': sort_arrows[0] = ' active%s'%arrow_dir trends = trends.sort_values(_sort_, ascending=ascending).iloc[i0:i0+100] def sdql_locate(x, client, trends): for client_bet in list(trends['KSC']): headers = trends['KSC'][client_bet].headers i_sdql = headers.index('sdql') if x in trends['KSC'][client_bet].data[i_sdql]: return client_bet.split('_')[-1] return '-' def sdql_record(x, client, bet, trends): headers = trends['KSC']['%s_%s'%(client,bet)].headers i_sdql = headers.index('sdql') i_wins = headers.index('wins') i_losses = headers.index('losses') if x in trends['KSC']['%s_%s'%(client,bet)].data[i_sdql]: i = list(trends['KSC']['%s_%s'%(client,bet)].data[i_sdql]).index(x) c0 = trends['KSC']['%s_%s'%(client,bet)].data[i_wins][i] c1 = trends['KSC']['%s_%s'%(client,bet)].data[i_losses][i] if c1 > c0: return '1' return '0' def eval_focus(x, teams=teams): x = ' and %s'%x n = 0 if re.findall('|'.join(teams), x): n += 1 if re.findall('and ([A-z\s]+):', x): for y in re.findall('and ([A-z\s]+):', x): X = y.split(' and ')[-1].replace('not', '') if re.sub('[tpPnNosS ]','',X) != '': n += 2 return n if n < 2: if re.findall('name(?:\s|)=(?:\s|)[A-z]+', x): n += 2 elif re.findall('starter(?:\s|)=(?:\s|)[A-z]+', x): n += 2 if re.findall('coach(?:\s|)=(?:\s|)[A-z]+', x): n += 4 elif re.findall('manager(?:\s|)=(?:\s|)[A-z]+', x): n += 4 return n def eval_roi(side, rec): R = rec.split(' ')[0].split('-') if side in ['ON','OVER']: profit = (int(R[0]) * 100)-(int(R[1]) * 110) invest = (int(R[0]) + int(R[1])) * 110 elif side in ['AGST','UNDER']: profit = (int(R[1]) * 100)-(int(R[0]) * 110) invest = (int(R[0]) + int(R[1])) * 110 else: return '-' return '{:.1%}'.format((profit+0.0)/invest) if sport in ['NFL','NCAAFB'] and 'weeks' in locals(): # _date_ = week date_dropdown = """ <div class="dropdown"> <button onclick="myFunction(0)" class="dropdown-btn dropdown-toggle" data-toggle="dropdown" id="date-sel">Week <span class="caret"></span></button> <div id="myDropdown_0" class="dropdown-content" style="width: 225px"> """ for w in list(weeks)[:10]: date_dropdown += '<div class="option-bord" onclick="setDate(event)"><a class="drop-option" name="%s">Active in Week %s</a></div>'%(w,w) date_dropdown += "</div></div>" # _date_ = __d.get("date", options[0]) #int(PyQL.py_tools.today()) if _date_ > 10000000: _date_ = week_calc.find_week_from_date(_date_) week0 = _date_ else: date_dropdown = """ <div class="dropdown"> <button onclick="myFunction(0)" class="dropdown-btn dropdown-toggle" data-toggle="dropdown" id="date-sel">Date <span class="caret"></span></button> <div id="myDropdown_0" class="dropdown-content" style="width: 225px"> """ for i in options: date_dropdown += """ <div class="option-bord" onclick="setDate(event)" style="cursor:pointer"> <a class="drop-option" name="%s">Active on %s</a> </div>"""%(i, PyQL.py_tools.nice_date(i)) date_dropdown += "</div></div>" plays = ['ats', 'su', 'ou'] if sport in ['MLB']: plays = ['ml', 'ou', 'rl'] elif sport in ['NHL']: plays = ['ml', 'ou', 'pl'] typ_dropdown = """ <div class="dropdown"> <button onclick="myFunction(1)" class="dropdown-btn dropdown-toggle" data-toggle="dropdown" id="typ-sel">All Types <span class="caret"></span></button> <div id="myDropdown_1" class="dropdown-content" style="width: 225px"> <div class="option-bord" onclick="setType(event)" style="cursor:pointer"> <a class="drop-option" name=".*">All Types</a> </div> <div class="option-bord" onclick="setType(event)" style="cursor:pointer"> <a class="drop-option" name="%s">%s</a> </div> <div class="option-bord" onclick="setType(event)" style="cursor:pointer"> <a class="drop-option" name="%s">%s</a> </div> <div class="option-bord" onclick="setType(event)" style="cursor:pointer"> <a class="drop-option" name="%s">%s</a> </div> """%(plays[0], plays[0].upper(), plays[1], plays[1].upper(), plays[2], plays[2].upper()) typ_dropdown += "</div></div>" foc_dropdown = """ <div class="dropdown"> <button onclick="myFunction(2)" class="dropdown-btn dropdown-toggle" data-toggle="dropdown" id="foc-sel">Any Focus <span class="caret"></span></button> <div id="myDropdown_2" class="dropdown-content" style="width: 225px"> <div class="option-bord" onclick="setFocus(event)" style="cursor:pointer"> <a class="drop-option" name="*">All Categories</a> </div> <div class="option-bord" onclick="setFocus(event)" style="cursor:pointer"> <a class="drop-option" name="league">League-Wide</a> </div> <!--<div class="option-bord" onclick="setFocus(event)" style="cursor:pointer"> <a class="drop-option" name="player">Player Specific</a> </div>--> <div class="option-bord" onclick="setFocus(event)" style="cursor:pointer"> <a class="drop-option" name="team">Team Specific</a> </div> <div class="option-bord" onclick="setFocus(event)" style="cursor:pointer"> <a class="drop-option" name="coach">Coach Specific</a> </div> """ if sport == 'MLB': foc_dropdown += """ <div class="option-bord" onclick="setFocus(event)" style="cursor:pointer"> <a class="drop-option" name="player">Player Specific</a> </div>""" foc_dropdown += "</div></div>" if sport in ['ATP','WTA']: per_dropdown = """ <div class="dropdown"> <button onclick="myFunction(2)" class="dropdown-btn dropdown-toggle" data-toggle="dropdown" id="per-sel">Focus <span class="caret"></span></button> <div id="myDropdown_2" class="dropdown-content" style="width: 225px"> """ else: per_dropdown = """ <div class="dropdown"> <button onclick="myFunction(3)" class="dropdown-btn dropdown-toggle" data-toggle="dropdown" id="per-sel">Period <span class="caret"></span></button> <div id="myDropdown_3" class="dropdown-content" style="width: 225px"> <div class="option-bord" onclick="setPeriod(event)" style="cursor:pointer"> <a class="drop-option" name="FG">Full Game</a> </div> <div class="option-bord" onclick="setPeriod(event)" style="cursor:pointer"> <a class="drop-option" name="H1">1st Half</a> </div> <div class="option-bord" onclick="setPeriod(event)" style="cursor:pointer"> <a class="drop-option" name="Q1">1st Quarter</a> </div> """ per_dropdown += "</div></div>" trend_table = """ <table id="DT_Table" class="table table-striped"> <thead class="table-header"> <tr> <th style="cursor:pointer" onclick="trendSort('pval')">P val<span class="sorting-arrow ml-3%s"></span></th> <th>Type</th> <th>Play</th> <th>Category</th> <th style="cursor:pointer" onclick="trendSort('record')">Record<span class="sorting-arrow ml-3%s"></span></th> <th style="cursor:pointer" onclick="trendSort('profit')">Profit<span class="sorting-arrow ml-3%s"></span></th> <th style="cursor:pointer" onclick="trendSort('roi')">ROI<span class="sorting-arrow ml-3%s"></span></th> <th class="recode-header">Trend Description</th> <!--<th style="cursor:pointer">SDQL</th>--> <th style="width: 20px;"></th> </tr> </thead> <tbody class="table-body">"""%(sort_arrows[0], sort_arrows[1], sort_arrows[2], sort_arrows[3]) if ((client in beta_testers or KS2.ks.SUBSCRIBE_SYSTEM) and not vault_access[client_info.tier]): filter_notice = "" trend_table = """<h1 class="color-yellow" style="padding-top: 100px; text-align: center">Upgrade to access the Trend Vault</h1> <h3 class='help-title-color' style='padding-top: 10px; text-align: center'> This feature requires a Basic, Pro, or Premium tier subscription. Click <a href='plans-premium' class='color-yellow' target='_blank'>here</a> to upgrade</h3>""" elif (datetime.now()-datetime.fromtimestamp(os.path.getmtime(pth[0]))).days > 2: filter_notice = "" trend_table = "<h1 class='color-yellow' style='padding-top: 100px; text-align: center'>Vault Empty</h1>" trend_table += "<h3 class='help-title-color' style='padding-top: 10px; text-align: center'>Please check back before the start of the next %s season</h3>"%sport else: if sport in ['NFL','NCAAFB']: info += "<br><br><i style='color: #64ff8d;font-weight: 300;'>Trends listed below are only those that are active in Week %s</i>"%week0 else: info += "<br><br><i style='color: #64ff8d;font-weight: 300;'>Trends listed below are only those that are active on %s</i>"%datetime.strptime(str(_date_), '%Y%m%d').strftime('%B %d, %Y') #overlycomplex # headers = res['%s'%(list(res)[0])][0].headers i_wins = 'wins' i_losses = 'losses' i_percents = ' % ' i_link = 'link' # if sport not in ['MLB', 'NHL']: i_profit = 'profit' i_roi = 'roi' i_pval = 'pval' # else: # i_roi = 'roi' # i_pval = None pvals = []; wins = []; losses = []; percents = []; links = []; profits = []; rois = []; plays = []; types =[] # for x in list(trends): wins += list(trends[i_wins]) losses += list(trends[i_losses]) percents += list(trends[i_wins]/(trends[i_wins] + trends[i_losses])) links += list(trends[['sdql','english']].values) #list(trends[i_link]) types += list(trends['type']) plays += list(trends['play']) # if i_pval != None: pvals += list(trends[i_pval]) # if i_roi != None: profits += list(trends[i_profit]) rois += list(trends[i_roi]) # # sides += [x.split('_')[-1].upper()]*len(res[x].data[0][0]) ptypes = {'ats margin':'ATS', 'ou margin': 'OU', 'margin':'SU', 'rl margin': 'RL', 'pl margin': 'PL'} if sport in ['MLB','NHL']: ptypes['margin'] = 'ML' sides = {'ats margin': {1.0: 'ON', -1.0: 'AGST'},'ou margin': {1.0: 'OVER', -1.0: 'UNDER'},'margin': {1.0: 'ON', -1.0: 'AGST'}, 'rl margin': {1.0: 'ON', -1.0: 'AGST'}, 'pl margin': {1.0: 'ON', -1.0: 'AGST'}, 'ML': {'0': 'ON', '1': 'AGST'}} foci = {0: 'League-Wide', 1: 'Team', 2: 'Player', 3: 'Player, Team', 4: 'Coach', 5: 'Coach, Team', 6: 'Coach, Player', 7: 'Coach, Player, Team'} for i in range(0, len(links)): if pvals: if (pvals[i] < 0.00000001): pval = '{:.4e}'.format(pvals[i]) else: pval = '{:.8f}'.format(pvals[i]) else: pval = '-' play = ptypes[types[i]] side = sides[types[i]][plays[i]] rec = '%s-%s'%(wins[i], losses[i]) + ' ('+"{:.1%}".format(percents[i])+')' if ((rois[i] == '-') or math.isnan(rois[i])): profit = '-' roi = '-' else: profit = '${:,.0f}'.format(int(profits[i])) roi = '{:.1%}'.format(float(rois[i])) # else: # roi = '-' desc = links[i][1] sdql = links[i][0] foc = foci[eval_focus(sdql)] # if _foc_ != '*': # if _foc_ not in foc.lower(): # continue # search = '(%s) as "%s=>%s"' % (sdql, sdql, desc) # if search in metrics: # play = metrics[search]['type'].upper() # side = sides[play][metrics[search]['side']] # rtg = str(metrics[search]['rtg']) # if rtg == 'NR': rtg = '-' # else: # play = sdql_locate(sdql, owner, trends).upper() # if play != '-': # side = sides[play][sdql_record(sdql, owner, play.lower(), trends)] # else: # side = '-' # rtg = '-' # calculate ROI # if ((play in ['ATS','OU', 'RL', 'PL']) and (roi == '-')): # roi = eval_roi(side, rec) # if side in ['AGST','UNDER']: # pct = (losses[i]+0.0)/(losses[i] + wins[i]) # rec = '%s-%s'%(losses[i], wins[i]) + ' ('+"{:.1%}".format(pct)+')' href = '/query?sdql='+urllib.quote_plus(links[i][0]) + '&filter=%s%s&init=1'%(sport, '' if period == 'FG' else '&period=%s'%period) sdql = sdql.replace('<','&lt;').replace('>','&gt;') trend_table += """ <tr class="align-middle"> <td>""" + pval + """</td> <td>""" + play + """</td> <td>""" + side + """</td> <td>""" + foc + """</td> <td>""" + rec + """</td> <td>""" + profit + """</td> <td>""" + roi + """</td> <td class="text-start text-off" hidden>""" + sdql + """</td> <td class="text-start"> <div class="help-title-color"> <div class="flex align-items-center"> <div class=""> <p><a class="help-title-color text-on" style="white-space:pre-wrap" href='""" + href + """'>""" + str(desc).replace('>','&gt;').replace('<','&lt;') + """</a></p> </div> </div> </div> </td> <td class="small-card-cell-content"> <a href='""" + href + """'><img src="KS/Images/trend/play.svg" style="max-width: unset;"></a> </td> </tr> """ filter_notice = "" if 'pyql' in __d: filter_team = None if _type_ == 'ou' and re.findall('active', __d['pyql']): if re.findall('\(wins>losses\)', __d['pyql']): filter_team = urllib.unquote('OVER') elif re.findall('\(wins<losses\)', __d['pyql']): filter_team = urllib.unquote('UNDER') else: if re.findall('\(team=(.*?)\)', __d['pyql']): filter_team = urllib.unquote(re.findall('\((team=.*?)\)', __d['pyql'])[0]) elif re.findall('\,(.*?)\) in active', __d['pyql']): filter_team = urllib.unquote('team='+re.findall('\,(.*?)\) in active', __d['pyql'])[0]) if filter_team: filter_notice = """ <div class="flex align-items-center small-card-cell" style="color: #77DCEA;cursor: pointer" onclick="noPYQL()"> <div class=""> <p class="small-card-cell-content">%s</p> </div> <span class="small-card-icon">&times;</span> </div>"""%filter_team # for game in games: # date = datetime.strptime(str(_date_), '%Y%m%d').strftime('%m/%d/%Y'); divider = '' # trend_table += """ # <tr class="align-middle"> # <th scope="row">0.0755</th> # <td> # UNDER # </td> # <td>90-64 (58.4%)</td> # <td>11.5%</td> # <td class="w-40 text-start"> # Lorem ipsum dolor sit amet consectetur. Augue maecenas semper nunc consequat egestas proin a aliquam augue. Ut amet felis in adipiscing. # </td> # <td class="text-start"> # <div class="flex align-items-center gap-8 pb-8 help-title-color"> # <div class="flex align-items-center small-card-cell"> # <div class=""> # <p class="small-card-cell-content">team=Bears</p> # </div> # <span class="small-card-icon">&times;</span> # </div> # <p class="color-yellow">and</p> # <div class="flex align-items-center small-card-cell"> # <div class=""> # <p class="small-card-cell-content">Season = 2023</p> # </div> # <span class="small-card-icon">&times;</span> # </div> # </div> # </td> # <td> # <a href="sdql"><img src="KS/Images/trend/play.svg"></a> # </td> # </tr> # """ # t_vals = {'ats': '-', 'ml': '-', 'ou': '-'} # p_vals = {'ats': '-', 'ml': '-', 'ou': '-'} # for typ in ['ats', 'ml', 'ou']: # if typ in games[game]: # t_vals[typ] = games[game][typ] # rec0 = t_vals[typ].split(' (')[-1][:-5].split(' - ') # rec = [int(x) for x in rec0] # # rec = [5, 15] # p_vals[typ] = round(math.log(1/probability(sum(rec),rec[0],0.5)),1) # if ((int(game) % 2 == 1) and ('None' not in teams)): # date = '@' # divider = ' style="border-bottom: #ABABABC9 1px solid;"' # if teams[0] == 'None': # if games[game]['team'] == 'None': # trend_table = """ # <table class="table table-striped"> # <thead class="table-header"> # <tr> # <th>Team</th> # <th>ATS</th> # <th>AVG Power</th> # <th>ML</th> # <th>AVG Power</th> # <th>OU</th> # <th>AVG Power</th> # </tr> # </thead> # <tbody class="table-body">""" # trend_table += """ # <tr class="align-middle"%s > # <td class="flex align-items-center"> # <img class="pr-11" width="70"></a> # %s # </td> # <td>%s</td> # <td>%s</td> # <td>%s</td> # <td>%s</td> # <td>%s</td> # <td>%s</td> # </tr>"""%(divider, 'Non-specific', t_vals['ats'], p_vals['ats'], t_vals['ml'], p_vals['ml'], t_vals['ou'], p_vals['ou']) # else: # trend_table += """ # <tr class="align-middle"%s > # <td class="flex align-items-center"> # <img class="pr-11" width="70" src="KS/Images/trend/%s/%s.png" alt="#"> # %s # </td> # <td>%s</td> # <td>%s</td> # <td>%s</td> # <td>%s</td> # <td>%s</td> # <td>%s</td> # </tr>"""%(divider, sport, games[game]['team'], games[game]['team'], t_vals['ats'], p_vals['ats'], t_vals['ml'], p_vals['ml'], t_vals['ou'], p_vals['ou']) # else: # line = odds['line'][(odds['team']==games[game]['team']) & (odds['date']==_date_)].iloc[0] # total = odds['total'][(odds['team']==games[game]['team']) & (odds['date']==_date_)].iloc[0] # trend_table += """ # <tr class="align-middle"%s > # <th scope="row">%s</th> # <td class="flex align-items-center"> # <img class="pr-11" width="70" src="KS/Images/trend/%s/%s.png" alt="#"> # %s # </td> # <td>+%s</td> # <td><b>O</b> %s</td> # <td>%s</td> # <td>%s</td> # <td>%s</td> # <td>%s</td> # <td>%s</td> # <td>%s</td> # </tr>"""%(divider, date, sport, games[game]['team'], games[game]['team'], line, total, t_vals['ats'], p_vals['ats'], t_vals['ml'], p_vals['ml'], t_vals['ou'], p_vals['ou']) # # trend_table += "</tbody></table>" # trend_table = trend_table.replace('+-','-').replace('+nan','').replace('+None','').replace('<b>O</b> nan','').replace('<b>O</b> None','') prior_button = """ <a href="/trend-ware-trend?filter=%s&date=%s&typ=%s&foc=%s&per=%s%s&pg=1&sort=%s" style="color: #F3D527;padding: 8px 16px;">&#8249;&#8249;</a> <a href="/trend-ware-trend?filter=%s&date=%s&typ=%s&foc=%s&per=%s%s&pg=%s&sort=%s" style="color: #F3D527;border-radius: 8px;padding: 8px 16px;border: 1px solid #F3D527;"> &#8249; Last 100 </a>"""%(sport, _date_,_type_,_foc_,_per_,pyql_url,_lsort_,sport, _date_,_type_,_foc_,_per_,pyql_url,_page_-1,_lsort_) next_button = """ <a href="/trend-ware-trend?filter=%s&date=%s&typ=%s&foc=%s&per=%s%s&pg=%s&sort=%s" style="color: #F3D527;border-radius: 8px;padding: 8px 16px;border: 1px solid #F3D527;"> Next 100 &#8250; </a>"""%(sport, _date_,_type_,_foc_,_per_,pyql_url,_page_+1,_lsort_) if i0 == 0: prior_button = "" elif i0 > pageT-100: next_button = "" if sport in ['NFL','NCAAFB']: if len(options) > 0: _date_ = week0 else: _date_ = __d.get("date", int(PyQL.py_tools.today()))
error:
exception:
message: invalid syntax (, line 3)
traceback:


error:
exception:
message: 1
traceback: