From 9007b8127ae122869fb2c818bdd6d8c7e4499b45 Mon Sep 17 00:00:00 2001 From: Jarkko Vatjus-Anttila Date: Thu, 4 Aug 2011 14:17:28 +0300 Subject: [PATCH] Added simply getopt support for tundra2-txml-convertes now -i|--input= and -o|--output= params are accepted --- tools/tundra2-txml-converter.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/tools/tundra2-txml-converter.py b/tools/tundra2-txml-converter.py index 708fba2e05..52a83d4426 100644 --- a/tools/tundra2-txml-converter.py +++ b/tools/tundra2-txml-converter.py @@ -86,10 +86,29 @@ def getNewValue(self): if __name__ == "__main__": - fileName = "putFileNameHere.txml" - newFileName = fileName[:fileName.index(".txml")] + "_.txml" + try: + import getopt + try: + opts, args = getopt.getopt(sys.argv[1:], "i:o:", ["input=", "output="]) + except getopt.GetoptError, err: + # print help information and exit: + print str(err) + print "Usage: tundra2-txml-converter.py [-i|--input=inputTXML] [-o|--output=outputTXML]" + sys.exit(2) + # Set defaults first: + fileName = "putFileNameHere.txml" + newFileName = fileName[:fileName.index(".txml")] + "_.txml" + for o, a in opts: + if o in ("-i", "--input"): + fileName = a + elif o in ("-o", "--output"): + newFileName = a + except ImportError: + fileName = "putFileNameHere.txml" + newFileName = fileName[:fileName.index(".txml")] + "_.txml" c = getFileContent(fileName) + if c == None: sys.exit(2) lines = c.splitlines(True) parentName = "GeneratedGrandParentEntity"