[PATCH 00/17] nmbug-status: Python-3-compabitility and general refactoring

Tomi Ollila tomi.ollila at iki.fi
Mon Feb 3 13:10:23 PST 2014


On Mon, Feb 03 2014, "W. Trevor King" <wking at tremily.us> 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 <module>
    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 "<string>", line 1, in <module>
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 <module>
    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 <code> and <p> 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 at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch


More information about the notmuch mailing list