import sys if(len(sys.argv) < 2) : print("Invalid usage: tc-generator ") sys.exit(-1) import re sites = sys.argv[1] name = re.match(r"(\S+).xml", sites) tc = name.group(1) + ".tc.data" sites_file = open(sites, 'r') tc_file = open(tc, 'w') from string import Template lines = sites_file.readlines() for line in lines : result = re.match(r"""(\s*)\n""", line) if(result != "" and result != None) : t = Template("$handle\techo\t/bin/echo\tINSTALLED\tINTEL32::LINUX\tnull\n\ $handle\tcat\t/bin/cat\tINSTALLED\tINTEL32::LINUX\tnull\n\ $handle\tls\t/bin/ls\t\tINSTALLED\tINTEL32::LINUX\tnull\n\ $handle\tgrep\t/bin/grep\tINSTALLED\tINTEL32::LINUX\tnull\n\ $handle\tsort\t/bin/sort\tINSTALLED\tINTEL32::LINUX\tnull\n\ $handle\tpaste\t/bin/paste\tINSTALLED\tINTEL32::LINUX\tnull\n") s = t.substitute({"handle":result.group(2)}) tc_file.write(s) tc_file.write("\n") tc_file.close() sites_file.close()