Skip to content

Commit f7047de

Browse files
committed
Pull eventutil.get_group_events into eventutil.CalendarConf.get_events.
1 parent 41de2e1 commit f7047de

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

metabot/modules/events.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ def group(ctx, msg):
4545
"I'm not configured for this group! Ask a bot admin to go into the <b>moderator</b> "
4646
'module settings, group <b>%s</b>, and %s.', group_id, humanize.list(missing))
4747

48-
events, unused_alerts = eventutil.get_group_events(ctx.bot, calconf.calcodes, calconf.tzinfo,
49-
calconf.count, calconf.days)
48+
events, unused_alerts = calconf.get_events(ctx.bot)
5049
if not events:
5150
msg.add('No events in the next %s days!', calconf.days)
5251
else:

metabot/modules/reminders.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ def get_events(self, bot, eventtime, base, *, countdown=True):
6666
"""Get (and format) events for the given time."""
6767

6868
calconf = self.calconf
69-
events, alerts = eventutil.get_group_events(bot, calconf.calcodes, calconf.tzinfo,
70-
calconf.count, calconf.days, eventtime)
69+
events, alerts = calconf.get_events(bot, when=eventtime)
7170
if self.preambles:
7271
preamble = self.preambles[int(eventtime / (60 * 60 * 24)) % len(self.preambles)]
7372
else:

metabot/util/eventutil.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,13 @@ def __init__(self, groupconf):
2929
timezone = groupconf.get('timezone')
3030
self.tzinfo = timezone and pytz.timezone(timezone)
3131

32+
def get_events(self, bot, *, when=None):
33+
"""Build lists of events and weather alerts for the given time (or now)."""
3234

33-
def get_group_events(bot, calcodes, tzinfo, count, days, now=None): # pylint: disable=too-many-arguments,too-many-locals
35+
return _get_group_events(bot, self.calcodes, self.tzinfo, self.count, self.days, now=when)
36+
37+
38+
def _get_group_events(bot, calcodes, tzinfo, count, days, *, now=None): # pylint: disable=too-many-arguments,too-many-locals
3439
"""Build lists of events and weather alerts for the given calendar configuration."""
3540

3641
calendar_view = bot.multibot.multical.view(calcodes)
@@ -111,7 +116,7 @@ def format_geo(address, now):
111116
return ' \u2022 '.join(warnings)
112117

113118

114-
def humanize_range(start, end, tzinfo, base=None, countdown=True):
119+
def humanize_range(start, end, tzinfo, *, base=None, countdown=True):
115120
"""Return the range between start and end as human-friendly text."""
116121

117122
startdt = datetime.datetime.fromtimestamp(start, tzinfo)

0 commit comments

Comments
 (0)