-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path__init__.py
38 lines (31 loc) · 1.15 KB
/
__init__.py
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
__all__ = [
"forecastgroup"
"location",
"pressure",
"remarks",
"runwayvisualrange",
"skycondition",
"temperature",
"time",
"visibility",
"weathergroup",
"wind"
]
class Component(object):
"""A superclass from which individual weather components should be derived"""
def __repr__(self):
return "%s(%r)" % (self.__class__.__name__, self.raw)
def __str__(self):
"""The component in its decoded form if available, or the raw form if not (for unparsed components)."""
return self.decoded or self.raw
def __eq__(self, other):
"""Components should be considered equal if they have the same type and their attributes are equal."""
return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
@property
def decoded(self) -> str:
"""The component as a decoded (plain English) string"""
raise NotImplementedError # This should be overridden by all components.
@property
def raw(self) -> str:
"""The component as a raw (or encoded) string"""
raise NotImplementedError # This should be overridden by all components.