c.l.m.helpers : module documentation

Part of canonical.launchpad.mail

No module docstring
Class IncomingEmailError Indicates that something went wrong processing the mail.
Function get_main_body Returns the first text part of the email.
Function get_bugtask_type Returns the specific IBugTask interface the bugtask provides.
Function guess_bugtask Guess which bug task the person intended to edit.
Function reformat_wiki_text Transform moin formatted raw text to readable text.
Function parse_commands Extract indented commands from email body.
Function get_person_or_team Get the Person from the vocabulary.
Function ensure_not_weakly_authenticated Make sure that the current principal is not weakly authenticated.
Function ensure_sane_signature_timestamp Ensure the signature was generated recently but not in the future.
def get_main_body(signed_msg):
Returns the first text part of the email.
def get_bugtask_type(bugtask):

Returns the specific IBugTask interface the bugtask provides.

>>> from canonical.launchpad.interfaces import (
...     IUpstreamBugTask, IDistroBugTask, IDistroSeriesBugTask)
>>> from zope.interface import classImplementsOnly
>>> class BugTask:
...     pass

When it does, the specific interface is returned:

>>> classImplementsOnly(BugTask, IUpstreamBugTask)
>>> get_bugtask_type(BugTask()) #doctest: +ELLIPSIS
<...IUpstreamBugTask>
>>> classImplementsOnly(BugTask, IDistroBugTask)
>>> get_bugtask_type(BugTask()) #doctest: +ELLIPSIS
<...IDistroBugTask>
>>> classImplementsOnly(BugTask, IDistroSeriesBugTask)
>>> get_bugtask_type(BugTask()) #doctest: +ELLIPSIS
<...IDistroSeriesBugTask>
Unknown Field: bugtask

has to provide a specific bugtask interface:

>>> get_bugtask_type(BugTask()) #doctest: +ELLIPSIS
Traceback (most recent call last):
...
AssertionError...
def guess_bugtask(bug, person):
Guess which bug task the person intended to edit.

Return None if no bug task could be guessed.

def reformat_wiki_text(text):
Transform moin formatted raw text to readable text.
def parse_commands(content, command_names):
Extract indented commands from email body.

All commands must be indented using either spaces or tabs. They must be listed in command_names -- if not, they are silently ignored.

The special command 'done' terminates processing. It takes no arguments. Any commands that follow it will be ignored. 'done' should not be listed in command_names.

While this syntax is the Launchpad standard, bug #29572 says it should be changed to only accept commands at the beginning and to not require indentation.

A list of (command, args) tuples is returned.

def get_person_or_team(person_name_or_email):
Get the Person from the vocabulary.
RaisesEmailProcessingError if person not found.
def ensure_not_weakly_authenticated(signed_msg, context, error_template='not-signed.txt', no_key_template='key-not-registered.txt'):
Make sure that the current principal is not weakly authenticated.
def ensure_sane_signature_timestamp(timestamp, context, error_template='old-signature.txt'):
Ensure the signature was generated recently but not in the future.
API Documentation for Launchpad, generated by pydoctor at 2010-09-27 00:00:11.