[PATCH 08/11] nmweb: use urllib.quote_plus() as plain quote_plus()

Daniel Kahn Gillmor dkg at fifthhorseman.net
Sun Feb 4 20:19:56 PST 2018


This will make it easier to import quote_plus from urllib.parse, which
is where it is in python3.
---
 contrib/notmuch-web/nmweb.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/contrib/notmuch-web/nmweb.py b/contrib/notmuch-web/nmweb.py
index 0217fce0..31351399 100755
--- a/contrib/notmuch-web/nmweb.py
+++ b/contrib/notmuch-web/nmweb.py
@@ -2,7 +2,7 @@
 
 from __future__ import absolute_import
 
-import urllib
+from urllib import quote_plus
 from datetime import datetime
 from mailbox import MaildirMessage
 import mimetypes
@@ -34,7 +34,7 @@ def urlencode_filter(s):
   if type(s) == 'Markup':
     s = s.unescape()
   s = s.encode('utf8')
-  s = urllib.quote_plus(s)
+  s = quote_plus(s)
   return Markup(s)
 env.filters['url'] = urlencode_filter
 
@@ -69,7 +69,7 @@ class search:
       redir = True
       terms += ' %s..%s' % (afters, befores)
     if redir:
-      raise web.seeother('/search/%s' % urllib.quote_plus(terms))
+      raise web.seeother('/search/%s' % quote_plus(terms))
     web.header('Content-type', 'text/html')
     web.header('Transfer-Encoding', 'chunked')
     db = Database()
@@ -107,7 +107,7 @@ def show_msgs(msgs):
     frm = msg.get_header('From')
     frm = mailto_addrs(frm)
     subj = msg.get_header('Subject')
-    lnk = urllib.quote_plus(msg.get_message_id())
+    lnk = quote_plus(msg.get_message_id())
     rs = show_msgs(msg.get_replies())
     r += '<li><font color=%s>%s—<a href="%s/show/%s">%s</a></font> %s</li>' % (
       red, frm, prefix, lnk, subj, rs)
-- 
2.15.1



More information about the notmuch mailing list