diff options
author | W. Trevor King <wking@drexel.edu> | 2009-07-27 14:42:17 -0400 |
---|---|---|
committer | W. Trevor King <wking@drexel.edu> | 2009-07-27 14:42:17 -0400 |
commit | f5fdbda0472ad3b37e098561fcd52df6bf06199f (patch) | |
tree | e69e05e00c5df114d136c2cf940d05a0a660c27f /interfaces/email/interactive/be-handle-mail | |
parent | dc69839cbe8ae9b03200a9bb2bd395ffebd6675e (diff) | |
download | bugseverywhere-f5fdbda0472ad3b37e098561fcd52df6bf06199f.tar.gz |
Cleaned up be-handle-mail's subscriber notification emails (fewer attachments).
Previously, every node in the DiffTree created it's own attachment.
Now they're consolidated into a single attachment per bug. higher
level nodes are still one attachment per node.
Also:
* added send_pgp_mime.append_text()
* pulled guess_encoding() out of send_pgp_mime.encodedMIMEText().
* renamed data_string -> data_part in libbe.diff, since it needn't be a string.
Diffstat (limited to 'interfaces/email/interactive/be-handle-mail')
-rwxr-xr-x | interfaces/email/interactive/be-handle-mail | 54 |
1 files changed, 46 insertions, 8 deletions
diff --git a/interfaces/email/interactive/be-handle-mail b/interfaces/email/interactive/be-handle-mail index 47c108e..d491a74 100755 --- a/interfaces/email/interactive/be-handle-mail +++ b/interfaces/email/interactive/be-handle-mail @@ -53,8 +53,8 @@ import doctest import unittest from becommands import subscribe -import libbe.cmdutil, libbe.encoding, libbe.utility, libbe.bugdir -import libbe.diff +import libbe.cmdutil, libbe.encoding, libbe.utility, libbe.diff, \ + libbe.bugdir, libbe.bug, libbe.comment import send_pgp_mime THIS_SERVER = u"thor.physics.drexel.edu" @@ -272,15 +272,53 @@ class Command (object): return response_generator.plain() class DiffTree (libbe.diff.DiffTree): + """ + In order to avoid tons of tiny MIMEText attachments, bug-level + nodes set .add_child_text=True (in .join()), which is propogated + on to their descendents. Instead of creating their own + attachement, each of these descendents appends his data_part to + the end of the bug-level MIMEText attachment. + + For the example tree in the libbe.diff.Diff unittests: + bugdir + bugdir/settings + bugdir/bugs + bugdir/bugs/new + bugdir/bugs/new/c <- sets .add_child_text + bugdir/bugs/rem + bugdir/bugs/rem/b <- sets .add_child_text + bugdir/bugs/mod + bugdir/bugs/mod/a <- sets .add_child_text + bugdir/bugs/mod/a/settings + bugdir/bugs/mod/a/comments + bugdir/bugs/mod/a/comments/new + bugdir/bugs/mod/a/comments/new/acom + bugdir/bugs/mod/a/comments/rem + bugdir/bugs/mod/a/comments/mod + """ def report_string(self): return send_pgp_mime.flatten(self.report(), to_unicode=True) def make_root(self): return MIMEMultipart() - def join(self, root, part): - if part != None: - root.attach(send_pgp_mime.encodedMIMEText(part)) - def data_string(self, depth, indent=False): - return libbe.diff.DiffTree.data_string(self, depth, indent=indent) + def join(self, root, parent, data_part): + if hasattr(parent, "attach_child_text"): + self.attach_child_text = True + if data_part != None: + send_pgp_mime.append_text(parent.data_mime_part, u"\n\n%s" % (data_part)) + self.data_mime_part = parent.data_mime_part + else: + self.data_mime_part = None + if data_part != None: + self.data_mime_part = send_pgp_mime.encodedMIMEText(data_part) + if parent != None and parent.name in ["new", "rem", "mod"]: + self.attach_child_text = True + if data_part == None: # make blank data_mime_part for children's appends + self.data_mime_part = send_pgp_mime.encodedMIMEText("") + if self.data_mime_part != None: + self.data_mime_part["Content-Description"] = self.name + root.attach(self.data_mime_part) + def data_part(self, depth, indent=False): + return libbe.diff.DiffTree.data_part(self, depth, indent=indent) class Diff (libbe.diff.Diff): def bug_add_string(self, bug): @@ -717,7 +755,7 @@ def main(): if options.notify_since != None: if options.subscribers == True: - libbe.encoding.set_IO_stream_encodings(ENCODING) # _after_ reading message + libbe.encoding.set_IO_stream_encodings(ENCODING) open_logfile(options.logfile) if LOGFILE != None: LOGFILE.write(u"Checking for subscribers to notify since revision %s\n" |