Luke Plant avatar Luke Plant committed d7cde94

Changed the sense of filter argument to cleanup() method to be more intuitive

Comments (0)

Files changed (2)

semanticeditor/utils/etree.py

 def cleanup(elem, filter):
     """
     Removes start and stop tags for any element for which the filter
-    function returns false.  If you want to remove the entire element,
+    function returns True.  If you want to remove the entire element,
     including all subelements, use the 'clear' method inside the
     filter callable.
 
     Note that this function modifies the tree in place.
     @param elem An element tree.
     @param filter An filter function.  This should be a callable that
-    takes an element as its single argument.
+    takes an element as its single argument, and returns True if the
+    element should be cleaned.
     """
 
     out = []
     for e in elem:
         cleanup(e, filter)
-        if not filter(e):
+        if filter(e):
             if e.text:
                 if out:
                     out[-1].tail = textjoin(out[-1].tail, e.text)

semanticeditor/utils/presentation.py

     return ET.tostring(root).replace('<html>','').replace('</html>','')
 
 def _strip_presentation(tree):
-    cleanup(tree, lambda t: t.tag != 'div')
+    cleanup(tree, lambda t: t.tag == 'div')
 
 
 def _sanitise_styleinfo(styleinfo, sect_ids):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.