Merge pull request #3394 from jaborsh/main
Fixing Replace Legacy Time of Day Markup
This commit is contained in:
commit
014696b80a
1 changed files with 9 additions and 9 deletions
|
|
@ -47,6 +47,7 @@ from collections import deque
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db.models import Q
|
from django.db.models import Q
|
||||||
|
|
||||||
from evennia import (
|
from evennia import (
|
||||||
CmdSet,
|
CmdSet,
|
||||||
DefaultRoom,
|
DefaultRoom,
|
||||||
|
|
@ -432,16 +433,16 @@ class ExtendedRoom(DefaultRoom):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
desc = desc or ""
|
desc = desc or ""
|
||||||
time_of_day = self.get_time_of_day()
|
current_time_of_day = self.get_time_of_day()
|
||||||
|
|
||||||
# regexes for in-desc replacements (gets cached)
|
# regexes for in-desc replacements (gets cached)
|
||||||
if not hasattr(self, "legacy_timeofday_regex_map"):
|
if not hasattr(self, "legacy_timeofday_regex_map"):
|
||||||
timeslots = deque()
|
timeslots = deque()
|
||||||
for time_of_day in self.times_of_day:
|
for tod in self.times_of_day:
|
||||||
timeslots.append(
|
timeslots.append(
|
||||||
(
|
(
|
||||||
time_of_day,
|
tod,
|
||||||
re.compile(rf"<{time_of_day}>(.*?)</{time_of_day}>", re.IGNORECASE),
|
re.compile(rf"<{tod}>(.*?)</{tod}>", re.IGNORECASE),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -453,11 +454,10 @@ class ExtendedRoom(DefaultRoom):
|
||||||
timeslots.rotate(-1)
|
timeslots.rotate(-1)
|
||||||
|
|
||||||
# do the replacement
|
# do the replacement
|
||||||
regextuple = self.legacy_timeofday_regex_map[time_of_day]
|
regextuple = self.legacy_timeofday_regex_map[current_time_of_day]
|
||||||
desc = regextuple[0].sub(r"\1", desc)
|
for regex in regextuple:
|
||||||
desc = regextuple[1].sub("", desc)
|
desc = regex.sub(r"\1" if regex == regextuple[0] else "", desc)
|
||||||
desc = regextuple[2].sub("", desc)
|
return desc
|
||||||
return regextuple[3].sub("", desc)
|
|
||||||
|
|
||||||
def get_display_desc(self, looker, **kwargs):
|
def get_display_desc(self, looker, **kwargs):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue