blob: 39508cf8a0bdf1bdd11abf6505487c2781cd6f5b [file] [log] [blame]
Dan Talaycod2ca1032010-03-10 14:40:26 -08001#!/usr/bin/env python
Dan Talaycof75360a2010-02-05 22:22:54 -08002"""This script reads struct
3
4Author ykk
5Date Jan 2010
6"""
7import sys
8import getopt
9import cpythonize
10import cheader
11
12def usage():
13 """Display usage
14 """
15 print "Usage "+sys.argv[0]+" <options> header_files... output_file\n"+\
16 "Options:\n"+\
17 "-h/--help\n\tPrint this usage guide\n"+\
18 ""
19
20#Parse options and arguments
21try:
22 opts, args = getopt.getopt(sys.argv[1:], "h",
23 ["help"])
24except getopt.GetoptError:
25 usage()
26 sys.exit(2)
27
28#Parse options
29for opt,arg in opts:
30 if (opt in ("-h","--help")):
31 usage()
32 sys.exit(0)
33 else:
34 print "Unhandled option :"+opt
35 sys.exit(2)
36
37#Check there is at least 1 input file with 1 output file
38if (len(args) < 2):
39 usage()
40 sys.exit(2)
41
42ch = cheader.cheaderfile(args[:-1])
43py = cpythonize.pythonizer(ch)
44fileRef = open(args[len(args)-1], "w")
45for l in py.pycode():
46 fileRef.write(l+"\n")
47fileRef.close()
48