Exemplo n.º 1
0
    def process_data(self):
        """
            TODO: refactor this method.
        """
        participants = self.config['PARTICIPANTS']
        if len(participants) < 2:
            raise Exception('Not enough participants specified.')

        givers = []
        for person in participants:
            person = Person.construct_santa_recipient(person)
            givers.append(person)

        receivers = givers[:]
        pairs = self.create_pairs(givers, receivers)

        if self.send_action:
            self.send_mail(pairs)
        else:
            self.logger.info(self.TEMPLATE_MSG % ("\n".join([str(p) for p in pairs])))
            return
Exemplo n.º 2
0
    def process_data(self):
        """
            TODO: refactor this method.
        """
        participants = self.config['PARTICIPANTS']
        if len(participants) < 2:
            raise Exception('Not enough participants specified.')

        pairs = None
        if not self.resend:
            givers = []
            for person in participants:
                person = Person.construct_santa_recipient(person)
                if self.report:
                    print(person)
                givers.append(person)

            receivers = givers[:]
            pairs = self.create_pairs(givers, receivers)

            self.logger.info(self.TEMPLATE_MSG % ("\n".join([str(p) for p in pairs])))

        if self.send_action or self.resend:
            self.send_mail(pairs)