From: Oleg Broytman Date: Thu, 28 Jul 2016 22:12:59 +0000 (+0300) Subject: Use 'key in dict' for Python 3 compatibility X-Git-Tag: 2.7.0~37 X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=085ec4a9063648bdaeea647f80bb61fd7c1d9639;p=mimedecode.git Use 'key in dict' for Python 3 compatibility --- diff --git a/mimedecode.py b/mimedecode.py index 8c18c6a..839703f 100755 --- a/mimedecode.py +++ b/mimedecode.py @@ -66,7 +66,7 @@ def _decode_header(s): def decode_header(msg, header): "Decode mail header (if exists) and put it back, if it was encoded" - if msg.has_key(header): + if header in msg: value = msg[header] new_value = _decode_header(value) if new_value != value: # do not bother to touch msg if not changed @@ -76,7 +76,7 @@ def decode_header(msg, header): def decode_header_param(msg, header, param): "Decode mail header's parameter (if exists) and put it back, if it was encoded" - if msg.has_key(header): + if header in msg: value = msg.get_param(param, header=header) if value: if isinstance(value, tuple): @@ -181,7 +181,7 @@ def decode_headers(msg): def set_header(msg, header, value): "Replace header" - if msg.has_key(header): + if header in msg: msg.replace_header(header, value) else: msg[header] = value @@ -211,8 +211,8 @@ def decode_body(msg, s): entries = mailcap.lookup(caps, content_type, "view") for entry in entries: - if entry.has_key('copiousoutput'): - if entry.has_key('test'): + if 'copiousoutput' in entry: + if 'test' in entry: test = mailcap.subst(entry['test'], content_type, filename) if test and os.system(test) != 0: continue