[PATCH] A few more small cleanups

Nathaniel Smith njs at pobox.com
Sat Feb 14 16:18:14 UTC 2004


Okay to commit?

-- Nathaniel

-- 
The Universe may  /  Be as large as they say
But it wouldn't be missed  /  If it didn't exist.
  -- Piet Hein
-------------- next part --------------
? results.qmr
? qm/external/__init__.pyc
? qm/test/classes/dejagnu_tet_stream.py
? tests/regress/QMTest/regression_database.pyc
? tests/regress/QMTest/selftest.pyc
? tests/regress/tuple1/QMTest/tuple_test.pyc
? tests/results_files/QMTest/results_file_database.pyc
? tests/results_files/QMTest/results_file_test.pyc
Index: ChangeLog
===================================================================
RCS file: /home/qm/Repository/qm/ChangeLog,v
retrieving revision 1.602
diff -u -r1.602 ChangeLog
--- ChangeLog	13 Feb 2004 23:21:51 -0000	1.602
+++ ChangeLog	14 Feb 2004 16:16:39 -0000
@@ -1,3 +1,9 @@
+2004-02-14  Nathaniel Smith  <njs at codesourcery.com>
+
+	* qm/common.py (encode_data_as_text): Remove.
+	(decode_data_from_text): Likewise.
+	(format_byte_count): Likewise.
+
 2004-02-13  Mark Mitchell  <mark at codesourcery.com>
 
 	* qm/common.py (open_temporary_file_fd): Add suffix parameter.
Index: qm/common.py
===================================================================
RCS file: /home/qm/Repository/qm/qm/common.py,v
retrieving revision 1.82
diff -u -r1.82 common.py
--- qm/common.py	13 Feb 2004 23:19:59 -0000	1.82
+++ qm/common.py	14 Feb 2004 16:16:39 -0000
@@ -243,31 +243,12 @@
     return string.join(traceback.format_tb(exc_info[2]), "\n")
 
 
-def format_byte_count(bytes):
-    """Return the traditional representation of 'bytes' bytes."""
-
-    kb = 1024.0
-    mb = kb * 1024
-    gb = mb * 1024
-    tb = gb * 1024
-    
-    for name, order in [
-        ("TB", tb),
-        ("GB", gb),
-        ("MB", mb),
-        ("KB", kb),
-        ]:
-        if bytes >= order:
-            return "%.1f %s" % (bytes / order, name)
-
-    return "%d bytes" % bytes
-
-
 def convert_from_dos_text(text):
     """Replace CRLF with LF in 'text'."""
 
     return string.replace(text, "\r\n", "\n")
 
+
 __load_module_lock = lock.RLock()
 """A lock used by load_module."""
 
@@ -419,66 +400,6 @@
         return [ entry ]
     else:
         return split_path_fully(dir) + [ entry ]
-
-
-def encode_data_as_text(data, mime_type="application/octet-stream"):
-    """Encode data as text.
-
-    'data' -- The data to encode.
-
-    'mime_type' -- The MIME type of the data.
-
-    returns -- A pair.  The first element designates the encoding scheme
-    used.  The second is a string containing the encoded data."""
-
-    base_type = string.split(mime_type, "/", 1)[0]
-
-    # For the text base MIME type, use a quoted-printable encoding.
-    # This makes the encoded data more human-friendly.
-    if base_type == "text":
-        encoding = "quoted-printable"
-        input_file = cStringIO.StringIO(data)
-        output_file = cStringIO.StringIO()
-        quopri.encode(input_file, output_file, 0)
-        data = output_file.getvalue()
-
-    # For everything else, gzip the data and then base64-encode it.
-    else:
-        encoding = "gzipped base64"
-        data = gzip.zlib.compress(data)
-        data = base64.encodestring(data)
-
-    return (encoding, data)
-
-
-def decode_data_from_text(data, encoding):
-    """Decode data that was encoded as text.
-
-    'data' -- The encoded data.
-
-    'encoding' -- The encoding scheme used to encode this data.
-
-    returns -- A string containing the decoded data."""
-
-    if encoding == "none":
-        return data
-
-    elif encoding == "quoted-printable":
-        # Decode quoted-printable text.
-        input_file = cStringIO.StringIO(data)
-        output_file = cStringIO.StringIO()
-        quopri.decode(input_file, output_file)
-        return output_file.getvalue()
-        
-    elif encoding == "gzipped base64":
-        # First base64-decode the data.
-        data = base64.decodestring(data)
-        # Now uncompress it.
-        return gzip.zlib.decompress(data)
-
-    else:
-        # Unknown encoding type.
-        raise ValueError, "unknown encoding %s" % encoding
 
 
 def open_temporary_file_fd(suffix = None):


More information about the qmtest mailing list