[Lxml-checkins] r44838 - in lxml/branch/html: doc src/lxml/html src/lxml/html/tests

scoder at codespeak.net scoder at codespeak.net
Sun Jul 8 09:55:35 CEST 2007


Author: scoder
Date: Sun Jul  8 09:55:34 2007
New Revision: 44838

Modified:
   lxml/branch/html/doc/lxmlhtml.txt
   lxml/branch/html/src/lxml/html/__init__.py
   lxml/branch/html/src/lxml/html/tests/test_rewritelinks.txt
Log:
renamed iter_links() to iterlinks()

Modified: lxml/branch/html/doc/lxmlhtml.txt
==============================================================================
--- lxml/branch/html/doc/lxmlhtml.txt	(original)
+++ lxml/branch/html/doc/lxmlhtml.txt	Sun Jul  8 09:55:34 2007
@@ -123,7 +123,7 @@
 Creating HTML with the E-factory
 ================================
 
-.. _`E-factory`: http://FIXME/
+.. _`E-factory`: http://online.effbot.org/2006_11_01_archive.htm#et-builder
 
 lxml.html comes with a predefined HTML vocabulary for the `E-factory`_,
 originally written by Fredrik Lundh.  This allows you to quickly generate HTML
@@ -172,7 +172,7 @@
 There are several methods on elements that allow you to see and modify
 the links in a document.
 
-``.iter_links()``:
+``.iterlinks()``:
     This yields ``(element, attribute, link, pos)`` for every link in
     the document.  ``attribute`` may be None if the link is in the
     text (as will be the case with a ``<style>`` tag with
@@ -214,7 +214,7 @@
     things like ``"mailto:bob at example.com"`` (or ``javascript:...``).
 
     If you want access to the context of the link, you should use
-    ``.iter_links()`` instead.
+    ``.iterlinks()`` instead.
 
 
 Functions
@@ -222,14 +222,15 @@
 
 In addition to these methods, there are corresponding functions:
 
-* ``iter_links(html)``
+* ``iterlinks(html)``
 * ``make_links_absolute(html, base_href, ...)``
 * ``rewrite_links(html, link_repl_func, ...)``
 * ``resolve_base_href(html)``
 
-These functions will parse ``html`` if it is a string, then return the
-new HTML as a string.  If you pass in a document, the document will be
-copied, the method performed, and the new document returned.
+These functions will parse ``html`` if it is a string, then return the new
+HTML as a string.  If you pass in a document, the document will be copied
+(except for ``iterlinks()``), the method performed, and the new document
+returned.
 
 
 Cleaning up HTML

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	Sun Jul  8 09:55:34 2007
@@ -8,7 +8,7 @@
 
 __all__ = ['HTML', 'tostring', 'Element', 'defs',
            'find_rel_links', 'find_class', 'make_links_absolute',
-           'resolve_base_href', 'iter_links', 'rewrite_links']
+           'resolve_base_href', 'iterlinks', 'rewrite_links']
 
 _rel_links_xpath = etree.XPath("descendant-or-self::a[@rel]")
 #_class_xpath = etree.XPath(r"descendant-or-self::*[regexp:match(@class, concat('\b', $class_name, '\b'))]", {'regexp': 'http://exslt.org/regular-expressions'})
@@ -152,7 +152,7 @@
             return
         self.make_links_absolute(base_href, resolve_base_href=False)
         
-    def iter_links(self):
+    def iterlinks(self):
         """
         Yield (element, attribute, link, pos), where attribute may be None
         (indicating the link is in the text).  ``pos`` is the position
@@ -200,7 +200,7 @@
             self.make_links_absolute(base_href, resolve_base_href=resolve_base_href)
         elif resolve_base_href:
             self.resolve_base_href()
-        for el, attrib, link, pos in self.iter_links():
+        for el, attrib, link, pos in self.iterlinks():
             new_link = link_repl_func(link)
             if new_link == link:
                 continue
@@ -272,7 +272,7 @@
 find_class = _MethodFunc('find_class', copy=False)
 make_links_absolute = _MethodFunc('make_links_absolute', copy=True)
 resolve_base_href = _MethodFunc('resolve_base_href', copy=True)
-iter_links = _MethodFunc('iter_links', copy=False)
+iterlinks = _MethodFunc('iterlinks', copy=False)
 rewrite_links = _MethodFunc('rewrite_links', copy=True)
 
 class HtmlComment(etree.CommentBase, HtmlMixin):

Modified: lxml/branch/html/src/lxml/html/tests/test_rewritelinks.txt
==============================================================================
--- lxml/branch/html/src/lxml/html/tests/test_rewritelinks.txt	(original)
+++ lxml/branch/html/src/lxml/html/tests/test_rewritelinks.txt	Sun Jul  8 09:55:34 2007
@@ -68,14 +68,14 @@
      </body>
     </html>
 
-The ``iter_links`` method (and function) gives you all the links in
+The ``iterlinks`` method (and function) gives you all the links in
 the document, along with the element and attribute the link comes
 from.  This makes it fairly easy to see what resources the document
 references or embeds (an ``<a>`` tag is a reference, an ``<img>`` tag
 is something embedded).  It returns a generator of ``(element, attrib,
 link)``, which is awkward to test here, so we'll make a printer::
 
-    >>> from lxml.html import iter_links, HTML, tostring
+    >>> from lxml.html import iterlinks, HTML, tostring
     >>> def print_iter(seq):
     ...     for element, attrib, link, pos in seq:
     ...         if pos:
@@ -83,7 +83,7 @@
     ...         else:
     ...             extra = ''
     ...         print '%s %s="%s"%s' % (element.tag, attrib, link, extra)
-    >>> print_iter(iter_links('''
+    >>> print_iter(iterlinks('''
     ... <html>
     ...  <head>
     ...   <link rel="stylesheet" href="style.css">


More information about the lxml-checkins mailing list