pha/matchers.py
def _prune_unmatched_elements(element, all_element_definitions):
    """ Removes elements in the tree which don't match any def or carry children who match any def """

    i_match_anything = any(_matches(elem_def, element) for elem_def in all_element_definitions)

    # Now I find out whether the children match anything
    children_to_extract = []
    child_matched_anything = False
    for child_element in _child_elements(element):
        if _prune_unmatched_elements(child_element, all_element_definitions):
            child_matched_anything = True
        else:
            children_to_extract.append(child_element)
    for child_element in children_to_extract:
        child_element.extract()

    # Let the client know if anything matched
    return i_match_anything or child_matched_anything
 Removes elements in the tree which don't match any def or carry children who match any def 
Removes elements in the tree which don't match any def or carry children who match any def
Removes elements in the tree which don ' t match any def or carry children who match any def
def _prune_unmatched_elements(element, all_element_definitions):
    i_match_anything = any(_matches(elem_def, element) for elem_def in all_element_definitions)
    children_to_extract = []
    child_matched_anything = False
    for child_element in _child_elements(element):
        if _prune_unmatched_elements(child_element, all_element_definitions):
            child_matched_anything = True
        else:
            children_to_extract.append(child_element)
    for child_element in children_to_extract:
        child_element.extract()
    return i_match_anything or child_matched_anything
def _prune_unmatched_elements ( element , all_element_definitions ) : i_match_anything = any ( _matches ( elem_def , element ) for elem_def in all_element_definitions ) children_to_extract = [ ] child_matched_anything = False for child_element in _child_elements ( element ) : if _prune_unmatched_elements ( child_element , all_element_definitions ) : child_matched_anything = True else : children_to_extract . append ( child_element ) for child_element in children_to_extract : child_element . extract ( ) return i_match_anything or child_matched_anything
Removes elements in the tree which don't match any def or carry children who match any def
Removes elements in the tree which don ' t match any def or carry children who match any def
""" Removes elements in the tree which don't match any def or carry children who match any def """ # Now I find out whether the children match anything # Let the client know if anything matched
element
all_element_definitions