This file is indexed.

/usr/share/pyshared/weboob/capabilities/weather.py is in python-weboob-core 0.g-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# -*- coding: utf-8 -*-

# Copyright(C) 2010-2011 Romain Bignon
#
# This file is part of weboob.
#
# weboob is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# weboob is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.


from datetime import datetime

from .base import IBaseCap, CapBaseObject, Field, DateField, FloatField, \
                  StringField, UserError


__all__ = ['Forecast', 'Current', 'City', 'CityNotFound', 'Temperature', 'ICapWeather']


class Temperature(CapBaseObject):

    value =      FloatField('Temperature value')
    unit =       StringField('Input unit')

    def __init__(self, value, unit = u''):
        CapBaseObject.__init__(self, value)
        self.value = value
        if unit not in [u'C', u'F']:
            unit = u''
        self.unit = unit

    def asfahrenheit(self):
        if not self.unit:
            return u'%s' % int(round(self.value))
        elif self.unit == 'F':
            return u'%s°F' % int(round(self.value))
        else:
            return u'%s°F' % int(round((self.value * 9.0 / 5.0) + 32))

    def ascelsius(self):
        if not self.unit:
            return u'%s' % int(round(self.value))
        elif self.unit == 'C':
            return u'%s°C' % int(round(self.value))
        else:
            return u'%s°C' % int(round((self.value - 32.0) * 5.0 / 9.0))


class Forecast(CapBaseObject):
    """
    Weather forecast.
    """
    date =      Field('Date for the forecast', datetime, basestring)
    low =       Field('Low temperature', Temperature)
    high =      Field('High temperature', Temperature)
    text =      StringField('Comment on forecast')

    def __init__(self, date, low, high, text, unit):
        CapBaseObject.__init__(self, unicode(date))
        self.date = date
        self.low = Temperature(low, unit)
        self.high = Temperature(high, unit)
        self.text = text


class Current(CapBaseObject):
    """
    Current weather.
    """
    date =      DateField('Date of measure')
    text =      StringField('Comment about current weather')
    temp =      Field('Current temperature', Temperature)

    def __init__(self, date, temp, text, unit):
        CapBaseObject.__init__(self, unicode(date))
        self.date = date
        self.text = text
        self.temp = Temperature(temp, unit)


class City(CapBaseObject):
    """
    City where to find weather.
    """
    name =      StringField('Name of city')

    def __init__(self, id, name):
        CapBaseObject.__init__(self, id)
        self.name = name


class CityNotFound(UserError):
    """
    Raised when a city is not found.
    """


class ICapWeather(IBaseCap):
    """
    Capability for weather websites.
    """
    def iter_city_search(self, pattern):
        """
        Look for a city.

        :param pattern: pattern to search
        :type pattern: str
        :rtype: iter[:class:`City`]
        """
        raise NotImplementedError()

    def get_current(self, city_id):
        """
        Get current weather.

        :param city_id: ID of the city
        :rtype: :class:`Current`
        """
        raise NotImplementedError()

    def iter_forecast(self, city_id):
        """
        Iter forecasts of a city.

        :param city_id: ID of the city
        :rtype: iter[:class:`Forecast`]
        """
        raise NotImplementedError()