summaryrefslogtreecommitdiff
path: root/Mailman/Utils.py
diff options
context:
space:
mode:
authorbwarsaw1998-07-06 15:44:03 +0000
committerbwarsaw1998-07-06 15:44:03 +0000
commitea41e10356631b41969fe1c307fe2c303188f1ef (patch)
treee9cefa3890369185c0cafde244b5035d21b5a8f3 /Mailman/Utils.py
parent3868d6b41a3faeb649e12e77a53829c2ad87729b (diff)
downloadmailman-ea41e10356631b41969fe1c307fe2c303188f1ef.tar.gz
mailman-ea41e10356631b41969fe1c307fe2c303188f1ef.tar.zst
mailman-ea41e10356631b41969fe1c307fe2c303188f1ef.zip
Moved wrapping/filling to maketext() template generator.
SendTextToUser() no longer has a raw argument and no longer calls wrap() in any way. maketext() has a raw argument, default to zero, which if true skips the call to wrap() on the interpolated text.
Diffstat (limited to 'Mailman/Utils.py')
-rw-r--r--Mailman/Utils.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/Mailman/Utils.py b/Mailman/Utils.py
index 31950246a..6a6315b60 100644
--- a/Mailman/Utils.py
+++ b/Mailman/Utils.py
@@ -142,13 +142,11 @@ def wrap(text, column=70):
return wrapped
-def SendTextToUser(subject, text, recipient, sender, add_headers=[], raw=0):
+def SendTextToUser(subject, text, recipient, sender, add_headers=[]):
import Message
msg = Message.OutgoingMessage()
msg.SetSender(sender)
msg.SetHeader('Subject', subject, 1)
- if not raw:
- text = wrap(text)
msg.SetBody(QuotePeriods(text))
DeliverToUser(msg, recipient, add_headers=add_headers)
@@ -398,11 +396,17 @@ def chunkify(members, chunksize=mm_cfg.ADMIN_MEMBER_CHUNKSIZE):
return res
-def maketext(templatefile, dict):
- # Read a template file, do string substituion based on the dictionary and
- # return the results
+def maketext(templatefile, dict, raw=0):
+ """Make some text from a template file.
+
+ Reads the `templatefile', relative to mm_cfg.TEMPLATE_DIR, does string
+ substitution by interpolating in the `dict', and if `raw' is false,
+ wraps/fills the resulting text by calling wrap().
+ """
file = os.path.join(mm_cfg.TEMPLATE_DIR, templatefile)
fp = open(file)
template = fp.read()
fp.close()
- return template % dict
+ if raw:
+ return template % dict
+ return wrap(template % dict)