def _copy_root_siblings(source: etree._Element, target: etree._Element): stack = [] current_element = source.getprevious() while current_element is not None: stack.append(current_element) current_element = current_element.getprevious() while stack: target.addprevious(copy(stack.pop())) stack = [] current_element = source.getnext() while current_element is not None: stack.append(current_element) current_element = current_element.getnext() while stack: target.addnext(copy(stack.pop()))
def load_app( app: et._Element, direction: str ) -> Tuple[Union[int, Tuple[int, int], None], List[Dict[str, str]], List[Dict[ str, str]], List[str], et._Element]: if direction == 'next': while True: app = app.getnext() if app.tag == 'app': break elif direction == 'prev': while True: app = app.getprevious() if app.tag == 'app': break selected_app = get_focus_app(app) rdgs = get_all_rdgs(app) arcs, nodes = get_arcs(app) return selected_app, rdgs, arcs, nodes, app