def filter(path, mimetype, body): # HTML if mimetype == 'text/html': source = XHTMLFile(string=body) target = XHTMLFile() elem = get_element(source.events, 'div', **{'class': 'body'}) if not elem: print 'E', path return None elements = elem.get_content_elements() elements = rewrite_uris(elements, rewrite) elements = list(elements) target.set_body(elements) return target.to_str() # Skip elif mimetype in skip: return None # Keep elif mimetype in keep: return body # Unknown else: print 'X', path, mimetype return body
def filter(path, mimetype, body): # HTML if mimetype == "text/html": source = XHTMLFile(string=body) target = XHTMLFile() elem = get_element(source.events, "div", **{"class": "body"}) if not elem: print "E", path return None elements = elem.get_content_elements() elements = rewrite_uris(elements, rewrite) elements = list(elements) target.set_body(elements) return target.to_str() # Skip elif mimetype in skip: return None # Keep elif mimetype in keep: return body # Unknown else: print "X", path, mimetype return body