Merge ~cjwatson/launchpad:remove-mimeparse into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 18712daf8b5415792987f34c50a5a65c176c3783
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:remove-mimeparse
Merge into: launchpad:master
Diff against target: 43 lines (+4/-5)
2 files modified
lib/lp/bugs/externalbugtracker/trac.py (+4/-4)
setup.py (+0/-1)
Reviewer Review Type Date Requested Status
Jürgen Gmach Approve
Review via email: mp+411257@code.launchpad.net

Commit message

Replace use of python-mimeparse

Description of the change

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`.

To post a comment you must log in.
Revision history for this message
Jürgen Gmach (jugmac00) wrote :

LGTM - changes are tested via externalbugtracker-trac.txt

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/bugs/externalbugtracker/trac.py b/lib/lp/bugs/externalbugtracker/trac.py
2index 9f8f4f6..9a2e0a3 100644
3--- a/lib/lp/bugs/externalbugtracker/trac.py
4+++ b/lib/lp/bugs/externalbugtracker/trac.py
5@@ -5,12 +5,12 @@
6
7 __all__ = ['Trac', 'TracLPPlugin']
8
9+import cgi
10 import csv
11 from datetime import datetime
12 from email.utils import parseaddr
13 import time
14
15-from mimeparse import parse_mime_type
16 import pytz
17 import requests
18 from requests.cookies import RequestsCookieJar
19@@ -129,9 +129,9 @@ class Trac(ExternalBugTracker):
20 response = self._getPage(
21 "%s/%s" %
22 (self.baseurl, self.ticket_url % ticket_id))
23- subtype = parse_mime_type(
24- response.headers.get('Content-Type', ''))[1]
25- return subtype == 'csv'
26+ ctype, _ = cgi.parse_header(
27+ response.headers.get('Content-Type', ''))
28+ return '/' in ctype and ctype.split('/')[1] == 'csv'
29 except BugTrackerConnectError:
30 return False
31 else:
32diff --git a/setup.py b/setup.py
33index 14763f8..44df4e7 100644
34--- a/setup.py
35+++ b/setup.py
36@@ -204,7 +204,6 @@ setup(
37 'python-debian',
38 'python-keystoneclient',
39 'python-memcached',
40- 'python-mimeparse',
41 'python-openid2',
42 'python-subunit',
43 'python-swiftclient',

Subscribers

People subscribed via source and target branches

to status/vote changes: