]> git.phdru.name Git - mimedecode.git/blobdiff - formatparam_27.py
Split mimedecode.py into a mimedecode library and a small script
[mimedecode.git] / formatparam_27.py
diff --git a/formatparam_27.py b/formatparam_27.py
deleted file mode 100644 (file)
index 9abbebe..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-from email import message
-from email import utils
-
-
-def _formatparam(param, value=None, quote=True):
-    """This is _formatparam from Python 2.7"""
-    if value is not None and len(value) > 0:
-        # A tuple is used for RFC 2231 encoded parameter values where items
-        # are (charset, language, value).  charset is a string, not a Charset
-        # instance.
-        if isinstance(value, tuple):
-            # Encode as per RFC 2231
-            param += '*'
-            value = utils.encode_rfc2231(value[2], value[0], value[1])
-        # BAW: Please check this.  I think that if quote is set it should
-        # force quoting even if not necessary.
-        if quote or message.tspecials.search(value):
-            return '%s="%s"' % (param, utils.quote(value))
-        else:
-            return '%s=%s' % (param, value)
-    else:
-        return param
-
-
-# Replace with this _formatparam to avoid re-encoding non-ascii params
-message._formatparam = _formatparam