Changeset 2810:631027615512 in livinglogic.python.xist

Show
Ignore:
Timestamp:
07/25/07 19:46:03 (12 years ago)
Author:
Walter Doerwald <walter@…>
Branch:
default
Message:

More docstring work.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/ll/xist/xfind.py

    r2809 r2810  
    386386    """ 
    387387    <par>Selector that selects all element nodes that have an attribute with one 
    388     of the specified Python names.</par> 
    389  
    390     <example> 
    391     <tty> 
    392     <prompt>>>> </prompt><input>from ll.xist import parsers, xfind</input> 
     388    of the specified Python names. For selecting nodes with global attributes 
     389    the attribute class can be passed.</par> 
     390 
     391    <example> 
     392    <tty> 
     393    <prompt>>>> </prompt><input>from ll.xist import parsers, xfind</input> 
     394    <prompt>>>> </prompt><input>from ll.xist.ns import html, xml</input> 
    393395    <prompt>>>> </prompt><input>doc = parsers.parseURL("http://www.python.org", tidy=True)</input> 
    394396    <prompt>>>> </prompt><input>for node in doc.walknode(<em>xfind.onlyoftype &amp; xsc.Element</em>):</input> 
     
    400402    <ll.xist.ns.html.body element object (19 children/no attrs) (from http://www.python.org/:26:?) at 0xb6d7282c>]]> 
    401403    <rep>...</rep> 
     404    <prompt>>>> </prompt><input>for node in doc.walknode(<em>xfind.hasattr(xml.Attrs.lang</em>):</input> 
     405    <prompt>... </prompt><input>\tprint repr(node)</input> 
     406    <prompt>... </prompt><input></input> 
     407    <![CDATA[<ll.xist.ns.html.html element object (2 children/2 attrs) (from http://www.python.org/:4:?) at 0xb6d71d4c>]]> 
    402408    </tty> 
    403409    </example> 
     
    445451    """ 
    446452    <par>Selector that selects all element nodes where an attribute with the 
    447     specified Python name has the specified value. Note that 
     453    specified Python name has the specified value. For global attributes 
     454    the attribute class can be passed. Note that 
    448455    <pyref module="ll.xist.xsc" class="Attr" method="isfancy">fancy</pyref> attributes 
    449456    will not be considered.</par> 
     
    509516    """ 
    510517    <par>Selector that selects all element nodes where an attribute with the 
    511     specified Python name contains the specified subtring in its value. Note that 
    512     <pyref module="ll.xist.xsc" class="Attr" method="isfancy">fancy</pyref> attributes 
    513     will not be considered.</par> 
     518    specified Python name contains the specified subtring in its value. For 
     519    global attributes the attribute class can be passed. Note that 
     520    <pyref module="ll.xist.xsc" class="Attr" method="isfancy">fancy</pyref> 
     521    attributes will not be considered.</par> 
    514522 
    515523    <example> 
     
    575583    """ 
    576584    <par>Selector that selects all element nodes where an attribute with the 
    577     specified Python name starts with the specified string. Note that 
     585    specified Python name starts with the specified string. For global attributes 
     586    the attribute class can be passed. Note that 
    578587    <pyref module="ll.xist.xsc" class="Attr" method="isfancy">fancy</pyref> attributes 
    579588    will not be considered.</par> 
     
    638647    """ 
    639648    <par>Selector that selects all element nodes where an attribute with the 
    640     specified Python name ends with the specified string. Note that 
     649    specified Python name ends with the specified string. For global attributes 
     650    the attribute class can be passed. Note that 
    641651    <pyref module="ll.xist.xsc" class="Attr" method="isfancy">fancy</pyref> attributes 
    642652    will not be considered.</par> 
     
    11361146 
    11371147class CallableSelector(Selector): 
     1148    """ 
     1149    <par>A <class>CallableSelector</class> is a selector that calls a user specified 
     1150    callable to select nodes. The callable gets passed the path and must return 
     1151    a bool specifying whether this path is selected. A <class>CallableSelector</class> 
     1152    is created implicitely whenever a callable is passed to a method that expects 
     1153    a walk filter.</par> 
     1154 
     1155    <par>The following example outputs all links that point outside the <lit>python.org</lit> domain:</par> 
     1156 
     1157    <example> 
     1158    <tty> 
     1159    <prompt>>>> </prompt><input>from ll.xist import parsers, xfind</input> 
     1160    <prompt>>>> </prompt><input>from ll.xist.ns import html</input> 
     1161    <prompt>>>> </prompt><input>doc = parsers.parseURL("http://www.python.org", tidy=True)</input> 
     1162    <prompt>>>> </prompt><input>def foreignlink(path):</input> 
     1163    <prompt>... </prompt><input>    return path and isinstance(path[-1], html.a) and not path[-1].attrs.href.asURL().server.endswith(".python.org")</input> 
     1164    <prompt>... </prompt><input></input> 
     1165    <prompt>>>> </prompt><input>for node in doc.walknode(<em>foreignlink</em>):</input> 
     1166    <prompt>... </prompt><input>\tprint node.bytes()</input> 
     1167    <prompt>... </prompt><input></input> 
     1168    <![CDATA[<a href="http://homegain.com/" class="reference">HomeGain.com</a> 
     1169    <a href="http://www.zope.org/">Zope</a> 
     1170    <a href="http://www.djangoproject.com/">Django</a> 
     1171    <a href="http://www.turbogears.org/">TurboGears</a> 
     1172    <a href="http://pyxml.sourceforge.net/topics/">XML</a>]]> 
     1173    <rep>..</rep> 
     1174    </tty> 
     1175    </example> 
     1176    """ 
    11381177    def __init__(self, func): 
    11391178        self.func = func