From: Oleg Broytman Date: Sat, 1 Feb 2014 17:27:19 +0000 (+0400) Subject: Rename recode2 => recode_if_needed X-Git-Tag: v2.3.2~3 X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=554b3f06f7f69d0f570ebac18b1d9161ac7ddf5f;p=mimedecode.git Rename recode2 => recode_if_needed --- diff --git a/mimedecode.py b/mimedecode.py index 0e15fe0..b1b18e3 100755 --- a/mimedecode.py +++ b/mimedecode.py @@ -46,7 +46,7 @@ def recode(s, charset): return unicode(s, charset, "replace").encode(gopts.default_encoding, "replace") -def recode2(s, charset): +def recode_if_needed(s, charset): if charset and charset.lower() <> gopts.default_encoding: s = recode(s, charset) return s @@ -69,7 +69,7 @@ def _decode_header(s): if charset is None: rtn.append(atom) else: - rtn.append(recode2(atom, charset)) + rtn.append(recode_if_needed(atom, charset)) rtn.append(' ') del rtn[-1] # remove the last space @@ -89,7 +89,7 @@ def decode_header(msg, header): def _decode_header_param(s): - return recode2(s[2], s[0]) + return recode_if_needed(s[2], s[0]) def decode_header_param(msg, header, param): @@ -182,7 +182,7 @@ def recode_charset(msg, s): save_charset = charset = msg.get_content_charset() if charset and charset.lower() <> gopts.default_encoding: - s = recode2(s, charset) + s = recode_if_needed(s, charset) content_type = msg.get_content_type() set_content_type(msg, content_type, gopts.default_encoding) msg["X-MIME-Autoconverted"] = "from %s to %s by %s id %s" % (save_charset, gopts.default_encoding, gopts.host_name, me)