Skip to content

Commit

Permalink
Add 'src' attribute for original icon URL
Browse files Browse the repository at this point in the history
* Can be used to add missing icon mappings
  • Loading branch information
trollvottel committed Dec 4, 2020
1 parent 2aa57cc commit 94e5685
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
3 changes: 2 additions & 1 deletion wetteronline/WetterOnline/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ def _parse_tree(self, tree):
'temp_min': float(day.xpath('.//div[5]/text()')[0].replace('°', '')),
'sunhours': float(day.xpath('.//div[8]/text()')[0].replace('h', '')),
'rain_probability': float(day.xpath('.//div[9]/text()')[0].replace('%', '')),
'img': day.xpath('.//div[@class="weathersymbol"]/img/@src')[0],
'src': day.xpath('.//div[@class="weathersymbol"]/img/@src')[0],
'img': 'question',
'title': day.xpath('.//div[@class="weathersymbol"]/img/@title')[0],
}

Expand Down
11 changes: 5 additions & 6 deletions wetteronline/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,11 @@ def update(self, value=None, trigger=None):

# Map native icons
for wd in wol_data['weather']:
img = re.search(r"/([^/_]+)_+\.svg$", wd['img']).group(1)
if img in icons:
wd['img'] = icons[img]
else:
wd['img'] = 'question'

img = re.search(r"/([^/_]+)_*\.svg$", wd['src'])
if img:
img = img.group(1)
if img in icons:
wd['img'] = icons[img]

for keyword, item in self.items.items():
try:
Expand Down
7 changes: 5 additions & 2 deletions wetteronline/item.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
('_0', '== Heute =='),
('0__title', 'Wetterlage'),
('0__img', 'Icon'),
('0__src', 'Icon (orig)'),
('0__temp_now', 'Temperatur aktuell (°C)'),
('0__temp_min', 'Temperatur min. (°C)'),
('0__temp_max', 'Temperatur max. (°C)'),
Expand All @@ -11,7 +12,8 @@

('_1', '== Morgen =='),
('1__title', 'Wetterlage'),
('1__img', 'Icon'),
('1__img', 'Icon'),
('1__src', 'Icon (orig)'),
('1__temp_min', 'Temperatur min. (°C)'),
('1__temp_max', 'Temperatur max. (°C)'),
('1__sunhours', 'Sonnenstunden (h)'),
Expand All @@ -20,10 +22,11 @@
('_2', '== Übermorgen =='),
('2__title', 'Wetterlage'),
('2__img', 'Icon'),
('2__src', 'Icon (orig)'),
('2__temp_min', 'Temperatur min. (°C)'),
('2__temp_max', 'Temperatur max. (°C)'),
('2__sunhours', 'Sonnenstunden (h)'),
('2__rain_probability', 'Regenwahrscheinlichkeit (%)'),
])
form.guiSelect('wetteronline', label='Wert', named=select_data)
}}
}}

0 comments on commit 94e5685

Please sign in to comment.