[Lxml-checkins] r43350 - lxml/trunk/src/lxml

scoder at codespeak.net scoder at codespeak.net
Mon May 14 10:34:35 CEST 2007


Author: scoder
Date: Mon May 14 10:34:35 2007
New Revision: 43350

Modified:
   lxml/trunk/src/lxml/xmlerror.pxi
Log:
cleanup, doc strings

Modified: lxml/trunk/src/lxml/xmlerror.pxi
==============================================================================
--- lxml/trunk/src/lxml/xmlerror.pxi	(original)
+++ lxml/trunk/src/lxml/xmlerror.pxi	Mon May 14 10:34:35 2007
@@ -129,6 +129,9 @@
         self._entries = entries
 
     def copy(self):
+        """Creates a shallow copy of this error log.  Reuses the list of
+        entries.
+        """
         return _ListErrorLog(self._entries, self.last_error)
 
     def __iter__(self):
@@ -156,6 +159,9 @@
         return bool(self._entries)
 
     def filter_domains(self, domains):
+        """Filter the errors by the given domains and return a new error log
+        containing the matches.
+        """
         cdef _LogEntry entry
         filtered = []
         if not python.PySequence_Check(domains):
@@ -166,6 +172,9 @@
         return _ListErrorLog(filtered)
 
     def filter_types(self, types):
+        """Filter the errors by the given types and return a new error log
+        containing the matches.
+        """
         cdef _LogEntry entry
         if not python.PySequence_Check(types):
             types = (types,)
@@ -176,8 +185,9 @@
         return _ListErrorLog(filtered)
 
     def filter_levels(self, levels):
-        """Return a log with all messages of the requested level(s). Takes a
-        single log level or a sequence."""
+        """Filter the errors by the given error levels and return a new error
+        log containing the matches.
+        """
         cdef _LogEntry entry
         if not python.PySequence_Check(levels):
             levels = (levels,)
@@ -223,6 +233,8 @@
         del self._entries[:]
 
     def copy(self):
+        """Creates a shallow copy of this error log and the list of entries.
+        """
         return _ListErrorLog(self._entries[:], self.last_error)
 
     def __iter__(self):
@@ -270,7 +282,8 @@
     object and calls ``self.log(log_entry, format_string, arg1, arg2, ...)``
     with appropriate data.
     """
-    cdef public object level_map
+    cdef readonly object level_map
+    cdef object _map_level
     cdef object _log
     def __init__(self, logger_name=None):
         _BaseErrorLog.__init__(self)
@@ -280,6 +293,7 @@
             ErrorLevels.ERROR   : logging.ERROR,
             ErrorLevels.FATAL   : logging.CRITICAL
             }
+        self._map_level = self.level_map.get
         if logger_name:
             logger = logging.getLogger(logger_name)
         else:
@@ -287,11 +301,13 @@
         self._log = logger.log
 
     def copy(self):
+        """Dummy method that returns an empty error log.
+        """
         return _ListErrorLog([])
 
     def log(self, entry, message_format_string, *args):
         self._log(
-            self.level_map.get(entry.level, 0),
+            self._map_level(entry.level, 0),
             message_format_string, *args
             )
 
@@ -310,9 +326,8 @@
     """Replace the global error log by an etree.PyErrorLog that uses the
     standard Python logging package.
 
-    Note that this slows down processing and disables access to the global
-    error log from exceptions.  Parsers, XSLT etc. will continue to provide
-    their normal local error log.
+    Note that this disables access to the global error log from exceptions.
+    Parsers, XSLT etc. will continue to provide their normal local error log.
     """
     global __GLOBAL_ERROR_LOG
     __GLOBAL_ERROR_LOG = log


More information about the lxml-checkins mailing list