コード例 #1
0
ファイル: __init__.py プロジェクト: midnjerry/bb-oftl-hrd
 def get(self):
   logging.debug("checking OFL match results...")
   # We have to parse OFL Schedule to get up to date results.
   season, week = misc.get_ofl_season_and_week()
   season += 3
   weekbegin = week - 1
   if weekbegin < 1:
     weekbegin = 1
   weekend = week + 1
   if weekend > 16:
     weekend = 16
   for week in range(weekbegin, weekend+1):
     parser = OFLScheduleParser()
     data = []
     data = parser.parse(season, week)
     parser.update_schedule_entries(data)
     #Now that entries are updated, let's look at predictions for all coaches
     put_list=[]
     predictions = OFL_Prediction.all().filter("season =", season).filter("week =", week)
     for prediction in predictions:
       keyname = prediction.key().name()
       match = OFL_Match.get_by_key_name(keyname)
       # match exists so compare - should not occur unless Thul changes team matchups
       if match:
         if match.gamePlayed:
           if prediction.Update(match.scoreA, match.scoreB):
             put_list.append(prediction)
             logging.debug("Updating prediction %s for %s" % (prediction.key().name(), prediction.parent().key().name())) 
     batch_put(put_list)
コード例 #2
0
 def choice_getter(prediction):
   match = OFL_Match.get_by_key_name(prediction.key().name())
   html = "<img src='http://www.shalkith.com/bloodbowl/%s'/>" % (match.teamAlogo)
   if not match.gamePlayed:
     html += "<input type='radio' name='%schoice' value='-1' %s>" % (match.key().name(), prediction.isChecked(-1))
     html += "<input type='radio' name='%schoice' value='0' %s>" % (match.key().name(), prediction.isChecked(0))
     html += "<input type='radio' name='%schoice' value='1' %s>" % (match.key().name(), prediction.isChecked(1))
   else:
     html += "<input type='radio' name='%schoice' value='-1' disabled %s>" % (match.key().name(), prediction.isChecked(-1))
     html += "<input type='radio' name='%schoice' value='0' disabled %s>" % (match.key().name(), prediction.isChecked(0))
     html += "<input type='radio' name='%schoice' value='1' disabled %s>" % (match.key().name(), prediction.isChecked(1))
   html += "<img src='http://www.shalkith.com/bloodbowl/%s'/>" % (match.teamBlogo)
   return html
コード例 #3
0
def update_predictions(coach,season,week):
  matches = OFL_Match.all().filter("season =", season).filter("week =", week)
  for match in matches:        
    prediction = OFL_Prediction.get_by_key_name(match.key().name(), parent=coach)
    if not prediction:
      prediction = OFL_Prediction(key_name = match.key().name(), parent = coach, match = match)
      if match.gamePlayed:
        prediction.Disqualify()
      prediction.season = season
      prediction.week = week
      prediction.put()
    if match.gamePlayed:
      if prediction.Update(match.scoreA, match.scoreB):
        prediction.put()
コード例 #4
0
 def choice_getter(prediction):
   match = OFL_Match.get_by_key_name(prediction.key().name())
   #html = "<img src='./get_wager_pic?keyname=%s&team=A'/>" % (prediction.key().name())
   html = "<img src='http://www.oldworldfootball.com/%s'/>" % (match.teamAlogo)
   if not match.gamePlayed:
     html += "<input type='radio' name='%schoice' value='-1' %s>" % (match.key().name(), prediction.isChecked(-1))
     html += "<input type='radio' name='%schoice' value='0' %s>" % (match.key().name(), prediction.isChecked(0))
     html += "<input type='radio' name='%schoice' value='1' %s>" % (match.key().name(), prediction.isChecked(1))
   else:
     html += "<input type='radio' name='%schoice' value='-1' disabled %s>" % (match.key().name(), prediction.isChecked(-1))
     html += "<input type='radio' name='%schoice' value='0' disabled %s>" % (match.key().name(), prediction.isChecked(0))
     html += "<input type='radio' name='%schoice' value='1' disabled %s>" % (match.key().name(), prediction.isChecked(1))
   html += "<img src='http://www.oldworldfootball.com/%s'/>" % (match.teamBlogo)
   #html += "<img src='./get_wager_pic?keyname=%s&team=B'/>" % (prediction.key().name())
   return html
