Skip to content

Commit fb29b72

Browse files
committed
Fix icon regex and add 'src' attribute for original icon URL
* Can be used to add missing icon mappings
1 parent 2aa57cc commit fb29b72

3 files changed

Lines changed: 12 additions & 9 deletions

File tree

wetteronline/WetterOnline/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ def _parse_tree(self, tree):
6262
'temp_min': float(day.xpath('.//div[5]/text()')[0].replace('°', '')),
6363
'sunhours': float(day.xpath('.//div[8]/text()')[0].replace('h', '')),
6464
'rain_probability': float(day.xpath('.//div[9]/text()')[0].replace('%', '')),
65-
'img': day.xpath('.//div[@class="weathersymbol"]/img/@src')[0],
65+
'src': day.xpath('.//div[@class="weathersymbol"]/img/@src')[0],
66+
'img': 'question',
6667
'title': day.xpath('.//div[@class="weathersymbol"]/img/@title')[0],
6768
}
6869

wetteronline/__init__.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,11 @@ def update(self, value=None, trigger=None):
7878

7979
# Map native icons
8080
for wd in wol_data['weather']:
81-
img = re.search(r"/([^/_]+)_+\.svg$", wd['img']).group(1)
82-
if img in icons:
83-
wd['img'] = icons[img]
84-
else:
85-
wd['img'] = 'question'
86-
81+
img = re.search(r"/([^/_]+)_*\.svg$", wd['src'])
82+
if img:
83+
img = img.group(1)
84+
if img in icons:
85+
wd['img'] = icons[img]
8786

8887
for keyword, item in self.items.items():
8988
try:

wetteronline/item.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
('_0', '== Heute =='),
44
('0__title', 'Wetterlage'),
55
('0__img', 'Icon'),
6+
('0__src', 'Icon (orig)'),
67
('0__temp_now', 'Temperatur aktuell (°C)'),
78
('0__temp_min', 'Temperatur min. (°C)'),
89
('0__temp_max', 'Temperatur max. (°C)'),
@@ -11,7 +12,8 @@
1112

1213
('_1', '== Morgen =='),
1314
('1__title', 'Wetterlage'),
14-
('1__img', 'Icon'),
15+
('1__img', 'Icon'),
16+
('1__src', 'Icon (orig)'),
1517
('1__temp_min', 'Temperatur min. (°C)'),
1618
('1__temp_max', 'Temperatur max. (°C)'),
1719
('1__sunhours', 'Sonnenstunden (h)'),
@@ -20,10 +22,11 @@
2022
('_2', '== Übermorgen =='),
2123
('2__title', 'Wetterlage'),
2224
('2__img', 'Icon'),
25+
('2__src', 'Icon (orig)'),
2326
('2__temp_min', 'Temperatur min. (°C)'),
2427
('2__temp_max', 'Temperatur max. (°C)'),
2528
('2__sunhours', 'Sonnenstunden (h)'),
2629
('2__rain_probability', 'Regenwahrscheinlichkeit (%)'),
2730
])
2831
form.guiSelect('wetteronline', label='Wert', named=select_data)
29-
}}
32+
}}

0 commit comments

Comments
 (0)