From: Tomi Ollila Date: Mon, 3 Feb 2014 21:10:23 +0000 (+0200) Subject: Re: [PATCH 00/17] nmbug-status: Python-3-compabitility and general refactoring X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=e089990f1940616981c5cd939d8441fa56ad3108;p=notmuch-archives.git Re: [PATCH 00/17] nmbug-status: Python-3-compabitility and general refactoring --- diff --git a/4d/1610adf8532b6faa7aff965896e404b5675d89 b/4d/1610adf8532b6faa7aff965896e404b5675d89 new file mode 100644 index 000000000..dca1ce363 --- /dev/null +++ b/4d/1610adf8532b6faa7aff965896e404b5675d89 @@ -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 1621B431FBC + for ; Mon, 3 Feb 2014 13:10:37 -0800 (PST) +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 I+BqKRVaaZhb for ; + Mon, 3 Feb 2014 13:10:29 -0800 (PST) +Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) + by olra.theworths.org (Postfix) with ESMTP id 7C2B2431FAF + for ; Mon, 3 Feb 2014 13:10:29 -0800 (PST) +Received: from guru.guru-group.fi (localhost [IPv6:::1]) + by guru.guru-group.fi (Postfix) with ESMTP id 573E4100033; + Mon, 3 Feb 2014 23:10:23 +0200 (EET) +From: Tomi Ollila +To: "W. Trevor King" , notmuch@notmuchmail.org +Subject: Re: [PATCH 00/17] nmbug-status: Python-3-compabitility and general + refactoring +In-Reply-To: +References: +User-Agent: Notmuch/0.17+55~g4397960 (http://notmuchmail.org) Emacs/24.3.1 + (x86_64-unknown-linux-gnu) +X-Face: HhBM'cA~ +MIME-Version: 1.0 +Content-Type: text/plain +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: Mon, 03 Feb 2014 21:10:37 -0000 + +On Mon, Feb 03 2014, "W. Trevor King" wrote: + +> I noticed that nmbug-status was written in Python :), but not +> compatible with Python 3 :(. I started cleaning up a few print +> statements, but this quickly turned into a more general refactoring. +> Let me know if this is too much to bite off at once. I tried to keep +> each patch fairly contained, but the Page / HtmlPage addition is still +> pretty big. Despite increasing the size of this module by almost 50%, +> I think my final version is more readable. However, it's always +> easier to read your own code, so feel free to tell me that this is a +> step in the completely wrong direction ;). +> +> Also anyone with asthetic sensibilities is free to pick nicer colors +> in the final patch. I'm too partial to the EFF permutation symmetry +> to be able to pick other colors myself ;). + +Nice series. One problem with python 2.6 though: + +Traceback (most recent call last): + File "devel/nmbug/nmbug-status", line 300, in + page.write(database=db, views=config['views']) + File "devel/nmbug/nmbug-status", line 76, in write + self._write_view(database=database, view=view, stream=stream) + File "devel/nmbug/nmbug-status", line 93, in _write_view + threads = self._get_threads(messages=q.search_messages()) + File "devel/nmbug/nmbug-status", line 107, in _get_threads + running_data=thread.running_data, message=message) + File "devel/nmbug/nmbug-status", line 207, in _message_display_data + *args, **kwargs) + File "devel/nmbug/nmbug-status", line 132, in _message_display_data + data['message-id-term'] = 'id:"{}"'.format(value) +ValueError: zero length field name in format + +Using python 2.6.6 + +$ python -c 'print "{}".format("foo")' +Traceback (most recent call last): + File "", line 1, in +ValueError: zero length field name in format +zsh: exit 1 python -c '"{}".format("foo")' + +python -c 'print "{0}".format("foo")' +foo + +With python 2.7.x python -c 'print "{}".format("foo")' works OK. + +Argh, when I changed that one, next: + +Traceback (most recent call last): + File "devel/nmbug/nmbug-status", line 300, in + page.write(database=db, views=config['views']) + File "devel/nmbug/nmbug-status", line 76, in write + self._write_view(database=database, view=view, stream=stream) + File "devel/nmbug/nmbug-status", line 95, in _write_view + self._write_threads(threads=threads, stream=stream) + File "devel/nmbug/nmbug-status", line 197, in _write_threads + ).format(**message_display_data)) + File "/usr/lib64/python2.6/codecs.py", line 351, in write + data, consumed = self.encode(object, self.errors) +UnicodeEncodeError: 'ascii' codec can't encode character u'\u017b' in + position 176: ordinal not in range(128) + +This one is harder... + +Tomi + + +> +> W. Trevor King (17): +> nmbug-status: Convert to Python-3-compatible print functions +> nmbug-status: Use email.utils instead of rfc822 +> nmbug-status: Decode Popen output using the user's locale +> nmbug-status: Factor config-loading out into read_config +> nmbug-status: Add metavars for --config and --get-query +> nmbug-status: Consolidate functions and main code +> nmbug-status: Don't require write access +> nmbug-status: Consolidate HTML header printing +> nmbug-status: Add a Python-3-compatible urllib.parse.quote import +> nmbug-status: Add Page and HtmlPage for modular rendering +> nmbug-status: Normalize table HTML indentation +> nmbug-status: Convert from XHTML 1.0 to HTML 5 +> nmbug-status: Encode output using the user's locale +> nmbug-status: Anchor with h3 ids instead of a names +> nmbug-status: Quote the title when using it as an id +> nmbug-status: Use and

markup where appropriate +> nmbug-status: Color threads in HTML output +> +> devel/nmbug/nmbug-status | 412 ++++++++++++++++++++++++++++++----------------- +> 1 file changed, 261 insertions(+), 151 deletions(-) +> +> -- +> 1.8.5.2.8.g0f6c0d1 +> +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch