From a760d5648abba527b96d1b305c62c2250018f6ff Mon Sep 17 00:00:00 2001 From: Miro Hrončok Date: Nov 19 2015 11:12:22 +0000 Subject: Port mailtoparse to Python 3 (#1282165) --- diff --git a/exo.spec b/exo.spec index 98dbce6..8fb8d57 100644 --- a/exo.spec +++ b/exo.spec @@ -6,7 +6,7 @@ Name: exo Version: 0.10.7 -Release: 1%{?dist} +Release: 2%{?dist} Summary: Application library for the Xfce desktop environment Group: System Environment/Libraries @@ -21,7 +21,7 @@ Source1: internet-mail-24.png Source2: internet-mail-48.png # replace mailto handler with python version # https://bugzilla.xfce.org/show_bug.cgi?id=9964 -Source3: http://skvidal.fedorapeople.org/misc/mailtoparse.py +Source3: mailtoparse.py Patch1: exo-0.7.2-remove-xfce-category.patch # Set default applications to the ones we use in Fedora Patch2: exo-0.10.2-default-apps.patch @@ -171,6 +171,9 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || : %endif %changelog +* Thu Nov 19 2015 Miro Hrončok - 0.10.7-2 +- Port mailtoparse to Python 3 (#1282165) + * Mon Sep 14 2015 Mukundan Ragavan - 0.10.7-1 - Updated to 0.10.7 - Removed upstreamed missing URI patch diff --git a/mailtoparse.py b/mailtoparse.py index e541b10..4b3b62c 100644 --- a/mailtoparse.py +++ b/mailtoparse.py @@ -1,6 +1,6 @@ -#!/usr/bin/python -tt +#!/usr/bin/python3 -tt # skvidal@fedoraproject.org -# (c) red hat, inc 2013 +# (c) red hat, inc 2013, 2015 # gpl whatever # this is a direct port of exo-compos-mail-1 from xfce # from perl to python @@ -16,34 +16,31 @@ # - would be nice to have an actual set of tests :) - import sys import posix import os -import urlparse -import urllib +import urllib.parse def parse_url(mailto): - urlparse.uses_query.append('mailto') - url = urlparse.urlparse(mailto) + url = urllib.parse.urlparse(mailto, 'mailto') res = {} to = [] query = None if url.query or '?' not in url.path: if url.path: - to.append(urlparse.unquote(url.path)) - + to.append(urllib.parse.unquote(url.path)) + else: (thisto, ques, query) = url.path.partition('?') if thisto.strip(): - to.append(urlparse.unquote(thisto)) + to.append(urllib.parse.unquote(thisto)) if not query: - query = url.query + query = url.query - q_dict = urlparse.parse_qs(query) + q_dict = urllib.parse.parse_qs(query) to.extend(q_dict.get('to', [])) res['to'] = to if 'to' in q_dict: @@ -53,9 +50,8 @@ def parse_url(mailto): return res - if len(sys.argv) < 3: - print >> sys.stderr, "Usage: %s