l.s.m.helpers : module documentation

Part of lp.services.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 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_error_message Returns the error message that's in the given filename.
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.
Function save_mail_to_librarian Save the message to the librarian.
Function get_email_template Returns the email template with the given file name.
Function get_contact_email_addresses Return a set of email addresses to contact this Person.
def get_main_body(signed_msg):
Returns the first text part of the email.
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_error_message(filename, error_templates=None, **interpolation_items):
Returns the error message that's in the given filename.

If the error message requires some parameters, those are given in interpolation_items.

The files are searched for in lib/lp/services/mail/errortemplates.

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):
Make sure that the current principal is not weakly authenticated.

NB: While handling an email, the authentication state is stored partly in properties of the message object, and partly in the current security principal. As a consequence this function will only work correctly if the message has just been passed through authenticateEmail -- you can't give it an arbitrary message object.

def ensure_sane_signature_timestamp(timestamp, context, error_template='old-signature.txt'):
Ensure the signature was generated recently but not in the future.

If the timestamp is wrong, the message is rejected rather than just treated as untrusted, so that the user gets a chance to understand the problem. Therefore, this raises an error rather than returning a value.

ParameterscontextShort user-readable description of the place the problem occurred.
RaisesIncomingEmailErrorif the timestamp is stale or implausible, containing a message based on the context and template.
def save_mail_to_librarian(raw_mail, restricted=False):
Save the message to the librarian.

It can be referenced from errors, and also accessed by code that needs to get back the exact original form.

def get_email_template(filename, app=None):
Returns the email template with the given file name.

The templates are located in lib/lp/services/mail/emailtemplates or lib/lp/<app>/emailtemplates.

def get_contact_email_addresses(person):
Return a set of email addresses to contact this Person.

In general, it is better to use lp.registry.model.person.get_recipients instead.

API Documentation for Launchpad, generated by pydoctor at 2018-08-18 00:00:04.