Beispiel #1
0
    def author(self):
        """Construct an author header value for the article."""
        for d in [self.entry, self.group.config]:
            if 'author_detail' in d:
                ad = d['author_detail']
                if 'name' in ad and 'email' in ad:
                    return encode_email_header(ad['name'], ad['email'])
                elif 'name' in ad:
                    return encode_email_header(ad['name'])
                elif 'email' in ad:
                    return message.encode_header_word(ad['email'])
            elif 'author' in d:
                return encode_email_header(d['author'])

        if 'title' in self.group.config:
            return encode_email_header(self.group.config['title'])
                                
        return 'Unknown <unknown@unknown>'
Beispiel #2
0
def encode_email_header(name, email="unknown@unknown"):
    """Produce a properly encoded string with the given name and email
    address for use in an article header."""
    return '%s <%s>' % tuple(message.encode_header_word(decode_implicit_utf8(s))
                             for s in [name, email])