launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #27658
[Merge] ~cjwatson/launchpad:remove-mimeparse into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:remove-mimeparse into launchpad:master.
Commit message:
Replace use of python-mimeparse
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/411257
It's somewhat excessive to pull in a whole dependency for what amounts to a trivial bit of string parsing on top of `cgi.parse_header`.
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:remove-mimeparse into launchpad:master.
diff --git a/lib/lp/bugs/externalbugtracker/trac.py b/lib/lp/bugs/externalbugtracker/trac.py
index 9f8f4f6..9a2e0a3 100644
--- a/lib/lp/bugs/externalbugtracker/trac.py
+++ b/lib/lp/bugs/externalbugtracker/trac.py
@@ -5,12 +5,12 @@
__all__ = ['Trac', 'TracLPPlugin']
+import cgi
import csv
from datetime import datetime
from email.utils import parseaddr
import time
-from mimeparse import parse_mime_type
import pytz
import requests
from requests.cookies import RequestsCookieJar
@@ -129,9 +129,9 @@ class Trac(ExternalBugTracker):
response = self._getPage(
"%s/%s" %
(self.baseurl, self.ticket_url % ticket_id))
- subtype = parse_mime_type(
- response.headers.get('Content-Type', ''))[1]
- return subtype == 'csv'
+ ctype, _ = cgi.parse_header(
+ response.headers.get('Content-Type', ''))
+ return '/' in ctype and ctype.split('/')[1] == 'csv'
except BugTrackerConnectError:
return False
else:
diff --git a/setup.py b/setup.py
index 14763f8..44df4e7 100644
--- a/setup.py
+++ b/setup.py
@@ -204,7 +204,6 @@ setup(
'python-debian',
'python-keystoneclient',
'python-memcached',
- 'python-mimeparse',
'python-openid2',
'python-subunit',
'python-swiftclient',