[PATCH] Some small cleanups

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


(already committed)

-- Nathaniel

-- 
Eternity is very long, especially towards the end.
  -- Woody Allen
-------------- 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.599
retrieving revision 1.600
diff -u -r1.599 -r1.600
--- ChangeLog	12 Feb 2004 06:19:08 -0000	1.599
+++ ChangeLog	12 Feb 2004 07:44:48 -0000	1.600
@@ -1,5 +1,17 @@
 2004-02-11  Nathaniel Smith  <njs at codesourcery.com>
 
+	* qm/fields.py: Use types.StringTypes instead of
+	qm.common.string_types.  Also remove tabs.
+	* qm/test/result.py: Likewise.
+	* qm/common.py (string_types): Remove.
+	(Empty): Remove.
+	(MutexError): Remove.
+	(MutexLockError): Remove.
+	(ConfigurationError): Remove.
+	(indent_lines): Remove.
+	
+2004-02-11  Nathaniel Smith  <njs at codesourcery.com>
+
 	* qm/common.py: Import getpass.  
 	(get_username): New function.
 	* qm/test/execution_engine.py
Index: qm/common.py
===================================================================
RCS file: /home/qm/Repository/qm/qm/common.py,v
retrieving revision 1.80
retrieving revision 1.81
diff -u -r1.80 -r1.81
--- qm/common.py	12 Feb 2004 06:19:08 -0000	1.80
+++ qm/common.py	12 Feb 2004 07:44:48 -0000	1.81
@@ -54,13 +54,6 @@
 # exceptions
 ########################################################################
 
-class Empty:
-    """An empty class."""
-
-    pass
-
-
-
 class QMException(Exception):
     """An exception generated directly by QM.
 
@@ -77,26 +70,6 @@
 
 
 
-class MutexError(QMException):
-    """A problem occurred with a mutex."""
-
-    pass
-
-
-
-class MutexLockError(QMException):
-    """A lock was not obtained on the mutex."""
-
-    pass
-
-
-
-class ConfigurationError(QMException):
-
-    pass
-
-
-
 class UserError(QMException):
 
     pass
@@ -588,18 +561,6 @@
         return object
 
 
-def indent_lines(text, indent):
-    """Indent each line of 'text' by 'indent' spaces."""
-
-    indentation = ' ' * indent
-    # Break into lines.
-    lines = string.split(text, "\n")
-    # Indent each.
-    lines = map(lambda line, ind=indentation: ind + line, lines)
-    # Rejoin.
-    return string.join(lines, "\n")
-
-
 def wrap_lines(text, columns=72, break_delimiter="\\", indent=""):
     """Wrap lines in 'text' to 'columns' columns.
 
@@ -918,12 +879,6 @@
 
 # The next number to be used when handing out unqiue tag strings.
 _unique_tag = 0
-
-# The string types available in this implementation of Python.
-try:
-    string_types = (types.StringType, types.UnicodeType)
-except AttributeError:
-    string_types = (types.StringType,)
 
 ########################################################################
 # Local Variables:
Index: qm/fields.py
===================================================================
RCS file: /home/qm/Repository/qm/qm/fields.py,v
retrieving revision 1.82
retrieving revision 1.83
diff -u -r1.82 -r1.83
--- qm/fields.py	5 Feb 2004 06:29:11 -0000	1.82
+++ qm/fields.py	12 Feb 2004 07:44:49 -0000	1.83
@@ -646,7 +646,7 @@
 
     def Validate(self, value):
 
-        if not isinstance(value, qm.common.string_types):
+        if not isinstance(value, types.StringTypes):
             raise ValueError, value
         
         # Clean up unless it's a verbatim string.
@@ -1062,7 +1062,7 @@
         # the set.
         contained_field = self.__contained
         element = 0
-	for element in xrange(int(request[name + "_count"])):
+        for element in xrange(int(request[name + "_count"])):
             element_name = name + "_%d" % element
             if not (action == "remove"
                     and request.get(element_name + "_remove") == "on"):
@@ -1073,7 +1073,7 @@
                 if r:
                     redisplay = 1
             element += 1
-	
+        
         # Remove entries from the request that might cause confusion
         # when the page is redisplayed.
         names = []
@@ -1535,8 +1535,8 @@
         if not default_value in enumerals and len(enumerals) > 0:
             default_value = enumerals[0]
         # Perform base class initialization.
-	super(EnumerationField, self).__init__(name, default_value, 
-					       **properties)
+        super(EnumerationField, self).__init__(name, default_value, 
+                                               **properties)
         # Remember the enumerals.
         self.__enumerals = enumerals
 
@@ -1571,7 +1571,7 @@
 
         # Store the name of the enumeral.
         return xmlutil.create_dom_text_element(document, "enumeral", 
-	                                       str(value))
+                                               str(value))
 
 
     ### Input methods.
Index: qm/test/result.py
===================================================================
RCS file: /home/qm/Repository/qm/qm/test/result.py,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- qm/test/result.py	24 Nov 2003 14:06:09 -0000	1.23
+++ qm/test/result.py	12 Feb 2004 07:44:49 -0000	1.24
@@ -338,28 +338,28 @@
     # annotations.
     
     def __getitem__(self, key):
-        assert type(key) in qm.common.string_types
+        assert type(key) in types.StringTypes
         return self.__annotations[key]
 
 
     def __setitem__(self, key, value):
-        assert type(key) in qm.common.string_types
-        assert type(value) in qm.common.string_types
+        assert type(key) in types.StringTypes
+        assert type(value) in types.StringTypes
         self.__annotations[key] = value
 
 
     def __delitem__(self, key):
-        assert type(key) in qm.common.string_types
+        assert type(key) in types.StringTypes
         del self.__annotations[key]
 
 
     def get(self, key, default=None):
-        assert type(key) in qm.common.string_types
+        assert type(key) in types.StringTypes
         return self.__annotations.get(key, default)
 
 
     def has_key(self, key):
-        assert type(key) in qm.common.string_types
+        assert type(key) in types.StringTypes
         return self.__annotations.has_key(key)
 
 


More information about the qmtest mailing list