Changeset View
Changeset View
Standalone View
Standalone View
wallace/module_optout.py
Show First 20 Lines • Show All 84 Lines • ▼ Show 20 Lines | def execute(*args, **kw): | ||||
_recipients = {} | _recipients = {} | ||||
for answer in answers: | for answer in answers: | ||||
_recipients[answer] = { | _recipients[answer] = { | ||||
"To": [], | "To": [], | ||||
"Cc": [] | "Cc": [] | ||||
} | } | ||||
for recipient_type in recipients.keys(): | for recipient_type in recipients: | ||||
for recipient in recipients[recipient_type]: | for recipient in recipients[recipient_type]: | ||||
log.debug( | log.debug( | ||||
_("Running opt-out consult from envelope sender '%s " + \ | _("Running opt-out consult from envelope sender '%s " + \ | ||||
"<%s>' to recipient %s <%s>") % ( | "<%s>' to recipient %s <%s>") % ( | ||||
envelope_sender[0][0], | envelope_sender[0][0], | ||||
envelope_sender[0][1], | envelope_sender[0][1], | ||||
recipient[0], | recipient[0], | ||||
recipient[1] | recipient[1] | ||||
Show All 29 Lines | for answer in answers: | ||||
new_filepath = os.path.join(mybasepath, answer, os.path.basename(filepath)) | new_filepath = os.path.join(mybasepath, answer, os.path.basename(filepath)) | ||||
# Write out a message file representing the new contents for the message | # Write out a message file representing the new contents for the message | ||||
# use formataddr(recipient) | # use formataddr(recipient) | ||||
_message = message_from_file(open(filepath, 'r')) | _message = message_from_file(open(filepath, 'r')) | ||||
use_this = False | use_this = False | ||||
for recipient_type in _recipients[answer].keys(): | for recipient_type in _recipients[answer]: | ||||
_message.__delitem__(recipient_type) | _message.__delitem__(recipient_type) | ||||
if not len(_recipients[answer][recipient_type]) == 0: | if not len(_recipients[answer][recipient_type]) == 0: | ||||
_message.__setitem__( | _message.__setitem__( | ||||
recipient_type, | recipient_type, | ||||
',\n '.join( | ',\n '.join( | ||||
[formataddr(x) for x in _recipients[answer][recipient_type]] | [formataddr(x) for x in _recipients[answer][recipient_type]] | ||||
) | ) | ||||
) | ) | ||||
▲ Show 20 Lines • Show All 45 Lines • Show Last 20 Lines |