From fe76b2f4c09bdd23c6fb710cf67a6c0497e2bf52 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Wed, 6 Aug 2014 14:50:27 +0200 Subject: [PATCH] Add an option to define the output file when generating the Python wrapper code. --- tools/python/apixml2python.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/python/apixml2python.py b/tools/python/apixml2python.py index 5459c1ac8..ee31c09c3 100755 --- a/tools/python/apixml2python.py +++ b/tools/python/apixml2python.py @@ -118,11 +118,10 @@ hand_written_functions = [ 'linphone_core_new_with_config' ] -def generate(apixmlfile): +def generate(apixmlfile, f): tree = ET.parse(apixmlfile) renderer = pystache.Renderer() m = LinphoneModule(tree, blacklisted_classes, blacklisted_events, blacklisted_functions, hand_written_functions) - f = open("linphone.c", "w") os.chdir('apixml2python') f.write(renderer.render(m)) @@ -131,9 +130,12 @@ def main(argv = None): if argv is None: argv = sys.argv argparser = argparse.ArgumentParser(description="Generate a Python wrapper of the Linphone API.") + argparser.add_argument('-o', '--outputfile', metavar='outputfile', type=argparse.FileType('w'), help="Output C file containing the code of the Python wrapper.") argparser.add_argument('apixmlfile', help="XML file of the Linphone API generated by genapixml.py.") args = argparser.parse_args() - generate(args.apixmlfile) + if args.outputfile == None: + args.outputfile = open('linphone.c', 'w') + generate(args.apixmlfile, args.outputfile) if __name__ == "__main__": sys.exit(main())