Пример #1
0
 def set_settings(self, settings):
     """
     After setting the settings, initialize the counts of emails
     :param settings:
     :return:
     """
     JenniferNotificationPlugin.set_settings(self, settings)
     self.update_number_new_emails()
     self.number_emails_announced = self.number_new_emails.copy()
 def set_settings(self, settings):
     """
     After setting the settings, initialize the counts of emails
     :param settings:
     :return:
     """
     JenniferNotificationPlugin.set_settings(self, settings)
     self.update_number_new_emails()
     self.number_emails_announced = self.number_new_emails.copy()
Пример #3
0
    def __init__(self, brain, settings=None, profile=None):
        # Call parent
        JenniferNotificationPlugin.__init__(self, brain, profile, settings)

        # Dict for holding number of new emails
        self.number_new_emails = {}

        # For pluralizing
        self.pluralize_engine = inflect.engine().plural

        # `number_emails_announced` tracks how many new emails we've already notified about.
        #   We don't want to notify right away
        self.number_emails_announced = self.number_new_emails.copy()
    def __init__(self, brain, settings=None, profile=None):
        # Call parent
        JenniferNotificationPlugin.__init__(self, brain, profile, settings)

        # Dict for holding number of new emails
        self.number_new_emails = {}

        # For pluralizing
        self.pluralize_engine = inflect.engine().plural

        # `number_emails_announced` tracks how many new emails we've already notified about.
        #   We don't want to notify right away
        self.number_emails_announced = self.number_new_emails.copy()
Пример #5
0
    def _load_lessons(self):
        """
        Search the lessons/ package for lessons & store them in sorted order by priority
        :return:
        """
        pkgs = [
            n for _, n, _ in pkgutil.iter_modules(['lessons']) if n != 'base'
        ]
        for name in pkgs:
            exec(f'import lessons.{name}.plugin')

        responders = [
            cls(self).set_profile(self.database['profile'])
            for cls in JenniferResponsePlugin.__subclasses__()
            if self._is_lesson_allowed(cls)
        ]
        self.notifiers = [
            cls(self).set_profile(self.database['profile'])
            for cls in JenniferNotificationPlugin.__subclasses__()
            if self._is_lesson_allowed(cls)
        ]

        for r in (responders + self.notifiers):
            r.set_settings(self._get_settings_for_lesson(r))

        self.responders = sorted(responders, key=lambda l: l.PRIORITY)