Beispiel #1
0
 def obj_low(self):
     # In the late afternoon (forecast "Tonight") only the Min temperature is shown
     low_text = CleanText('./a/dl/dd[1]/b')(self)
     if low_text:
         temp = CleanDecimal('./a/dl/dd[1]/b')(self)
         return Temperature(float(temp), 'C')
     else:
         temp = CleanDecimal('./a/dl/dd[1]/strong')(self)
         return Temperature(float(temp), 'C')
Beispiel #2
0
 def obj_low(self):
     temp = CleanDecimal(
         Regexp(CleanText('./dl/dd/span[@class="min-temp"]'),
                u'(\d*)\xb0\w Minimale.*'))(self)
     unit = Regexp(CleanText('./dl/dd/span[@class="min-temp"]'),
                   u'.*\xb0(\w) Minimale.*')(self)
     return Temperature(float(temp), unit)
Beispiel #3
0
 def obj_high(self):
     temp = CleanDecimal(
         Regexp(CleanText('./dl/dd/span[@class="max-temp"]'),
                u'(.*)\xb0\w Maximale.*'))(self)
     unit = Regexp(CleanText('./dl/dd/span[@class="max-temp"]'),
                   u'.*\xb0(\w) Maximale.*')(self)
     return Temperature(float(temp), unit)
Beispiel #4
0
 def obj_temp(self):
     path = u'//table[@class="observation-text"]//span[@class="parameter-name" and text() = "Lämpötila"]' + \
            u'/../span[@class="parameter-value"]'
     temp = CleanDecimal(Regexp(CleanText(path), r'^([^ \xa0]+)'),
                         replace_dots=True)(self)
     unit = Regexp(CleanText(path), r'\xb0(\w)')(self)
     return Temperature(float(temp), unit)
Beispiel #5
0
 def obj_high(self):
     temp = CleanText('.//span[@class="large-temp"]/text()')(self)
     # Eliminating the '°' at the end:
     temp = temp[:-1]
     unit = CleanText('//span[@class="local-temp"]/text()')(self)
     unit = unit[-1]
     return Temperature(float(temp), unit)
Beispiel #6
0
 def obj_temp(self):
     temp = CleanDecimal(
         '//*[@id="current-city-tab"]//span[@class="local-temp"]')(self)
     unit = Regexp(
         CleanText(
             '//*[@id="current-city-tab"]//span[@class="local-temp"]'),
         u'.*\xb0(\w)')(self)
     return Temperature(float(temp), unit)
Beispiel #7
0
 def obj_high(self):
     temp = Regexp(CleanText('./dl/dd/span[@class="max-temp"]'),
                   u'(.*)\xb0\w Maximale.*')(self)
     if temp != "-":  # Sometimes website does not return high
         temp = CleanDecimal(temp)(self)
         unit = Regexp(CleanText('./dl/dd/span[@class="max-temp"]'),
                       u'.*\xb0(\w) Maximale.*')(self)
         return Temperature(float(temp), unit)
     return NotAvailable
Beispiel #8
0
 def obj_temp(self):
     temp = CleanDecimal(
         '//ul[@class="prevision-horaire "]/li[@class=" active "]/ul/li[@class="day-summary-temperature"]'
     )(self)
     unit = Regexp(
         CleanText(
             '//ul[@class="prevision-horaire "]/li[@class=" active "]/ul/li[@class="day-summary-temperature"]'
         ), u'.*\xb0(\w)')(self)
     return Temperature(float(temp), unit)
Beispiel #9
0
 def obj_high(self):
     temp = CleanDecimal(
         Regexp(
             CleanText('./ul/li[@class="day-summary-temperature"]'),
             '.* / (.*)'))(self)
     unit = Regexp(
         CleanText('./ul/li[@class="day-summary-temperature"]'),
         u'.* / .*\xb0(\w).*')(self)
     return Temperature(float(temp), unit)
Beispiel #10
0
 def obj_temp(self):
     temp = CleanDecimal(
         '//div[@id="detail-day-01"]/table/tr[@class="in-between"]/td[1]'
     )(self)
     unit = Regexp(
         CleanText(
             '//div[@id="detail-day-01"]/table/tr[@class="in-between"]/td[1]'
         ), u'.*\xb0(\w)')(self)
     return Temperature(float(temp), unit)
Beispiel #11
0
 def obj_low(self):
     temp = Regexp(CleanText('./dl/dd/span[@class="min-temp"]'),
                   u'(\d*)\xb0\w Minimale.*')
     if temp != "-":  # Sometimes website does not return low
         temp = CleanDecimal(temp)(self)
         unit = Regexp(CleanText('./dl/dd/span[@class="min-temp"]'),
                       u'.*\xb0(\w) Minimale.*')(self)
         return Temperature(float(temp), unit)
     return NotAvailable
