#!/usr/bin/python2.6
#su xinmin 2014/2/17
import xml.etree.ElementTree as ET
import sys
def usage():
sys.stderr.write("""Usage: %(progName)s xmlfilename casename --d=true --t=false
Options:
--d=true
set dislplay true or false.
--t=false
set testable true or false.
""" % {
"progName": os.path.split(sys.argv[0])[1],
})
sys.exit(1)
def main(argv):
filename = argv[1]
casename = argv[2]
tree = ET.parse(filename)
root = tree.getroot()
i=3
while i<len(argv) and len(argv[i])>2 and argv[i][0:2] == "--":
arg = argv[i]
if arg.startswith("--d="):
try:
display = arg[len("--d="):]
except ValueError:
usage()
elif arg.startswith("--t="):
try:
test = arg[len("--t="):]
except ValueError:
usage()
else:
usage()
i += 1
for item in root.findall('item'):
if casename == item.find('CaseName').text:
item.set('Displayable',display)
item.set('Testable',test)
break
tree.write('output.xml')
if __name__ == "__main__":
main(sys.argv)
#su xinmin 2014/2/17
import xml.etree.ElementTree as ET
import sys
def usage():
sys.stderr.write("""Usage: %(progName)s xmlfilename casename --d=true --t=false
Options:
--d=true
set dislplay true or false.
--t=false
set testable true or false.
""" % {
"progName": os.path.split(sys.argv[0])[1],
})
sys.exit(1)
def main(argv):
filename = argv[1]
casename = argv[2]
tree = ET.parse(filename)
root = tree.getroot()
i=3
while i<len(argv) and len(argv[i])>2 and argv[i][0:2] == "--":
arg = argv[i]
if arg.startswith("--d="):
try:
display = arg[len("--d="):]
except ValueError:
usage()
elif arg.startswith("--t="):
try:
test = arg[len("--t="):]
except ValueError:
usage()
else:
usage()
i += 1
for item in root.findall('item'):
if casename == item.find('CaseName').text:
item.set('Displayable',display)
item.set('Testable',test)
break
tree.write('output.xml')
if __name__ == "__main__":
main(sys.argv)