예제 #1
0
파일: spfin.py 프로젝트: amoydream/Metarace
    def startlist_report(self, program=False):
        """Return a startlist report."""
        ret = []
        if self.event[u'type'] == 'sprint final':
            sec = printing.sprintfinal()
        else:
            sec = printing.sprintround()
        headvec = [
            u'Event', self.evno, u':', self.event[u'pref'], self.event[u'info']
        ]
        if not program:
            headvec.append(u'- Start List')
        sec.heading = u' '.join(headvec)

        lapstring = strops.lapstring(self.event[u'laps'])
        substr = u' '.join(
            [lapstring, self.event[u'dist'], self.event[u'prog']]).strip()
        if substr:
            sec.subheading = substr

        for cr in self.contests:
            if cr[COL_CONTEST] == 'Heat 1':
                byeflag = None
                bno = cr[COL_B_NO]
                bname = cr[COL_B_STR].decode('utf-8')
                timestr = None
                if cr[COL_CONTEST] == u'bye':
                    timestr = u' '
                    bno = u' '
                    bname = u' '
                    byeflag = u' '
                if self.event[u'type'] == 'sprint final':
                    ## HACK: assume no bye
                    sec.lines.append([
                        None,
                        [
                            None, cr[COL_A_NO], cr[COL_A_STR].decode('utf-8'),
                            None, None, None, None
                        ],
                        [
                            None, cr[COL_B_NO], cr[COL_B_STR].decode('utf-8'),
                            None, None, None, None
                        ]
                    ])
                else:
                    sec.lines.append([
                        cr[COL_CONTEST] + u':',
                        [
                            None, cr[COL_A_NO], cr[COL_A_STR].decode('utf-8'),
                            None
                        ], [byeflag, bno, bname, None], timestr
                    ])
                ret.append(sec)
            return ret
예제 #2
0
파일: spfin.py 프로젝트: amoydream/Metarace
    def result_report(self, recurse=False):
        """Return a list of printing sections containing the race result."""
        ret = []
        sec = printing.sprintround()
        sec.heading = u'Event ' + self.evno + u': ' + u' '.join(
            [self.event[u'pref'], self.event[u'info']]).strip()
        sec.lines = []
        lapstring = strops.lapstring(self.event[u'laps'])
        substr = u' '.join(
            [lapstring, self.event[u'dist'], self.event[u'prog']]).strip()
        if substr:
            sec.subheading = substr

        for cr in self.contests:
            # if winner set, report a result, otherwise, use startlist style:
            cprompt = cr[COL_CONTEST] + u':'
            if cr[COL_WINNER]:
                avec = [
                    cr[COL_A_PLACE], cr[COL_A_NO],
                    cr[COL_A_STR].decode('utf-8'), None
                ]
                bvec = [
                    cr[COL_B_PLACE], cr[COL_B_NO],
                    cr[COL_B_STR].decode('utf-8'), None
                ]
                ft = None
                if cr[COL_200M] is not None:
                    ft = cr[COL_200M].rawtime(2)
                else:
                    ft = u' '
                if cr[COL_WINNER] == cr[COL_A_NO]:
                    sec.lines.append([cprompt, avec, bvec, ft])
                else:
                    sec.lines.append([cprompt, bvec, avec, ft])
            else:
                sec.lines.append([
                    cprompt,
                    [None, cr[COL_A_NO], cr[COL_A_STR].decode('utf-8'), None],
                    [None, cr[COL_B_NO], cr[COL_B_STR].decode('utf-8'), None],
                    None
                ])
        ret.append(sec)

        if len(self.comment) > 0:
            s = printing.bullet_text('comms')
            s.subheading = u'Decisions of the commissaires panel'
            for comment in self.comment:
                s.lines.append([None, comment])
            ret.append(s)
        return ret
예제 #3
0
파일: spfin.py 프로젝트: amoydream/Metarace
    def delayed_announce(self):
        """Initialise the announcer's screen after a delay."""
        if self.winopen:
            self.meet.announce.clrall()
            self.meet.ann_title(' '.join([
                self.meet.event_string(self.evno), ':', self.event[u'pref'],
                self.event[u'info']
            ]))
            lapstring = strops.lapstring(self.event[u'laps'])
            substr = u' '.join(
                [lapstring, self.event[u'dist'], self.event[u'prog']]).strip()
            if substr:
                self.meet.announce.postxt(1, 0, substr.center(80))
            self.meet.announce.linefill(2, '_')
            self.meet.announce.linefill(8, '_')
            # announce current contest
            i = self.current_contest_combo.get_active_iter()
            if i is not None:  # contest selected ok
                cid = self.contests.get_value(i, COL_CONTEST)
                self.meet.announce.postxt(4, 0, u'Contest: ' + cid)
                ano = self.contests.get_value(i, COL_A_NO).rjust(3)
                astr = self.contests.get_value(i, COL_A_STR).decode('utf-8')
                aplace = self.contests.get_value(i, COL_A_PLACE).ljust(3)
                bni = self.contests.get_value(i, COL_B_NO)
                bno = bni.rjust(3)
                bstr = self.contests.get_value(i, COL_B_STR).decode('utf-8')
                bplace = self.contests.get_value(i, COL_B_PLACE).ljust(3)
                if self.contests.get_value(i, COL_WINNER) == bni:
                    self.meet.announce.postxt(
                        6, 0, bplace + u' ' + bno + u' ' + bstr)
                    self.meet.announce.postxt(
                        7, 0, aplace + u' ' + ano + u' ' + astr)
                else:
                    self.meet.announce.postxt(
                        6, 0, aplace + u' ' + ano + u' ' + astr)
                    self.meet.announce.postxt(
                        7, 0, bplace + u' ' + bno + u' ' + bstr)
                ft = self.contests.get_value(i, COL_200M)
                if ft is not None:
                    self.meet.announce.postxt(
                        6, 60, u'200m: ' + ft.rawtime(2).rjust(10))
                    self.meet.announce.postxt(
                        7, 60, u' Avg: ' + ft.speedstr().strip().rjust(10))
            # show 'leaderboard'
            lof = 10
            for c in self.contests:
                cid = (c[COL_CONTEST] + u':').ljust(8)
                win = c[COL_WINNER]
                lr = u''
                rr = u''
                sep = u' v '
                if win:
                    if c[COL_CONTEST] == u'bye':
                        sep = '   '
                    else:
                        sep = 'def'
                if win == c[COL_B_NO]:
                    lr = (c[COL_B_NO].rjust(3) + u' ' +
                          strops.truncpad(c[COL_B_STR].decode('utf-8'), 29))
                    rr = (c[COL_A_NO].rjust(3) + u' ' +
                          strops.truncpad(c[COL_A_STR].decode('utf-8'), 29))
                else:
                    lr = (c[COL_A_NO].rjust(3) + u' ' +
                          strops.truncpad(c[COL_A_STR].decode('utf-8'), 29))
                    rr = (c[COL_B_NO].rjust(3) + u' ' +
                          strops.truncpad(c[COL_B_STR].decode('utf-8'), 29))
                self.meet.announce.postxt(lof, 0, u' '.join([cid, lr, sep,
                                                             rr]))
                lof += 1

        return False