Previous topic

synfu.postfilter.PostFilter – Mail2News and back again

Next topic

synfu.imp.Imp – Periodic Imp - background tasks

This Page

synfu.fucore.FUCore – Common utility and helper methods

Platforms: Unix, MacOS, Windows

Module author: René Köcher <shirk@bitspin.org>

class synfu.fucore.FUCore(conf)

FUCore contains the generic code and utility methods shared by both synfu.postfilter.PostFilter and synfu.reactor.Reactor.

All of this methods are private and should only be called by subclasses.

_log(message, *args, **kwargs)

Log a message using syslog as well as sys.stdout.

Parameters:
  • message – The pre-formatted log message.
  • rec – Optional recursion level used to indent messages.
  • verbosity – Minimal verbosity required to display this message.
Returns:

None

_is_cancel(message)

Check if the passed message is a CANCEL message.

This will try to match FUCore.CANCEL_EXP against all Control: headers contained in message.

Parameters:message – A email.message object.
Returns:True or False
_find_list_tag(message, rec=0, plain=False)

Filter message for a valid list tag.

This method will scan the passed in messages headers looking for a hint to the used list-tag.

The following headers will be checked (in order):

  • X-SynFU-Tags (explicit List-Tags supplied by synfu-news2mail)
  • [X-]List-Post
  • [X-]List-Id
  • [X-]AF-Envelope-to

If any of these is found it will be converted into a regular expression which can be used to remove the List-Tag from arbitrary headers.

Parameters:
  • message – A email.message object.
  • rec – Optional recursion level used to indent messages.
  • plain – If True return the plain List-Tag (no regexp)
Returns:

Either a re.SRE_PATTERN or a string

_filter_headers(list_tag, headers, outlook_hacks=False, fix_dateline=False, rec=0)

Filter a list of headers according to the global settings.

This method will filter the passed in header list by matching a series of expressions and filters to it:

  • if list_tag is specified and matched in the Subject: header it will be removed
  • if outlook_hacks is enabled then outlook-style AW:/FWD:/... subjects will be converted to RFC compliant versions
  • if fix_dateline is enabled Date-headers with broken timezone (like those sent by Incredymail) will get their timezone fixed.
  • all tags matching FUCore.HEADER_IGN will be discarded with the exception of X-No-Archive.
Parameters:
  • list_tag – A re.SRE_PATTERN as returned by FUCore._find_list_tag().
  • headers – A list of (key, value) headers
  • outlook_hacks – If True convert AW:/FWD:/... subjects to RFC versions.
  • rec – Optional recursion level used to indent messages.
Returns:

The filtered header list.