Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / 61 / d4ce194b7e8f6f510e01c0a3261189338ef689
1 Return-Path: <bremner@tethera.net>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 183E9431FBC\r
6         for <notmuch@notmuchmail.org>; Mon, 20 May 2013 08:59:56 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -2.3\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id 5tq0XaJowOHB for <notmuch@notmuchmail.org>;\r
16         Mon, 20 May 2013 08:59:48 -0700 (PDT)\r
17 Received: from tempo.its.unb.ca (tempo.its.unb.ca [131.202.1.21])\r
18         (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
19         (No client certificate requested)\r
20         by olra.theworths.org (Postfix) with ESMTPS id 5B0DE431FB6\r
21         for <notmuch@notmuchmail.org>; Mon, 20 May 2013 08:59:48 -0700 (PDT)\r
22 Received: from tesseract.cs.unb.ca (tesseract.cs.unb.ca [131.202.240.238])\r
23         by tempo.its.unb.ca (8.13.8/8.13.8) with ESMTP id r4KFxdDv008958;\r
24         Mon, 20 May 2013 12:59:39 -0300\r
25 Received: from fctnnbsc30w-156034082078.dhcp-dynamic.fibreop.nb.bellaliant.net\r
26         ([156.34.82.78] helo=zancas.localnet)\r
27         by tesseract.cs.unb.ca with esmtpsa\r
28         (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.80)\r
29         (envelope-from <bremner@tethera.net>)\r
30         id 1UeSUs-0007Yr-FR; Mon, 20 May 2013 12:59:39 -0300\r
31 Received: from bremner by zancas.localnet with local (Exim 4.80)\r
32         (envelope-from <bremner@tethera.net>)\r
33         id 1UeSUk-00083W-Nt; Mon, 20 May 2013 12:59:30 -0300\r
34 From: david@tethera.net\r
35 To: notmuch@notmuchmail.org\r
36 Subject: [PATCH] devel: add dkg's printmimestructure script to notmuch devel\r
37         scripts\r
38 Date: Mon, 20 May 2013 12:59:19 -0300\r
39 Message-Id: <1369065559-30788-1-git-send-email-david@tethera.net>\r
40 X-Mailer: git-send-email 1.8.2.rc2\r
41 MIME-Version: 1.0\r
42 Content-Type: text/plain; charset=UTF-8\r
43 Content-Transfer-Encoding: 8bit\r
44 X-Spam_bar: -\r
45 Cc: David Bremner <bremner@debian.org>\r
46 X-BeenThere: notmuch@notmuchmail.org\r
47 X-Mailman-Version: 2.1.13\r
48 Precedence: list\r
49 List-Id: "Use and development of the notmuch mail system."\r
50         <notmuch.notmuchmail.org>\r
51 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
52         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
53 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
54 List-Post: <mailto:notmuch@notmuchmail.org>\r
55 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
56 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
57         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
58 X-List-Received-Date: Mon, 20 May 2013 15:59:56 -0000\r
59 \r
60 From: David Bremner <bremner@debian.org>\r
61 \r
62 I find this script pretty useful when figuring out who to blame for\r
63 MIME rendering problems.  It currently isn't very widely known, so it\r
64 seems worth distributing with notmuch.\r
65 ---\r
66 \r
67 I did a small amount whitespace cleanup compared to version in dkg's git repo.\r
68 \r
69  devel/printmimestructure | 54 ++++++++++++++++++++++++++++++++++++++++++++++++\r
70  1 file changed, 54 insertions(+)\r
71  create mode 100755 devel/printmimestructure\r
72 \r
73 diff --git a/devel/printmimestructure b/devel/printmimestructure\r
74 new file mode 100755\r
75 index 0000000..b8084a9\r
76 --- /dev/null\r
77 +++ b/devel/printmimestructure\r
78 @@ -0,0 +1,54 @@\r
79 +#!/usr/bin/env python\r
80 +# -*- coding: utf-8 -*-\r
81 +\r
82 +# Author: Daniel Kahn Gillmor <dkg@fifthhorseman.net>\r
83 +# License: GPLv3+\r
84 +\r
85 +# Updates: git://lair.fifthhorseman.net/~dkg/printmimestructure\r
86 +\r
87 +# This script reads a MIME message from stdin and produces a treelike\r
88 +# representation on it stdout.\r
89 +\r
90 +# Example:\r
91 +#\r
92 +# 0 dkg@alice:~$ printmimestructure < 'Maildir/cur/1269025522.M338697P12023.monkey,S=6459,W=6963:2,Sa'\r
93 +# └┬╴multipart/signed 6546 bytes\r
94 +#  ├─╴text/plain inline 895 bytes\r
95 +#  └─╴application/pgp-signature inline [signature.asc] 836 bytes\r
96 +# 0 dkg@alice:~$\r
97 +\r
98 +\r
99 +# If you want to number the parts, i suggest piping the output through\r
100 +# something like "cat -n"\r
101 +\r
102 +import email\r
103 +import sys\r
104 +\r
105 +def test(z, prefix=''):\r
106 +    fname = '' if z.get_filename() is None else ' [' + z.get_filename() + ']'\r
107 +    cset = '' if z.get_charset() is None else ' (' + z.get_charset() + ')'\r
108 +    disp = z.get_params(None, header='Content-Disposition')\r
109 +    if (disp is None):\r
110 +        disposition = ''\r
111 +    else:\r
112 +        disposition = ''\r
113 +        for d in disp:\r
114 +            if d[0] in [ 'attachment', 'inline' ]:\r
115 +                disposition = ' ' + d[0]\r
116 +    if (z.is_multipart()):\r
117 +        print prefix + '┬╴' + z.get_content_type() + cset + disposition + fname, z.as_string().__len__().__str__() + ' bytes'\r
118 +        if prefix.endswith('└'):\r
119 +            prefix = prefix.rpartition('└')[0] + ' '\r
120 +        if prefix.endswith('├'):\r
121 +            prefix = prefix.rpartition('├')[0] + '│'\r
122 +        parts = z.get_payload()\r
123 +        i = 0\r
124 +        while (i < parts.__len__()-1):\r
125 +            test(parts[i], prefix + '├')\r
126 +            i += 1\r
127 +        test(parts[i], prefix + '└')\r
128 +        # FIXME: show epilogue?\r
129 +    else:\r
130 +        print prefix + '─╴'+ z.get_content_type() + cset + disposition + fname, z.get_payload().__len__().__str__(), 'bytes'\r
131 +\r
132 +test(email.message_from_file(sys.stdin), '└')\r
133 -- \r
134 1.8.2.rc2\r
135 \r