Example #1
0
  def get(self):
    ''' game id '''
    gid = self.request.get('gid')
    
    ''' derive year/month/day from the game id '''
    year = gid[:4]
    month = gid[5:7]
    day = gid[8:10]
    
    ''' determine dates for links based on date selected '''
    selDay = date(int(year), int(month), int(day))
    prevDay = selDay - timedelta(days=1)
    nextDay = selDay + timedelta(days=1)
    
    masterScoreboardDOM = xml_helper.fetchMasterScoreboard(year, month, day)
    gamesNode = masterScoreboardDOM.getElementsByTagName("games")[0]
    gameday = xml_helper.buildGameDay(gamesNode)

    games = []
    game = {}
    boxscore = {}
    for node in gamesNode.childNodes:
      if node.nodeType == node.ELEMENT_NODE:
        game = xml_helper.buildGame(node)
        if gid == game.gameday:
          selectedGame = xml_helper.buildGame(node)
          boxscoreDOM = xml_helper.fetchBoxscore(gameday.year, gameday.month, gameday.day, game.gameday)
          if boxscoreDOM is None:
            boxscore = {}
          else:
            boxscoreNode = boxscoreDOM.getElementsByTagName("boxscore")[0]
            boxscore = xml_helper.buildBoxscore(boxscoreNode)
        games.append(game)

    template = "boxscore.html"
    template_values = {
      'gid': gid,
      'gameday': gameday,
      'games': games,
      'game': selectedGame,
      'boxscore': boxscore,
      'prevDay': prevDay,
      'selDay': selDay,
      'nextDay': nextDay
    }

    self.generate(template, template_values)
Example #2
0
  def get(self):
    refresh = self.request.get('r')
    if refresh != "on":
      refresh = "off";
    refreshTime = self.request.get('t')
    if refreshTime == "":
      refreshTime = 60

    ''' game id '''
    gid = self.request.get('gid')
    
    ''' derive year/month/day from the game id '''
    year = gid[:4]
    month = gid[5:7]
    day = gid[8:10]
    
    ''' determine dates for links based on date selected '''
    selDay = date(int(year), int(month), int(day))
    prevDay = selDay - timedelta(days=1)
    nextDay = selDay + timedelta(days=1)    
    today = datetime.today() - timedelta(hours=5)
    lastUpdate = datetime.today() - timedelta(hours=5)

    masterScoreboardDOM = xml_helper.fetchMasterScoreboard(year, month, day)
    gamesNode = masterScoreboardDOM.getElementsByTagName("games")[0]
    gameday = xml_helper.buildGameDay(gamesNode)

    games = []
    game = {}
    boxscore = {}
    highlights = {}
    innings = []
    for node in gamesNode.childNodes:
      if node.nodeType == node.ELEMENT_NODE:
        game = xml_helper.buildGame(node)
        if gid == game.gameday:
          #selectedGame = xml_helper.buildGame(node)
          selectedGame = game
          boxscoreDOM = xml_helper.fetchBoxscore(gameday.year, gameday.month, gameday.day, game.gameday)
          boxscoreNode = boxscoreDOM.getElementsByTagName("boxscore")[0]
          boxscore = xml_helper.buildBoxscore(boxscoreNode)
          highlightsDOM = xml_helper_highlights.fetchHighlights(gameday.year, gameday.month, gameday.day, game.gameday)
          if highlightsDOM is not None:
            highlightsNode = highlightsDOM.getElementsByTagName("highlights")[0]
            highlights = xml_helper_highlights.buildHighlights(highlightsNode, gid)
        games.append(game)

    template_values = {
      'gid': gid,
      'gameday': gameday,
      'games': games,
      'game': selectedGame,
      'boxscore': boxscore,
      'highlights': highlights,
      'lastUpdate': lastUpdate.strftime("%m/%d %I:%M:%S %p"),
      'prevDay': prevDay,
      'selDay': selDay,
      'today': today,
      'nextDay': nextDay
    }

    path = os.path.join(os.path.dirname(__file__), 'html/highlights.html')
    self.response.out.write(template.render(path, template_values))