add weather modes

add exports
This commit is contained in:
zxsanny
2025-03-13 16:39:57 +02:00
parent 948d4f1425
commit 3113d59a3a
4 changed files with 70 additions and 68 deletions
+14 -1
View File
@@ -1,7 +1,14 @@
import json
from enum import Enum
from os.path import dirname, join
class WeatherMode(Enum):
Norm = 0
Wint = 20
Night = 40
class AnnotationClass:
def __init__(self, id, name, color):
self.id = id
@@ -13,7 +20,13 @@ class AnnotationClass:
classes_path = join(dirname(dirname(__file__)), 'classes.json')
with open(classes_path, 'r', encoding='utf-8') as f:
j = json.loads(f.read())
return {cl['Id']: AnnotationClass(id=cl['Id'], name=cl['Name'], color=cl['Color']) for cl in j}
annotations_dict = {}
for mode in WeatherMode:
for cl in j:
id = mode.value + cl['Id']
name = cl['Name'] if mode.value == 0 else f'{cl['Name']}({mode.name})'
annotations_dict[id] = AnnotationClass(id, name, cl['Color'])
return annotations_dict
@property
def color_tuple(self):