Beispiel #12
0
 def obj_low(self):
     temp = CleanText('.//span[@class="small-temp"]/text()')(self)
     # For some of the low temperature elements, the value ends with '°', for some others it ends with '°C' or '°F':
     if temp.endswith('C') or temp.endswith('F'):
         temp = temp[1:-2]
     else:
         temp = temp[1:-1]
     unit = CleanText('//span[@class="local-temp"]/text()')(self)
     unit = unit[-1]
     return Temperature(float(temp), unit)
Beispiel #13
0
 def obj_temp(self):
     temp = CleanDecimal(
         Regexp(
             CleanText(
                 '(//div[@class="group-days-summary"])[1]/div[1]/div/div/div[@class="day-summary-temperature"]'
             ), '(.*)\|.*'))(self)
     unit = Regexp(
         CleanText(
             '(//div[@class="group-days-summary"])[1]/div[1]/div/div/div[@class="day-summary-temperature"]'
         ), u'.*\xb0(\w) \|.*')(self)
     return Temperature(float(temp), unit)
Beispiel #14
0
            def obj_high(self):

                high_temp = CleanText('.//span[@class="large-temp"]')(self)
                if high_temp:
                    temp = CleanDecimal('.//span[@class="large-temp"]')(self)
                    unit = Regexp(
                        CleanText(
                            '//*[@id="current-city-tab"]//span[@class="local-temp"]'
                        ), u'.*\xb0(\w)')(self)
                    return Temperature(float(temp), unit)
                return NotAvailable
Beispiel #15
0
 def obj_low(self):
     temp = CleanDecimal(
         Regexp(
             CleanText(
                 './div/div/div[@class="day-summary-temperature"]'),
             '(.*)\|.*'))(self)
     unit = Regexp(
         CleanText(
             './div/div/div[@class="day-summary-temperature"]'),
         u'.*\xb0(\w) \|.*')(self)
     return Temperature(float(temp), unit)
Beispiel #16
0
 def get_current(self):
     obj = Current()
     obj.id = date.today()
     obj.date = date.fromtimestamp(self.doc['latestObservationTime'] / 1000)
     obj.temp = Temperature(max(self.doc['t2m'])[1], u'C')
     last_hour_precipitations = int(max(self.doc['Precipitation1h'])[1])
     nebulosity = int(max(self.doc['TotalCloudCover'])[1])
     wind_speed = int(max(self.doc['WindSpeedMS'])[1])
     wind_direction = self.WINDS[int(
         max(self.doc['WindDirection'])[1] / 22.5)]
     obj.text = u'1h precipitations %d mm, wind %d m/s (%s), nebulosity %d/8' % (
         last_hour_precipitations, wind_speed, wind_direction, nebulosity)
     return obj
Beispiel #17
0
        def obj_temp(self):
            #Retrieving the temperature:
            temp = CleanText(
                '//div[@id="details"]//span[@class="large-temp"]/text()')(self)
            #Eliminating the '°' at the end of the temperature value:
            temp = temp[:-1]
            temp = CleanDecimal(temp)(self)

            #Retrieving the temperature unit in Celsius or Fahrenheit:
            unit = CleanText('//ul[@class="stats"]/li[8]/strong/text()')(self)
            unit = unit[-1]

            return Temperature(float(temp), unit)
Beispiel #18
0
 def obj_high(self):
     return Temperature(max(self.temperatures()), u'C')
Beispiel #19
0
 def obj_low(self):
     return Temperature(min(self.temperatures()), u'C')
Beispiel #20
0
def temp(v):
    t = Temperature()
    t.unit = 'C'
    t.value = v
    return t
Beispiel #21
0
 def obj_high(self):
     temp = CleanDecimal(Dict('high'))(self)
     return Temperature(float(temp), Env('unit')(self))
Beispiel #22
0
 def obj_temp(self):
     temp = Dict('vt1observation/temperature')(self)
     return Temperature(float(temp), 'C')
Beispiel #23
0
        def obj_temp(self):

            temp = CleanDecimal('//*[@class="current temp-block"]/span[1]/b')(
                self)
            return Temperature(float(temp), 'C')
Beispiel #24
0
 def obj_high(self):
     low_text = CleanText('./a/dl/dd[1]/b')(self)
     if low_text:
         temp = CleanDecimal('./a/dl/dd[1]/strong')(self)
         return Temperature(float(temp), 'C')
Beispiel #25
0
 def obj_temp(self):
     temp = CleanDecimal(
         Dict('query/results/channel/item/condition/temp'))(self)
     unit = CleanText(
         Dict('query/results/channel/units/temperature'))(self)
     return Temperature(float(temp), unit)