Skip to content

Instantly share code, notes, and snippets.

@u8sand
Created December 24, 2014 00:20
Show Gist options
  • Save u8sand/1d0c47a42c0ec657a18c to your computer and use it in GitHub Desktop.
Save u8sand/1d0c47a42c0ec657a18c to your computer and use it in GitHub Desktop.
Sometimes Qt Creator doesn't clean up after itself--this should take care of that.
#!/bin/python3
import sys;
from lxml import etree;
def clean(f):
print("Processing "+f+"...")
tree = etree.parse(f)
root = tree.getroot()
used_actions=[]
for child in root.iter('addaction'):
used_actions.append(child.get('name'))
for child in root.iter('action'):
if child.get('name') not in used_actions:
print("Cleaning "+child.get('name'))
child.getparent().remove(child)
tree.write(f)
args = iter(sys.argv)
next(args)
for arg in args:
clean(arg)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment