25 lines
629 B
Python
25 lines
629 B
Python
from gallery.sketch.weather.model import WindDirection, WindDirectionDeg
|
||
|
||
|
||
class ParseError(Exception):
|
||
pass
|
||
|
||
|
||
WIND_DIRECTION_MAP: dict[str, WindDirection] = {
|
||
"—": WindDirection.CALM,
|
||
"": WindDirection.CALM,
|
||
"штиль": WindDirection.CALM,
|
||
"с": WindDirection.N,
|
||
"св": WindDirection.NE,
|
||
"в": WindDirection.E,
|
||
"юв": WindDirection.SE,
|
||
"ю": WindDirection.S,
|
||
"юз": WindDirection.SW,
|
||
"з": WindDirection.W,
|
||
"сз": WindDirection.NW,
|
||
}
|
||
|
||
|
||
def parse_wind_direction(value: str) -> WindDirectionDeg:
|
||
return WindDirectionDeg.from_direction(WIND_DIRECTION_MAP[value.lower()])
|