mirror of
https://github.com/joBr99/nspanel-lovelace-ui.git
synced 2026-02-17 10:27:00 +01:00
Make neighbor card generation work in Python < 3.10 (#665)
Co-authored-by: Daniel Albert <esclear@users.noreply.github.com> Co-authored-by: Johannes <johannes+develop+github@braun-rheingau.de>
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
from itertools import pairwise
|
|
||||||
import secrets
|
import secrets
|
||||||
import string
|
import string
|
||||||
|
|
||||||
@@ -163,20 +162,18 @@ class LuiBackendConfig(object):
|
|||||||
# parse cards
|
# parse cards
|
||||||
for card in self.get("cards"):
|
for card in self.get("cards"):
|
||||||
self._config_cards.append(Card(card))
|
self._config_cards.append(Card(card))
|
||||||
|
|
||||||
# setup prev and next uuids
|
# setup prev and next uuids
|
||||||
top_level_cards = filter(lambda card: not card.hidden, self._config_cards)
|
top_level_cards = list(filter(lambda card: not card.hidden, self._config_cards))
|
||||||
first_card = None
|
card_ids = [card.id for card in top_level_cards]
|
||||||
last_card = None
|
|
||||||
for cur, next in pairwise(top_level_cards):
|
prev_ids = card_ids[-1:] + card_ids[:-1]
|
||||||
if first_card is None:
|
next_ids = card_ids[ 1:] + card_ids[: 1]
|
||||||
first_card = cur
|
|
||||||
last_card = next
|
if len(card_ids) > 1:
|
||||||
cur.uuid_next = next.uuid
|
for prev_id, card, next_id in zip(prev_ids, top_level_cards, next_ids):
|
||||||
next.uuid_prev = cur.uuid
|
(card.uuid_prev, card.uuid_next) = (prev_id, next_id)
|
||||||
# if there is only one top level card first and last card will be none
|
|
||||||
if first_card and last_card:
|
|
||||||
first_card.uuid_prev = last_card.uuid
|
|
||||||
last_card.uuid_next = first_card.uuid
|
|
||||||
# parse screensaver
|
# parse screensaver
|
||||||
self._config_screensaver = Card(self.get("screensaver"))
|
self._config_screensaver = Card(self.get("screensaver"))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user