예제 #1
0
 def getHeading(self, report):
     if report.date is None:
         answer = "Results"
     else:
         answer = "Results: {0}".format(
             DateFormatter.formatDate(report.date, True, True))
     return answer
예제 #2
0
파일: results.py 프로젝트: hicksjduk/sehicl
 def getTitle(self):
     report = self.getReport()
     if report.date is None:
         answer = "SEHICL Results"
     else:
         answer = "SEHICL Results: {0}".format(DateFormatter.formatDate(report.date, True, True))
     return answer
예제 #3
0
 def getOtherDateLinks(self, report):
     html = """
     <ul id="datenav" class="noprint">
     <li>Results on other dates:</li>
     {datelinks}
     </ul>
     """
     linkHtml = """
     <li>
         <a href="{datelink.url}">{date}</a>
     </li>
     """
     dates = {}
     for d in report.otherDates:
         isoDate = DateFormatter.formatDateToISO(d)
         dateStr = DateFormatter.formatDate(d, False, None)
         dates[isoDate] = dateStr
     if len(dates) == 0:
         answer = ""
     else:
         linkData = []
         for isoDate in sorted(dates.keys(), reverse=True):
             dateStr = dates[isoDate]
             if len(linkData) == 0 and self.allParams.get("date",
                                                          None) is not None:
                 link = PageLink("latestResults", self)
             else:
                 link = PageLink("dateResults", self, {"date": isoDate})
             linkData.append(linkHtml.format(datelink=link, date=dateStr))
         answer = html.format(datelinks=string.join(linkData, "\n"))
     return answer
예제 #4
0
 def getStatusMessage(self, table):
     html = """
     <p class="statusMessage">{status}.</p>
     """
     if table.lastCompleteMatchDate is None:
         answer = ""
     elif self.allParams.get("archive", "no") == "yes":
         answer = ""
     else:
         if table.complete:
             message = "Final averages"
         else:
             dateStr = DateFormatter.formatDate(table.lastCompleteMatchDate,
                                                True, True)
             if table.toCome == 0:
                 template = "Includes all games up to and including {0}"
                 message = template.format(dateStr)
             else:
                 template = "Date of last game included: {0} ({1} {2} to come)"
                 message = template.format(
                     dateStr, table.toCome,
                     TextUtils.getGrammaticalNumber(table.toCome, "result",
                                                    "results"))
         answer = html.format(status=message)
     return answer
예제 #5
0
파일: results.py 프로젝트: hicksjduk/sehicl
 def getOtherDateLinks(self, report):
     html = """
     <ul id="datenav" class="noprint">
     <li>Results on other dates:</li>
     {datelinks}
     </ul>
     """
     linkHtml = """
     <li>
         <a href="{datelink.url}">{date}</a>
     </li>
     """ 
     dates = {}
     for d in report.otherDates:
         isoDate = DateFormatter.formatDateToISO(d)
         dateStr = DateFormatter.formatDate(d, False, None)
         dates[isoDate] = dateStr
     if len(dates) == 0:
         answer = ""
     else:
         linkData = []
         for isoDate in sorted(dates.keys(), reverse=True):
             dateStr = dates[isoDate]
             if len(linkData) == 0 and self.allParams.get("date", None) is not None:
                 link = PageLink("latestResults", self)
             else:
                 link = PageLink("dateResults", self, {"date": isoDate})
             linkData.append(linkHtml.format(datelink=link, date=dateStr))
         answer = html.format(datelinks=string.join(linkData, "\n"))
     return answer
예제 #6
0
 def getMatchLine(self, match, teamId, leagueResLink):
     html = """
     <tr>
         <td class="date">{date}</td>
         <td class="time">{time}</td>
         <td class="court">{court}</td>
         <td class="opponent"><a href="{oppfix.url}">{oppname}</a></td>
         <td class="homeAway">{homeaway}</td>
         <td class="result">{result}</td>
     </tr>
     """
     mDate = DateFormatter.formatDate(match.datetime, False, False)
     mTime = DateFormatter.formatTime(match.datetime)
     mCourt = match.court
     mOppFixLink = PageLink("teamFixtures", self, {"team": match.opponentId}, True)
     mOppName = match.opponentName
     mHomeAway = "H" if match.home else "A"
     mOppId = match.opponentId
     mHomeId = teamId if match.home else mOppId
     mAwayId = mOppId if match.home else teamId 
     if match.result:
         if match.margin:
             res = "{0} by {1}".format(match.result, match.margin)
         else:
             res = "{0}".format(match.result)
         mResult = "<a href=\"{leaguefix.url}#{homeid}{awayid}\">{result}</a>".format(leaguefix=leagueResLink, teamid=teamId, homeid=mHomeId, awayid=mAwayId, result=res)
     else:
         mResult = ""
     answer = html.format(date=mDate, time=mTime, court=mCourt, oppfix = mOppFixLink, oppname=mOppName, homeaway=mHomeAway, result=mResult)
     return answer;
예제 #7
0
 def getTitle(self):
     report = self.getReport()
     if report.date is None:
         answer = "SEHICL Results"
     else:
         answer = "SEHICL Results: {0}".format(
             DateFormatter.formatDate(report.date, True, True))
     return answer
예제 #8
0
파일: results.py 프로젝트: hicksjduk/sehicl
 def getResultsForDate(self, theDate, matches):
     html = """
     <tr>
         <td class="date" colspan="2">{date}</td>
     </tr>
     {results}
     """
     resList = []
     for m in sorted(matches, key=attrgetter("time", "court")):
         resList.append(self.getMatchResult(m))
     answer = html.format(date=DateFormatter.formatDate(theDate, True, True), results=string.join(resList, "\n"))
     return answer
예제 #9
0
 def getResultsForDate(self, theDate, matches):
     html = """
     <tr>
         <td class="date" colspan="2">{date}</td>
     </tr>
     {results}
     """
     resList = []
     for m in sorted(matches, key=attrgetter("time", "court")):
         resList.append(self.getMatchResult(m))
     answer = html.format(date=DateFormatter.formatDate(
         theDate, True, True),
                          results=string.join(resList, "\n"))
     return answer
예제 #10
0
 def getMatchLines(self, theDate, matches):
     html = """
     <tbody class="nobreak">
     <tr>
         <td class="date" colspan="3">{date}</td>
     </tr>
     {matchLines}
     </tbody>
     """
     answer = ""
     if len(matches) > 0:
         prevTime = None
         mLines = []
         for m in sorted(matches, key=attrgetter("time", "court")):
             mLines.append(self.getMatchLine(m, prevTime))
             prevTime = m.time
         dateStr = DateFormatter.formatDate(theDate, True, True)
         answer = html.format(date=dateStr, matchLines=string.join(mLines, "\n"))
     return answer
예제 #11
0
 def getMatchLine(self, match, teamId, leagueResLink):
     html = """
     <tr>
         <td class="date">{date}</td>
         <td class="time">{time}</td>
         <td class="court">{court}</td>
         <td class="opponent"><a href="{oppfix.url}">{oppname}</a></td>
         <td class="homeAway">{homeaway}</td>
         <td class="result">{result}</td>
     </tr>
     """
     mDate = DateFormatter.formatDate(match.datetime, False, False)
     mTime = DateFormatter.formatTime(match.datetime)
     mCourt = match.court
     mOppFixLink = PageLink("teamFixtures", self,
                            {"team": match.opponentId}, True)
     mOppName = match.opponentName
     mHomeAway = "H" if match.home else "A"
     mOppId = match.opponentId
     mHomeId = teamId if match.home else mOppId
     mAwayId = mOppId if match.home else teamId
     if match.result:
         if match.margin:
             res = "{0} by {1}".format(match.result, match.margin)
         else:
             res = "{0}".format(match.result)
         mResult = "<a href=\"{leaguefix.url}#{homeid}{awayid}\">{result}</a>".format(
             leaguefix=leagueResLink,
             teamid=teamId,
             homeid=mHomeId,
             awayid=mAwayId,
             result=res)
     else:
         mResult = ""
     answer = html.format(date=mDate,
                          time=mTime,
                          court=mCourt,
                          oppfix=mOppFixLink,
                          oppname=mOppName,
                          homeaway=mHomeAway,
                          result=mResult)
     return answer
예제 #12
0
파일: tables.py 프로젝트: hicksjduk/sehicl
 def getStatusMessage(self, table):
     html = """
     <p class="statusMessage">{status}.</p>
     """
     if table.lastCompleteMatchDate is None:
         answer = ""
     elif self.allParams.get("archive", "no") == "yes":
         answer = ""
     else:
         if table.complete:
             message = "Final table"
         else:
             dateStr = DateFormatter.formatDate(table.lastCompleteMatchDate, True, True)
             if table.toCome == 0:
                 template = "Includes all games up to and including {0}"
                 message = template.format(dateStr)
             else:
                 template = "Date of last game included: {0} ({1} {2} to come)"
                 message = template.format(dateStr, table.toCome, TextUtils.getGrammaticalNumber(table.toCome, "result", "results"))
         answer = html.format(status=message)
     return answer
예제 #13
0
파일: results.py 프로젝트: hicksjduk/sehicl
 def getHeading(self, report):
     if report.date is None:
         answer = "Results"
     else:
         answer = "Results: {0}".format(DateFormatter.formatDate(report.date, True, True))
     return answer
예제 #14
0
 def testFormatDateDatePassedMonthShortYearLong(self):
     date = datetime.date(2013, 12, 22)
     result = DateFormatter.formatDate(date, False, True)
     expectedResult = "22nd Dec 2013"
     self.assertEqual(expectedResult, result)
예제 #15
0
 def testFormatDateDatePassedMonthLongYearShort(self):
     date = datetime.date(2013, 4, 12)
     result = DateFormatter.formatDate(date, True, False)
     expectedResult = "12th April 13"
     self.assertEqual(expectedResult, result)
예제 #16
0
 def testFormatDateDatePassedMonthLongYearLong(self):
     date = datetime.date(2013, 7, 1)
     result = DateFormatter.formatDate(date, True, True)
     expectedResult = "1st July 2013"
     self.assertEqual(expectedResult, result)
예제 #17
0
 def testFormatDateDateTimePassed(self):
     date = datetime.datetime(2013, 7, 31, 14, 13)
     result = DateFormatter.formatDate(date, True, True)
     expectedResult = "31st July 2013"
     self.assertEqual(expectedResult, result)
예제 #18
0
 def testFormatDateYearOmitted(self):
     date = datetime.datetime(2013, 7, 31, 14, 13)
     result = DateFormatter.formatDate(date, False, None)
     expectedResult = "31st Jul"
     self.assertEqual(expectedResult, result)
예제 #19
0
 def testFormatDateDatePassedMonthShortYearShort(self):
     date = datetime.date(2013, 1, 3)
     result = DateFormatter.formatDate(date, False, False)
     expectedResult = "3rd Jan 13"
     self.assertEqual(expectedResult, result)