Permalink
Browse files

Function already offered by lxml: addnext, addprevious

  • Loading branch information...
kthoden committed Nov 22, 2018
1 parent 9e5bcbd commit 076f1acb8c410fc33f6e1a6e9510e4420fb86fbb
Showing with 0 additions and 18 deletions.
  1. +0 −18 libeoaconvert.py
@@ -364,21 +364,3 @@ def get_place_in_xml_tree(element, tree):

return position
# def get_place_in_xml_tree ends here

def insert_after(new_element, preceding, before=False):
"""Insert an element after another
Optional keyword argument inserts element before
"""

parent_element = preceding.getparent()
context_children = parent_element.getchildren()
preceding_position = context_children.index(preceding)
if before:
insertion_point = preceding_position
else:
insertion_point = preceding_position + 1
parent_element.insert(insertion_point, new_element)

return
# def insert_after ends here

0 comments on commit 076f1ac

Please sign in to comment.