def remove_mappings(quickstart_xml, webdefault_xml):
 tags_to_examine = ['filter-mapping', 'servlet-mapping']
 default_urls = set()
 default_root = xml.etree.ElementTree.fromstring(webdefault_xml)
 for child in _children_with_tags(default_root, tags_to_examine):
  for grandchild in _children_with_tag(child, 'url-pattern'):
   url = grandchild.text.strip()
   if url.startswith('/'):
    default_urls.add(url)
 to_remove = []
 quickstart_root = xml.etree.ElementTree.fromstring(quickstart_xml)
 for child in _children_with_tags(quickstart_root, tags_to_examine):
  for grandchild in _children_with_tag(child, 'url-pattern'):
   if (grandchild.text.strip() in default_urls):
    to_remove.append(child)
 for child in to_remove:
  quickstart_root.remove(child)
 output = cStringIO.StringIO()
 xml.etree.ElementTree.ElementTree(quickstart_root).write(output)
 return output.getvalue()

def remove_mappings ( quickstart_xml , webdefault_xml ) : tags_to_examine = [ 'filter-mapping' , 'servlet-mapping' ] default_urls = set ( ) default_root = xml . etree . ElementTree . fromstring ( webdefault_xml ) for child in _children_with_tags ( default_root , tags_to_examine ) : for grandchild in _children_with_tag ( child , 'url-pattern' ) : url = grandchild . text . strip ( ) if url . startswith ( '/' ) : default_urls . add ( url ) to_remove = [ ] quickstart_root = xml . etree . ElementTree . fromstring ( quickstart_xml ) for child in _children_with_tags ( quickstart_root , tags_to_examine ) : for grandchild in _children_with_tag ( child , 'url-pattern' ) : if ( grandchild . text . strip ( ) in default_urls ) : to_remove . append ( child ) for child in to_remove : quickstart_root . remove ( child ) output = cStringIO . StringIO ( ) xml . etree . ElementTree . ElementTree ( quickstart_root ) . write ( output ) return output . getvalue ( )
removes mappings from quickstart-web .