Advertisement
brandizzi

An empty function with a doctest

Feb 26th, 2018
794
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.69 KB | None | 0 0
  1. def get_css_class_dict(node):
  2.     """
  3.    Given an xml.dom.minidom.Node, returns a map from every "class" attribute
  4.    from it to a list of nodes with this class.
  5.  
  6.    For example, for the document below:
  7.  
  8.    >>> doc = xml.dom.minidom.parseString(
  9.    ...     '''
  10.    ...     <html>
  11.    ...         <body>
  12.    ...             <div class="a b"><span class="a"></span></div>
  13.    ...         </body>
  14.    ...     </html>
  15.    ...     ''')
  16.  
  17.    ...we will get this:
  18.  
  19.    >>> d = get_css_class_dict(doc)
  20.    >>> d['a']  # doctest: +ELLIPSIS
  21.    [<DOM Element: div at ...>, <DOM Element: span at ...>]
  22.    >>> d['b']  # doctest: +ELLIPSIS
  23.    [<DOM Element: span at ...>]
  24.    """
  25.     pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement