Skip to content

Commit

Permalink
Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
Josef-Friedrich committed Jan 20, 2024
1 parent 9b92d80 commit a411b02
Showing 1 changed file with 0 additions and 21 deletions.
21 changes: 0 additions & 21 deletions mscxyz/xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,24 +310,3 @@ def remove_tags(self, *element_paths: str) -> Xml:
for element in self.findall(path):
self.remove(element)
return self

def remove_tags_by_xpath(self, *xpath_strings: str) -> None:
"""Remove tags by xpath strings.
:param xpath_strings: A xpath string.
.. code:: Python
tree.remove_tags_by_xpath(
'/museScore/Score/Style', '//LayoutBreak', '//StemDirection'
)
"""
for xpath_string in xpath_strings:
x: _XPathObject = self.root.xpath(xpath_string)
if isinstance(x, list):
for rm in x:
if isinstance(rm, _Element):
p: _Element | None = rm.getparent()
if isinstance(p, _Element):
p.remove(rm)

0 comments on commit a411b02

Please sign in to comment.