def get_active_messages(self, when=None, event_pattern=None, here=True):
"""
:param when: the time for which to check effectiveness of the messages, default = the present time
:param event_pattern: a regular expression to match the desired event codes. default = all.
:param here: True to retrieve local messages, False to retrieve those for other locales
"""
if when is None:
when = time.time()
if event_pattern is None:
event_pattern = re.compile(".*")
elif not hasattr(event_pattern, 'match'):
event_pattern = re.compile(event_pattern)
l = list(filter(lambda m: m.is_effective(self.latlon, self.county_fips, here, when) and event_pattern.match(
m.get_event_type()), self.__messages.values()))
l.sort(key=functools.cmp_to_key(self.sorter))
return l
评论列表
文章目录