Skip to content

Instantly share code, notes, and snippets.

@spellancer
Created October 22, 2013 12:03
Show Gist options
  • Save spellancer/7099390 to your computer and use it in GitHub Desktop.
Save spellancer/7099390 to your computer and use it in GitHub Desktop.
fin = open("input.xml", "r")
a = fin.readline()
l = ""
kk = False
while len(a)!=0:
a = fin.readline()
if a.find("<kernel>")!=-1 and kk==False:
p = a.find("<kernel>")
for i in range(0,p):
l+= " "
kk=True
elif a.find("<initrd>")!=-1 and kk==False:
p = a.find("<kernel>")
for i in range(0,p):
l+= " "
kk=True
elif a.find("<cmdline>")!=-1 and kk==False:
p = a.find("<kernel>")
for i in range(0,p):
l+= " "
kk=True
fin.close()
fin = open("input.xml", "r")
fout = open("output.xml","w")
a = fin.readlines()
k=False
for i in a:
if i.find("<boot")!=-1:
k=True
for i in a:
if i.find("<kernel>")!=-1 or i.find("<initrd>")!=-1 or i.find("<cmdline>")!=-1:
if i.find("<boot")==-1 and k==False:
fout.write(l+"<boot dev='hd'/>\n")
k=True
elif i.find("<kernel>")==-1 and i.find("<initrd>")==-1 and i.find("<cmdline>")==-1:
fout.write(i)
fin.close()
fout.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment