Patch #407434: add rfc822_escape utility function
authorAndrew M. Kuchling <amk@amk.ca>
Thu, 22 Mar 2001 03:03:41 +0000 (03:03 +0000)
committerAndrew M. Kuchling <amk@amk.ca>
Thu, 22 Mar 2001 03:03:41 +0000 (03:03 +0000)
Lib/distutils/util.py

index e596150422526e531d4fc97c122ec249755ecf9f..010db9a3b0dde606a9680134976694390a8f5560 100644 (file)
@@ -443,3 +443,13 @@ byte_compile(files, optimize=%s, force=%s,
                               (file, cfile_base)
 
 # byte_compile ()
+
+def rfc822_escape (header):
+    """Return a version of the string escaped for inclusion in an
+    RFC-822 header, by adding a space after each newline.
+    """
+    header = string.rstrip(header)
+    header = string.replace(header, '\n', '\n ')
+    return header
+
+