-
Notifications
You must be signed in to change notification settings - Fork 0
/
conversions.py
74 lines (52 loc) · 2.23 KB
/
conversions.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
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
from decimal import Decimal, ROUND_HALF_UP
def symbol_for(number):
return weather_symbols[number] if number in weather_symbols else number
def bar_for(number):
return bars[max(0, min(8, number))]
def arrow_for(direction):
index = int((direction / Decimal('45')).quantize(Decimal('1.'), rounding=ROUND_HALF_UP)) % 8
return direction_arrows[index]
weather_symbols = {'1' : '☉',
'2' : '☉☁',
'3' : '☁☉',
'4' : '☁',
# Showers
'40': '☉☔', # Light
'5' : '☉☔',
'41': '☉☔', # Heavy
# Showers with thunderstorm
'24': '☉☔☈', # Light
'6' : '☉☔☈',
'25': '☉☔☈', # Heavy
# Sleet showers
'42': '☉☔❄', # Light
'7' : '☉☔❄',
'43': '☉☔❄', # Heavy
# Sleet showers with thunderstorm
'26': '☉☔❄☈', # Light
'20': '☉☔❄☈',
'27': '☉☔❄☈', # Heavy
# Snow showers█
'44': '☉❄', # Light
'8' : '☉❄',
'45': '☉❄', # Heavy
# Snow showers with thunderstorm
'28': '☉❄☈', # Light
'21': '☉❄☈',
'29': '☉❄☈', # Heavy
# Rain
'46': '☔', # Light
'9' : '☔',
'10': '☔', # Heavy ☂
# Rain with thunderstorm
# Sleet
# Sleet with thunderstorm
# Snow
'49': '❄', # Light
'13': '❄',
'50': '❄', # Heavy
# Snow with thunderstorm
# Fog
'15': '▒'}
bars = {0: ' ', 1: '▁', 2: '▂', 3: '▃', 4: '▄', 5: '▅', 6: '▆', 7: '▇', 8: '█'}
direction_arrows = {0: '↑', 1: '↗', 2: '→', 3: '↘', 4: '↓', 5: '↙', 6: '←',7: '↖' }