def init_team(self, team): """Create team if not exists.""" team_stored = Team.all().filter('name =',team['name']).get() if team_stored is None: team_stored = Team(name=team['name']) short_match = re.search(r'([a-z]{3})\.gif$',team['flag']) team_stored.flag = team['flag'] team_stored.short = short_match.group(1) team_stored.href = team['href'] team_stored.put() return team_stored
def init_team(self, team): """Create team if not exists.""" team_stored = Team.all().filter('name =', team['name']).get() if team_stored is None: team_stored = Team(name=team['name']) short_match = re.search(r'([a-z]{3})\.gif$', team['flag']) team_stored.flag = team['flag'] team_stored.short = short_match.group(1) team_stored.href = team['href'] team_stored.put() return team_stored
def init_team(self, team): """Create team if not exists.""" team_stored = Team.all().filter('name =',team['name']).get() if team_stored is None: team_stored = Team(name=team['name']) short_match = re.search(r'([a-z]{3})\.png$',team['flag']) team_stored.flag = team['flag'] team_stored.short = short_match.group(1) team_stored.href = "http://www.uefa.com/" + team['href'] team_stored.teamId = re.match(r'/uefaeuro/season=2012/teams/team=([0-9]+)/index.html', team['href']).group(1) team_stored.put() return team_stored
def init_team(self, team): """Create team if not exists.""" team_stored = Team.all().filter('name =', team['name']).get() if team_stored is None: team_stored = Team(name=team['name']) short_match = re.search(r'([a-z]{3})\.png$', team['flag']) team_stored.flag = team['flag'] team_stored.short = short_match.group(1) team_stored.href = "http://www.uefa.com/" + team['href'] team_stored.teamId = re.match( r'/uefaeuro/season=2012/teams/team=([0-9]+)/index.html', team['href']).group(1) team_stored.put() return team_stored
def post(self): team = Team.for_user(users.get_current_user()) if not team: team = Team() team.name = self.request.get('name') team.people = self.request.get('people') location = self.request.get('location') team.location = self.request.get('location') if location == 'Other': team.location = self.request.get('otherLocation') team.description = self.request.get('description') team.url = self.request.get('url') team.video = self.request.get('video') team.image = self.request.get('image') team.winner = self.request.get('winner') team.email = self.request.get('email') team.votes = 0 team.hackday = '092011' team.user = users.get_current_user() team.put() self.render('add_received', { })
def team_process(self, f): pattern = r""" <td>(\d+)</td> # rank <td>([A-Za-z. (),_0-9]+)</td> # name .* # rest of the line <td>(\d+)/(\d+)</td> # attempt, problemcount """ reg = re.compile( pattern, re.VERBOSE ) rankpat = r""" [A-Za-z]+\ ([A-Za-z]+\ \d+) # weekday, month, day \ \d\d:\d\d:\d\d\ [A-Za-z]+\ (\d+) # year """ rankreg = re.compile( rankpat, re.VERBOSE ) #finding the date of the event match = rankreg.search( f ) cdate = "" if match: cdate = match.group(1) + " " + match.group(2) logging.error( cdate ) logging.error( "finding something" ) else: logging.error( "nothing found" ) bests = "" results = reg.finditer(f) rank = 0; for result in results: # picking up details rank += 1 name = result.group(2) attempts = int(result.group(3)) solved = int(result.group(4)) earned = 0 # ignore autogenerated names if self.invalidName( name ): continue # pick up the earned points if rank <= 10 and int(solved) != 0: earned = points[ rank-1 ] if rank <= 3: if rank == 2: bests += ", " elif rank == 3: bests += " and " bests += name c = db.Query( Team ) c.filter( 'name =' , name ) teams = c.fetch(1) # updating database if len( teams ) == 0: # it was never in ranklist team = Team() team.name = name team.solve = solved team.points = earned team.contest = 1 team.attempt = attempts team.image = "img/nsu2.gif" if team.attempt: team.accuracy = str( round(( team.solve * 100. ) / team.attempt, 2) ) else: team.accuracy = str( 0.0 ) team.put() else: for team in teams: # it's one object though team.solve += solved team.points += earned team.contest += 1 team.attempt += attempts if team.attempt: team.accuracy = str( round(( team.solve * 100. ) / team.attempt,2) ) team.put() return [ bests, cdate ]
def team_process(self, f): pattern = r""" <td>(\d+)</td> # rank <td>([A-Za-z. (),_]+)</td> # name .* # rest of the line <td>(\d+)/(\d+)</td> # attempt, problemcount """ reg = re.compile( pattern, re.VERBOSE ) rankpat = r""" [A-Za-z]+\ ([A-Za-z]+\ \d+) # weekday, month, day \ \d\d:\d\d:\d\d\ [A-Za-z]+\ (\d+) # year """ rankreg = re.compile( rankpat, re.VERBOSE ) #finding the date of the event match = rankreg.search( f ) cdate = "" if match: cdate = match.group(1) + " " + match.group(2) logging.error( cdate ) logging.error( "finding something" ) else: logging.error( "nothing found" ) bests = "" results = reg.finditer(f) rank = 0; for result in results: # picking up details rank += 1 name = result.group(2) attempts = int(result.group(3)) solved = int(result.group(4)) earned = 0 # pick up the earned points if rank <= 10 and int(solved) != 0: earned = points[ rank-1 ] if rank <= 3: if rank == 2: bests += ", " elif rank == 3: bests += " and " bests += name c = db.Query( Team ) c.filter( 'name =' , name ) teams = c.fetch(1) # updating database if len( teams ) == 0: # it was never in ranklist team = Team() team.name = name team.solve = solved team.points = earned team.contest = 1 team.attempt = attempts team.image = "img/nsu2.gif" team.accuracy = str( round(( team.solve * 100. ) / team.attempt, 2) ) team.put() else: for team in teams: # it's one object though team.solve += solved team.points += earned team.contest += 1 team.attempt += attempts team.accuracy = str( round(( team.solve * 100. ) / team.attempt,2) ) team.put() return [ bests, cdate ]