def printScores( away, home, scoresArray, description, skipFuture, skipFinished ) : ''' Print the data from the game ''' print 'Entering' # debug doPrint = True if skipFinished : if isFinal( scoresArray ) : doPrint = False if doPrint : print 'doPrint!' # debug ( away, home ) = teamsTranslate( away, home ) if isFuture( scoresArray ) : if False == skipFuture : print "%11s %s" % ( away, scoresArray[ 1 ] ) print "%11s %s" % ( home, scoresArray[ 2 ] ) print else : chunkSize = len( scoresArray ) / 3 offset = chunkSize printLine( away, scoresArray, offset, offset + chunkSize - 1 ) printLine( home, scoresArray, offset + chunkSize, offset + ( 2 * chunkSize ) - 1 ) if len( description ) > 0 : print description print
def printScores(away, home, scoresArray, description, skipFuture, skipFinished): ''' Print the data from the game ''' print 'Entering' # debug doPrint = True if skipFinished: if isFinal(scoresArray): doPrint = False if doPrint: print 'doPrint!' # debug (away, home) = teamsTranslate(away, home) if isFuture(scoresArray): if False == skipFuture: print "%11s %s" % (away, scoresArray[1]) print "%11s %s" % (home, scoresArray[2]) print else: chunkSize = len(scoresArray) / 3 offset = chunkSize printLine(away, scoresArray, offset, offset + chunkSize - 1) printLine(home, scoresArray, offset + chunkSize, offset + (2 * chunkSize) - 1) if len(description) > 0: print description print
def dumpPage(page, options): ''' Parse the page into the pieces we need. td class="viBodyBorderNorm" find the second table... find all the tr's ''' soup = bs(page) mainTable = soup.findChild('td', {"class": "viBodyBorderNorm"}) tables = mainTable.findAll('table') oddsTable = tables[1] rows = oddsTable.findAll('tr') oddsOut = [] for aRow in rows: try: dates = aRow.findChildren('span', {'class': 'cellTextHot'}) teams = aRow.findChildren('a', {"class": "tabletext"}) if None != teams and len(teams) > 0: gamedate = fixDate(dates[0].getText()) visitor = teams[0].getText(" ") home = teams[1].getText(" ") (visitor, home) = teamsTranslate(visitor, home) # find the proper column cols = aRow.findAll('td') homeOdds = "" visitorOdds = "" try: viOdds = cols[2].findChild('a') odssItems = viOdds.getText("|").split("|") awayOdds, homeOdds = fixOdds(odssItems[1], odssItems[2]) visitorOdds = '-%s' % homeOdds if homeOdds[0] == '-': visitorOdds = visitorOdds[2:] except: pass oddsOut.append( (gamedate, visitor, visitorOdds, home, homeOdds)) except Exception as ex: print "We had an exception!", ex lastDay = -1 for aRow in oddsOut: gamedate, visitor, visitorOdds, home, homeOdds = aRow if gamedate.day != lastDay: print lastDay = gamedate.day dateStr = getDateStr(gamedate) if len(visitorOdds): outs = '' if options.fpOdds: if visitorOdds[0] == '-': outs = '%s %s @ %s (+%s)' % (dateStr, visitor, home, homeOdds) else: outs = '%s %s (+%s) @ %s' % (dateStr, visitor, visitorOdds, home) else: if visitorOdds[0] == '-': outs = '%s %s (%s) @ %s' % (dateStr, visitor, visitorOdds, home) else: outs = '%s %s @ %s (%s)' % (dateStr, visitor, home, homeOdds) print outs if options.extendedOdds: print print 'Odds FP formatted...' lastDay = -1 for aRow in oddsOut: gamedate, visitor, visitorOdds, home, homeOdds = aRow if gamedate.day != lastDay: print lastDay = gamedate.day print gamedate.strftime('%a %b %d') print if len(visitorOdds): post = '' try: val = float(homeOdds) if val < 0: val = val * -1 #print val if val < 3: post = ' XXX' except: pass if visitorOdds[0] == '-': outs = '[*]%s @ [b]%s (+%s)[/b]' % (visitor, home, homeOdds) else: outs = '[*][b]%s (+%s)[/b] @ %s' % (visitor, visitorOdds, home) if len(post): outs = '%s%s' % (outs, post) print outs print print 'Here for editing purposes only...' print print '[*]No Game Qualifies' print if options.dogs: print print 'Information for the sheet' print for aRow in oddsOut: gamedate, visitor, visitorOdds, home, homeOdds = aRow dog = None dogOdds = None val = float(homeOdds) if val <= 0: dog, dogOdds = visitor, visitorOdds else: dog, dogOdds = home, homeOdds if dogOdds[0] == '-': dogOdds = dogOdds[1:] print dog, dogOdds if options.home: print print 'Home odds' print for aRow in oddsOut: gamedate, visitor, visitorOdds, home, homeOdds = aRow print home, homeOdds
def dumpPage(page, options): """ Parse the page into the pieces we need. td class="viBodyBorderNorm" find the second table... find all the tr's """ soup = bs(page) mainTable = soup.findChild("td", {"class": "viBodyBorderNorm"}) tables = mainTable.findAll("table") oddsTable = tables[1] rows = oddsTable.findAll("tr") oddsOut = [] for aRow in rows: try: dates = aRow.findChildren("span", {"class": "cellTextHot"}) teams = aRow.findChildren("a", {"class": "tabletext"}) if None != teams and len(teams) > 0: gamedate = fixDate(dates[0].getText()) visitor = teams[0].getText(" ") home = teams[1].getText(" ") (visitor, home) = teamsTranslate(visitor, home) # find the proper column cols = aRow.findAll("td") homeOdds = "" visitorOdds = "" try: viOdds = cols[2].findChild("a") odssItems = viOdds.getText("|").split("|") awayOdds, homeOdds = fixOdds(odssItems[1], odssItems[2]) visitorOdds = "-%s" % homeOdds if homeOdds[0] == "-": visitorOdds = visitorOdds[2:] except: pass oddsOut.append((gamedate, visitor, visitorOdds, home, homeOdds)) except Exception as ex: print "We had an exception!", ex lastDay = -1 for aRow in oddsOut: gamedate, visitor, visitorOdds, home, homeOdds = aRow if gamedate.day != lastDay: print lastDay = gamedate.day dateStr = getDateStr(gamedate) if len(visitorOdds): outs = "" if options.fpOdds: if visitorOdds[0] == "-": outs = "%s %s @ %s (+%s)" % (dateStr, visitor, home, homeOdds) else: outs = "%s %s (+%s) @ %s" % (dateStr, visitor, visitorOdds, home) else: if visitorOdds[0] == "-": outs = "%s %s (%s) @ %s" % (dateStr, visitor, visitorOdds, home) else: outs = "%s %s @ %s (%s)" % (dateStr, visitor, home, homeOdds) print outs if options.extendedOdds: print print "Odds FP formatted..." lastDay = -1 for aRow in oddsOut: gamedate, visitor, visitorOdds, home, homeOdds = aRow if gamedate.day != lastDay: print lastDay = gamedate.day print gamedate.strftime("%a %b %d") print if len(visitorOdds): post = "" try: val = float(homeOdds) if val < 0: val = val * -1 # print val if val < 3: post = " XXX" except: pass if visitorOdds[0] == "-": outs = "[*]%s @ [b]%s (+%s)[/b]" % (visitor, home, homeOdds) else: outs = "[*][b]%s (+%s)[/b] @ %s" % (visitor, visitorOdds, home) if len(post): outs = "%s%s" % (outs, post) print outs print print "Here for editing purposes only..." print print "[*]No Game Qualifies" print if options.dogs: print print "Information for the sheet" print for aRow in oddsOut: gamedate, visitor, visitorOdds, home, homeOdds = aRow dog = None dogOdds = None val = float(homeOdds) if val <= 0: dog, dogOdds = visitor, visitorOdds else: dog, dogOdds = home, homeOdds if dogOdds[0] == "-": dogOdds = dogOdds[1:] print dog, dogOdds if options.home: print print "Home odds" print for aRow in oddsOut: gamedate, visitor, visitorOdds, home, homeOdds = aRow print home, homeOdds