import collections
import datetime
import email.utils
-import locale
try: # Python 3
from urllib.parse import quote
except ImportError: # Python 2
import xml.sax.saxutils
-_ENCODING = locale.getpreferredencoding() or sys.getdefaultencoding()
+_ENCODING = 'UTF-8'
_PAGES = {}
super(_OrderedDict, self).__setitem__(key, value)
self._keys.append(key)
- def __values__(self):
+ def values(self):
for key in self._keys:
yield self[key]
byte_stream = sys.stdout.buffer
except AttributeError: # Python 2
byte_stream = sys.stdout
- stream = codecs.getwriter(encoding='UTF-8')(stream=byte_stream)
+ stream = codecs.getwriter(encoding=_ENCODING)(stream=byte_stream)
self._write_header(views=views, stream=stream)
for view in views:
self._write_view(database=database, view=view, stream=stream)
stream.write(' <tbody>\n')
for message_display_data in thread:
stream.write((
- ' <tr>\n'
+ ' <tr class="message-first">\n'
' <td>{date}</td>\n'
' <td><code>{message-id-term}</code></td>\n'
' </tr>\n'
- ' <tr>\n'
+ ' <tr class="message-last">\n'
' <td>{from}</td>\n'
' <td>{subject}</td>\n'
' </tr>\n'
header='''<!DOCTYPE html>
<html lang="en">
<head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <meta http-equiv="Content-Type" content="text/html; charset={encoding}" />
<title>Notmuch Patches</title>
<style media="screen" type="text/css">
table {{
border-spacing: 0;
}}
+ tr.message-first td {{
+ padding-top: {inter_message_padding};
+ }}
+ tr.message-last td {{
+ padding-bottom: {inter_message_padding};
+ }}
td {{
padding-left: {border_radius};
padding-right: {border_radius};
</p>
<h3>Views</h3>
'''.format(date=datetime.datetime.utcnow().date(),
+ encoding=_ENCODING,
+ inter_message_padding='0.25em',
border_radius='0.5em'),
footer='</body>\n</html>\n',
)