コード例 #5
0
def update_predictions(coach, season, week):
    matches = OFL_Match.all().filter("season =", season).filter("week =", week)
    for match in matches:
        prediction = OFL_Prediction.get_by_key_name(match.key().name(),
                                                    parent=coach)
        if not prediction:
            prediction = OFL_Prediction(key_name=match.key().name(),
                                        parent=coach,
                                        match=match)
            if match.gamePlayed:
                prediction.Disqualify()
            prediction.season = season
            prediction.week = week
            prediction.put()
        if match.gamePlayed:
            if prediction.Update(match.scoreA, match.scoreB):
                prediction.put()
コード例 #6
0
def update_schedule_entries(coach, season, week, data):
    def chunker(seq, size):
        return (seq[pos:pos + size] for pos in xrange(0, len(seq), size))

    point_counter = 1
    match_data = []
    for chunk in chunker(data, 11):
        if len(chunk) == 11:
            match_name = str(season) + ":" + str(
                week) + "|" + chunk[2] + " vs. " + chunk[8]
            match = OFL_Match.get_or_insert(match_name)
            # match = OFL_Match(key_name = match_name)
            match.season = season
            match.week = week
            match.teamAcolor = chunk[0]
            match.teamAlogo = chunk[1]
            match.teamA = chunk[2]
            match.teamAcoach = chunk[3]
            match.teamArace = chunk[4]
            # Check to see if game has been played
            if not "vs.gif" in chunk[5]:
                #if chunk[5]:
                #if data[0].isdigit():
                scoreA, scoreB = chunk[5].split(" - ")
                match.scoreA = int(scoreA)
                match.scoreB = int(scoreB)
                match.gamePlayed = True
            # Check if prediction exists, if not, create and disqualify
            prediction = OFL_Prediction.get_by_key_name(match_name,
                                                        parent=coach)
            if not prediction:
                prediction = OFL_Prediction(key_name=match_name, parent=coach)
                if match.gamePlayed:
                    prediction.Disqualify()
                prediction.season = season
                prediction.week = week
                prediction.put()
            if match.gamePlayed:
                if prediction.Update(match.scoreA, match.scoreB):
                    prediction.put()
            match.teamBcolor = chunk[6]
            match.teamBlogo = chunk[7]
            match.teamB = chunk[8]
            match.teamBcoach = chunk[9]
            match.teamBrace = chunk[10]
            match.put()
コード例 #7
0
def update_schedule_entries(coach, season, week, data):
  def chunker(seq, size):
    return (seq[pos:pos + size] for pos in xrange(0, len(seq), size))
  

  
  point_counter = 1
  match_data = []
  for chunk in chunker(data,11):
    if len(chunk) == 11:
      match_name = str(season) + ":" + str(week) + "|" + chunk[2] + " vs. " + chunk[8]
      match = OFL_Match.get_or_insert(match_name)      
      # match = OFL_Match(key_name = match_name)      
      match.season = season
      match.week = week
      match.teamAcolor = chunk[0]    
      match.teamAlogo = chunk[1]
      match.teamA = chunk[2]
      match.teamAcoach = chunk[3]
      match.teamArace = chunk[4]
      # Check to see if game has been played
      if not "vs.gif" in chunk[5]:
        #if chunk[5]:
        #if data[0].isdigit():
        scoreA, scoreB = chunk[5].split(" - ") 
        match.scoreA = int(scoreA)
        match.scoreB = int(scoreB) 
        match.gamePlayed = True
      # Check if prediction exists, if not, create and disqualify
      prediction = OFL_Prediction.get_by_key_name(match_name, parent=coach)
      if not prediction:
        prediction = OFL_Prediction(key_name = match_name, parent = coach)
        if match.gamePlayed:
          prediction.Disqualify()
        prediction.season = season
        prediction.week = week
        prediction.put()
      if match.gamePlayed:
        if prediction.Update(match.scoreA, match.scoreB):
          prediction.put()        
      match.teamBcolor = chunk[6]    
      match.teamBlogo = chunk[7]
      match.teamB = chunk[8]
      match.teamBcoach = chunk[9]
      match.teamBrace = chunk[10]
      match.put()
