[Lxml-checkins] r43956 - lxml/branch/html/src/lxml/html

ianb at codespeak.net ianb at codespeak.net
Fri Jun 1 06:35:35 CEST 2007


Author: ianb
Date: Fri Jun  1 06:35:35 2007
New Revision: 43956

Modified:
   lxml/branch/html/src/lxml/html/__init__.py
Log:
rename get_text_content to text_content.  Add docstring and notes

Modified: lxml/branch/html/src/lxml/html/__init__.py
==============================================================================
--- lxml/branch/html/src/lxml/html/__init__.py	(original)
+++ lxml/branch/html/src/lxml/html/__init__.py	Fri Jun  1 06:35:35 2007
@@ -1,6 +1,7 @@
 import threading
 import re
 import urlparse
+import copy
 from lxml import etree
 from lxml.html import defs
 
@@ -96,7 +97,7 @@
         except IndexError:
             return default
 
-    def get_text_content(self):
+    def text_content(self):
         """
         Return the text content of the tag (and the text in any children).
         """
@@ -200,6 +201,19 @@
                     
 
 class _MethodFunc(object):
+    """
+    An object that represents a method on an element as a function;
+    the function takes either an element or an HTML string.  It
+    returns whatever the function normally returns, or if the function
+    works in-place (and so returns None) it returns a serialized form
+    of the resulting document.
+    """
+    # FIXME: the None test is a bit sloppy FIXME: this is basically
+    # functional if you use it with a string; should it be a
+    # functional equivalent for working with elements too?  It has to
+    # make a copy of the document.  The problem is it changes the
+    # return type, as it should return the copied document and not a
+    # serialization.  Is that odd?
     def __init__(self, name, fragment=False, source_class=HtmlMixin):
         self.name = name
         self.fragment = fragment


More information about the lxml-checkins mailing list