1 from __future__
import print_function
8 parser = argparse.ArgumentParser()
9 parser.add_argument(
'nodeids', help=
'path/to/NodeIds.csv')
10 parser.add_argument(
'outfile', help=
'outfile w/o extension')
11 args = parser.parse_args()
13 f = open(args.nodeids)
16 input_str = input_str.replace(
'\r',
'')
17 rows = map(
lambda x:tuple(x.split(
',')), input_str.split(
'\n'))
19 fh = open(args.outfile +
".h",
'w')
22 print(string, end=
'\n', file=fh)
24 printh(
'''/********************************************************** 25 * '''+args.outfile+
'''.hgen -- do not modify 26 ********************************************************** 27 * Generated from '''+args.nodeids+
''' with script '''+sys.argv[0]+
''' 28 * on host '''+platform.uname()[1]+
''' by user '''+getpass.getuser()+
''' at '''+
29 time.strftime(
"%Y-%m-%d %I:%M:%S")+
''' 30 **********************************************************/\n 31 #ifndef ''' + args.outfile.upper().split(
"/")[-1] +
'''_H_ 32 #define ''' + args.outfile.upper().split(
"/")[-1] +
'''_H_ 37 printh(
"#define BA_%s %s // %s" % (row[0].upper(), row[1], row[2]))
39 printh(
'\n#endif /* ' + args.outfile.upper().split(
"/")[-1] +
'_H_ */')