##// END OF EJS Templates
py3: use email.parser module to parse email messages...
Pulkit Goyal -
r35651:a981ab2a default
parent child Browse files
Show More
@@ -7,7 +7,7 b''
7 # GNU General Public License version 2 or any later version.
7 # GNU General Public License version 2 or any later version.
8 from __future__ import absolute_import
8 from __future__ import absolute_import
9
9
10 import email
10 import email.parser as emailparser
11 import os
11 import os
12 import shutil
12 import shutil
13 import stat
13 import stat
@@ -63,7 +63,7 b' class gnuarch_source(common.converter_so'
63 self.changes = {}
63 self.changes = {}
64 self.parents = {}
64 self.parents = {}
65 self.tags = {}
65 self.tags = {}
66 self.catlogparser = email.Parser.Parser()
66 self.catlogparser = emailparser.Parser()
67 self.encoding = encoding.encoding
67 self.encoding = encoding.encoding
68 self.archives = []
68 self.archives = []
69
69
@@ -135,6 +135,7 b' web.baseurl'
135 from __future__ import absolute_import
135 from __future__ import absolute_import
136
136
137 import email
137 import email
138 import email.parser as emailparser
138 import fnmatch
139 import fnmatch
139 import socket
140 import socket
140 import time
141 import time
@@ -339,7 +340,7 b' class notifier(object):'
339 'and revset\n')
340 'and revset\n')
340 return
341 return
341
342
342 p = email.Parser.Parser()
343 p = emailparser.Parser()
343 try:
344 try:
344 msg = p.parsestr(data)
345 msg = p.parsestr(data)
345 except email.Errors.MessageParseError as inst:
346 except email.Errors.MessageParseError as inst:
@@ -12,6 +12,7 b' import collections'
12 import copy
12 import copy
13 import difflib
13 import difflib
14 import email
14 import email
15 import email.parser as emailparser
15 import errno
16 import errno
16 import hashlib
17 import hashlib
17 import os
18 import os
@@ -108,7 +109,7 b' def split(stream):'
108 cur.append(line)
109 cur.append(line)
109 c = chunk(cur)
110 c = chunk(cur)
110
111
111 m = email.Parser.Parser().parse(c)
112 m = emailparser.Parser().parse(c)
112 if not m.is_multipart():
113 if not m.is_multipart():
113 yield msgfp(m)
114 yield msgfp(m)
114 else:
115 else:
@@ -217,7 +218,7 b' def extract(ui, fileobj):'
217 fd, tmpname = tempfile.mkstemp(prefix='hg-patch-')
218 fd, tmpname = tempfile.mkstemp(prefix='hg-patch-')
218 tmpfp = os.fdopen(fd, pycompat.sysstr('w'))
219 tmpfp = os.fdopen(fd, pycompat.sysstr('w'))
219 try:
220 try:
220 msg = email.Parser.Parser().parse(fileobj)
221 msg = emailparser.Parser().parse(fileobj)
221
222
222 subject = msg['Subject'] and mail.headdecode(msg['Subject'])
223 subject = msg['Subject'] and mail.headdecode(msg['Subject'])
223 data['user'] = msg['From'] and mail.headdecode(msg['From'])
224 data['user'] = msg['From'] and mail.headdecode(msg['From'])
General Comments 0
You need to be logged in to leave comments. Login now