Пример #1
0
    def __parseGameInfo__(self, gameInfoTag):
        gameConditions = {}

        gameInfoText = gameInfoTag.firstChild.data

        temperature = pattern.capture("""<b>Weather<\/b>\:\s(\d\d+)\s""",
                                      gameInfoText)
        forecast = pattern.capture(
            """<b>Weather<\/b>\:\s\d\d+\sdegrees\, (.*?)\.""", gameInfoText)
        windMPH = pattern.capture("""<b>Wind<\/b>\:\s(\d+)\smph""",
                                  gameInfoText)
        windDirection = pattern.capture(
            """<b>Wind<\/b>\:\s\d+\smph\, (.*?)\.""", gameInfoText)
        gameLength = pattern.capture("""<b>T<\/b>\:\s(\d\:\d+)""",
                                     gameInfoText)
        attendence = pattern.capture("""<b>Att<\/b>\:\s(\d+\,\d+)""",
                                     gameInfoText)

        #<b>Weather</b>: 60 degrees, partly cloudy.<br/><b>Wind</b>: 6 mph, Out to RF.<br/>
        #<b>T</b>: 2:37.<br/><b>Att</b>: 34,404.<br/>
        if not gameLength: gameLength = '0:00'
        if not windMPH: windMPH = '0'

        gameConditions['temperature'] = temperature
        gameConditions['forecast'] = forecast
        gameConditions['windMPH'] = windMPH
        gameConditions['windDirection'] = windDirection
        gameConditions['gameLength'] = gameLength
        gameConditions['attendence'] = attendence.replace(",", "")

        self.game.setGameConditions(gameConditions)
        """Cabrera pitched to 5 batters in the 7th.<br/><br/>
Пример #2
0
    def __dateInFuture__(self, dayURL):
        #"hlb/year_2008/month_09/day_24/

        year = int(pattern.capture("year_(\d\d\d\d)", dayURL))
        month = int(pattern.capture("month_(\d\d)", dayURL))
        day = int(pattern.capture("day_(\d\d)", dayURL))

        today = date.today()

        yearNow = today.year
        monthNow = today.month
        dayNow = today.day

        yearGreaterThanCurrentYear = (year > yearNow)
        yearEqualToCurrentYearButMonthGreaterThanCurrentMonth = (
            year == yearNow and month > monthNow)
        yearEqualAndMonthEqualButDayGreaterThanCurrentDay = (year == yearNow
                                                             and month
                                                             == monthNow
                                                             and day > dayNow)

        return yearGreaterThanCurrentYear or yearEqualToCurrentYearButMonthGreaterThanCurrentMonth \
            or yearEqualAndMonthEqualButDayGreaterThanCurrentDay