コード例 #8
0
 def choice_getter(prediction):
     match = OFL_Match.get_by_key_name(prediction.key().name())
     html = "<img src='http://www.shalkith.com/bloodbowl/%s'/>" % (
         match.teamAlogo)
     if not match.gamePlayed:
         html += "<input type='radio' name='%schoice' value='-1' %s>" % (
             match.key().name(), prediction.isChecked(-1))
         html += "<input type='radio' name='%schoice' value='0' %s>" % (
             match.key().name(), prediction.isChecked(0))
         html += "<input type='radio' name='%schoice' value='1' %s>" % (
             match.key().name(), prediction.isChecked(1))
     else:
         html += "<input type='radio' name='%schoice' value='-1' disabled %s>" % (
             match.key().name(), prediction.isChecked(-1))
         html += "<input type='radio' name='%schoice' value='0' disabled %s>" % (
             match.key().name(), prediction.isChecked(0))
         html += "<input type='radio' name='%schoice' value='1' disabled %s>" % (
             match.key().name(), prediction.isChecked(1))
     html += "<img src='http://www.shalkith.com/bloodbowl/%s'/>" % (
         match.teamBlogo)
     return html
コード例 #9
0
 def choice_getter(prediction):
     match = OFL_Match.get_by_key_name(prediction.key().name())
     #html = "<img src='./get_wager_pic?keyname=%s&team=A'/>" % (prediction.key().name())
     html = "<img src='http://www.oldworldfootball.com/%s'/>" % (
         match.teamAlogo)
     if not match.gamePlayed:
         html += "<input type='radio' name='%schoice' value='-1' %s>" % (
             match.key().name(), prediction.isChecked(-1))
         html += "<input type='radio' name='%schoice' value='0' %s>" % (
             match.key().name(), prediction.isChecked(0))
         html += "<input type='radio' name='%schoice' value='1' %s>" % (
             match.key().name(), prediction.isChecked(1))
     else:
         html += "<input type='radio' name='%schoice' value='-1' disabled %s>" % (
             match.key().name(), prediction.isChecked(-1))
         html += "<input type='radio' name='%schoice' value='0' disabled %s>" % (
             match.key().name(), prediction.isChecked(0))
         html += "<input type='radio' name='%schoice' value='1' disabled %s>" % (
             match.key().name(), prediction.isChecked(1))
     html += "<img src='http://www.oldworldfootball.com/%s'/>" % (
         match.teamBlogo)
     #html += "<img src='./get_wager_pic?keyname=%s&team=B'/>" % (prediction.key().name())
     return html
コード例 #10
0
 def nameB_getter(prediction):
   match = OFL_Match.get_by_key_name(prediction.key().name())
   html = "%s (%s - %s)" % (match.teamB, match.teamBcoach, match.teamBrace)
   return html
コード例 #11
0
 def nameB_getter(prediction):
     match = OFL_Match.get_by_key_name(prediction.key().name())
     html = "%s (%s - %s)" % (match.teamB, match.teamBcoach,
                              match.teamBrace)
     return html
コード例 #12
0
 def nameA_getter(prediction):
     match = OFL_Match.get_by_key_name(prediction.key().name())
     html = "%s (%s)" % (match.teamA, match.teamAcoach)
     return html
コード例 #13
0
 def nameA_getter(prediction):
   match = OFL_Match.get_by_key_name(prediction.key().name())
   html = "%s (%s)" % (match.teamA, match.teamAcoach)
   return html