From: Tomi Ollila Date: Tue, 21 May 2013 14:15:03 +0000 (+0300) Subject: Re: [PATCH] devel: add dkg's printmimestructure script to notmuch devel scripts X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=2f31746d4747a33dc290269a08c9330040d360ba;p=notmuch-archives.git Re: [PATCH] devel: add dkg's printmimestructure script to notmuch devel scripts --- diff --git a/0f/79c7184702d333087cdea29f2f574d4678f7d3 b/0f/79c7184702d333087cdea29f2f574d4678f7d3 new file mode 100644 index 000000000..ee651dcbb --- /dev/null +++ b/0f/79c7184702d333087cdea29f2f574d4678f7d3 @@ -0,0 +1,148 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 3F88F431FC0 + for ; Tue, 21 May 2013 07:15:11 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] + autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id bIwPNoNox1pe for ; + Tue, 21 May 2013 07:15:07 -0700 (PDT) +Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) + by olra.theworths.org (Postfix) with ESMTP id A2A92431FB6 + for ; Tue, 21 May 2013 07:15:06 -0700 (PDT) +Received: from guru.guru-group.fi (localhost [IPv6:::1]) + by guru.guru-group.fi (Postfix) with ESMTP id 325D41002C3; + Tue, 21 May 2013 17:15:04 +0300 (EEST) +From: Tomi Ollila +To: david@tethera.net, notmuch@notmuchmail.org +Subject: Re: [PATCH] devel: add dkg's printmimestructure script to notmuch + devel scripts +In-Reply-To: <1369065559-30788-1-git-send-email-david@tethera.net> +References: <1369065559-30788-1-git-send-email-david@tethera.net> +User-Agent: Notmuch/0.15.2+99~g7e455bc (http://notmuchmail.org) Emacs/24.3.1 + (x86_64-unknown-linux-gnu) +X-Face: HhBM'cA~ +MIME-Version: 1.0 +Content-Type: text/plain; charset=utf-8 +Content-Transfer-Encoding: quoted-printable +Cc: David Bremner +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Tue, 21 May 2013 14:15:11 -0000 + +On Mon, May 20 2013, david@tethera.net wrote: + +> From: David Bremner +> +> I find this script pretty useful when figuring out who to blame for +> MIME rendering problems. It currently isn't very widely known, so it +> seems worth distributing with notmuch. +> --- + +Good idea! +1 + +Tomi + +> +> I did a small amount whitespace cleanup compared to version in dkg's git = +repo. +> +> devel/printmimestructure | 54 ++++++++++++++++++++++++++++++++++++++++++= +++++++ +> 1 file changed, 54 insertions(+) +> create mode 100755 devel/printmimestructure +> +> diff --git a/devel/printmimestructure b/devel/printmimestructure +> new file mode 100755 +> index 0000000..b8084a9 +> --- /dev/null +> +++ b/devel/printmimestructure +> @@ -0,0 +1,54 @@ +> +#!/usr/bin/env python +> +# -*- coding: utf-8 -*- +> + +> +# Author: Daniel Kahn Gillmor +> +# License: GPLv3+ +> + +> +# Updates: git://lair.fifthhorseman.net/~dkg/printmimestructure +> + +> +# This script reads a MIME message from stdin and produces a treelike +> +# representation on it stdout. +> + +> +# Example: +> +# +> +# 0 dkg@alice:~$ printmimestructure < 'Maildir/cur/1269025522.M338697P12= +023.monkey,S=3D6459,W=3D6963:2,Sa' +> +# =E2=94=94=E2=94=AC=E2=95=B4multipart/signed 6546 bytes +> +# =E2=94=9C=E2=94=80=E2=95=B4text/plain inline 895 bytes +> +# =E2=94=94=E2=94=80=E2=95=B4application/pgp-signature inline [signatur= +e.asc] 836 bytes +> +# 0 dkg@alice:~$ +> + +> + +> +# If you want to number the parts, i suggest piping the output through +> +# something like "cat -n" +> + +> +import email +> +import sys +> + +> +def test(z, prefix=3D''): +> + fname =3D '' if z.get_filename() is None else ' [' + z.get_filename(= +) + ']' +> + cset =3D '' if z.get_charset() is None else ' (' + z.get_charset() += + ')' +> + disp =3D z.get_params(None, header=3D'Content-Disposition') +> + if (disp is None): +> + disposition =3D '' +> + else: +> + disposition =3D '' +> + for d in disp: +> + if d[0] in [ 'attachment', 'inline' ]: +> + disposition =3D ' ' + d[0] +> + if (z.is_multipart()): +> + print prefix + '=E2=94=AC=E2=95=B4' + z.get_content_type() + cse= +t + disposition + fname, z.as_string().__len__().__str__() + ' bytes' +> + if prefix.endswith('=E2=94=94'): +> + prefix =3D prefix.rpartition('=E2=94=94')[0] + ' ' +> + if prefix.endswith('=E2=94=9C'): +> + prefix =3D prefix.rpartition('=E2=94=9C')[0] + '=E2=94=82' +> + parts =3D z.get_payload() +> + i =3D 0 +> + while (i < parts.__len__()-1): +> + test(parts[i], prefix + '=E2=94=9C') +> + i +=3D 1 +> + test(parts[i], prefix + '=E2=94=94') +> + # FIXME: show epilogue? +> + else: +> + print prefix + '=E2=94=80=E2=95=B4'+ z.get_content_type() + cset= + + disposition + fname, z.get_payload().__len__().__str__(), 'bytes' +> + +> +test(email.message_from_file(sys.stdin), '=E2=94=94') +> --=20 +> 1.8.2.rc2 +> +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch