1
0
Fork 0

plugin talks: ordinamento stanze

This commit is contained in:
boyska 2019-05-10 00:13:21 +02:00
parent a359b518ed
commit 815dc2275f
2 changed files with 28 additions and 8 deletions

View file

@ -100,6 +100,10 @@ def get_global_data():
data["startdate"] = datetime.datetime.now()
if "rooms" not in data:
data["rooms"] = {}
if "names" not in data["rooms"]:
data["rooms"]["names"] = {}
if "order" not in data["rooms"]:
data["rooms"]["order"] = []
return data
@ -169,8 +173,8 @@ def get_talk_data(talkname):
if "room" not in data:
logging.warn("Talk <{}> has no `room` field".format(talkname))
else:
if data["room"] in get_global_data()["rooms"]:
data["room"] = get_global_data()["rooms"][data["room"]]
if data["room"] in get_global_data()["rooms"]["names"]:
data["room"] = get_global_data()["rooms"]["names"][data["room"]]
if "time" not in data or "day" not in data:
logging.warn("Talk <{}> has no `time` or `day`".format(talkname))
if "time" in data:
@ -371,8 +375,22 @@ class TalkGridDirective(Directive):
rooms.add(r)
else:
rooms.add(t["room"])
# TODO: ordina in base a qualcosa nel meta.yaml globale
rooms = list(sorted(rooms))
def _room_sort_key(r):
order = get_global_data()["rooms"]["order"]
base = None
for k, v in get_global_data()["rooms"]["names"].items():
if v == r:
base = k
break
else:
if type(r) is str:
return ord(r[0])
# int?
return r
return order.index(base)
rooms = list(sorted(rooms, key=_room_sort_key))
# room=* is not a real room.
# Remove it unless that day only has special rooms

View file

@ -1,6 +1,8 @@
startdate: 2019-05-30
rooms:
A: Bistrot
B: Sala Biliardo (grande)
C: Hangar
D: Sala concerti
names:
A: Bistrot
B: Sala Biliardo (grande)
C: Hangar
D: Sala concerti
order: [A,B,C,D]