예제 #1
0
파일: Server.py 프로젝트: DenisKealy/wcsapp
def handleScheduleEntry(entry, title, name):
    global scheduleId
    global lastSchedule
    lastSchedule = DBEntry()
    time = getStr(entry, 'date')
    if time == None:
        time = ''
    lastSchedule.time = getTimestampFromDate(time)
    lastSchedule.name = name
    lastSchedule.division = getDivisionFromTitle(title)
    lastSchedule.region = getRegionFromTitle(title)
    lastSchedule.round = getRoundFromTitle(title)
    lastSchedule.id = scheduleId;
    try:
        mergedSchedule = False
        for candidateSchedule in scheduleMap[lastSchedule.region][lastSchedule.division][lastSchedule.round]:
            if ((candidateSchedule.time < lastSchedule.time + 2 * 60 * 60 * 1000) and
                (candidateSchedule.time > lastSchedule.time - 6 * 60 * 60 * 1000) and
                candidateSchedule.name == lastSchedule.name):
                lastSchedule = candidateSchedule
                mergedSchedule = True
        if not mergedSchedule:
            scheduleId += 1
            scheduleMap[lastSchedule.region][lastSchedule.division][lastSchedule.round].append(lastSchedule)
            schedule.append(lastSchedule)
    except KeyError:
        print "KeyError for " + lastSchedule.region + " - " + lastSchedule.division + " - " + lastSchedule.round
예제 #2
0
파일: Server.py 프로젝트: sprocter/wcsapp
def handleStandings(wikicode):
    ranks = wikicode.filter(True, r'\|\d+', forcetype=Text)
    linkifiedNames = wikicode.filter_wikilinks()
    flagRace = wikicode.filter(True, r'flagRace', forcetype=Template)
    points = wikicode.filter(True, r"'''", forcetype=Tag)
    for i in range(0, len(flagRace)):
        standing = DBEntry()
        standing.rank = int((ranks[i][1 + ranks[i].rfind('\n'):].replace('|','')).strip())
        standing.name = unicode(linkifiedNames[i + 2].title)
        standing.flag = unicode(flagRace[i].params[0].value)
        standing.race = unicode(flagRace[i].params[1].value)
        standing.points = int(unicode(points[i].contents))
        standings.append(standing)
        i += 1
예제 #3
0
파일: Server.py 프로젝트: DenisKealy/wcsapp
def handleGroupEntry(entry):
    newParticipant = DBEntry()
    for param in entry.params:
        for template in param.value.filter_templates():
            if unicode(template.name) == 'player':
                newParticipant.name = getStr(template, '1')
                newParticipant.flag = getStr(template, 'flag')
                newParticipant.race = getStr(template, 'race')
    newParticipant.place = getInt(entry, 'place')
    newParticipant.matcheswon = getInt(entry, 'win_m')
    newParticipant.matcheslost = getInt(entry, 'lose_m')
    newParticipant.mapswon = getInt(entry, 'win_g')
    newParticipant.mapslost = getInt(entry, 'lose_g')
    newParticipant.result = getStr(entry, 'bg')
    newParticipant.scheduleid = lastSchedule.id
    participants.append(newParticipant)