Synopsis:
Make a test code for getting the menu names from .csv file by using Python and save them for the definitions in .h.
1. Make a list by using spreadsheets such as Excel. In this case, I used NeoOffice.
2. Export the file as .csv.
%cat test.csv
"Greet","Execute","Start"
,,"Stop",
,,"Reset"
,"Status","Counts"
,,"Storage"
,,"Settings"
,,"GPS"
,,"Accel"
,"Setup","Filter"
%cat test.py
#! /usr/bin/env python
import re
file = open('test.csv')
text = file.read()
buf = ""
top = """enum MenuId {\n"""
bottom = """TOTALIDS \n};"""
buf = re.sub( "[^\w]+", ",\n\tmnu", text )
buf = top + buf[ 1: ] + bottom
print buf
%python test.py
enum MenuId {
mnuGreet,
mnuExecute,
mnuStart,
mnuStop,
mnuReset,
mnuStatus,
mnuCounts,
mnuStorage,
mnuSettings,
mnuGPS,
mnuAccel,
mnuSetup,
mnuFilter,
mnuTOTALIDS
};
No comments:
Post a Comment