parser.add_option("-o", "--output", dest="output",
help='output file', metavar="FILE")
parser.add_option("--mode", type="choice", metavar="<FUNCTIONS|S3PROTO|LIBPROTO|PARAMDEFS|PARAMTABLE>",
- choices=["FUNCTIONS", "S3PROTO", "LIBPROTO", "PARAMDEFS", "PARAMTABLE"], default="FUNCTIONS")
+ choices=["FUNCTIONS", "S3PROTO", "LIBPROTO", "PARAMDEFS", "PARAMTABLE"], default="FUNCTIONS")
parser.add_option("--scope", metavar="<GLOBAL|LOCAL>",
- choices = ["GLOBAL", "LOCAL"], default="GLOBAL")
+ choices=["GLOBAL", "LOCAL"], default="GLOBAL")
(options, args) = parser.parse_args()
if options.output is None:
parser.error("No output file specified")
+
def iterate_all(path):
"""Iterate and yield all the parameters.
"ustring" : "_STRING",
}
+
def generate_functions(path_in, path_out):
f = open(path_out, 'w')
try:
- f.write('/* This file was automatically generated by generate_param.py. DO NOT EDIT */\n\n')
- for parameter in iterate_all(options.filename):
+ f.write('/* This file was automatically generated by generate_param.py. DO NOT EDIT */\n\n')
+ for parameter in iterate_all(options.filename):
# filter out parameteric options
if ':' in parameter['name']:
continue
if temp is None:
raise Exception(parameter['name'] + " has an invalid param type " + parameter['type'])
output_string += temp
- f.write(output_string + "(" + parameter['function'] +", " + parameter['function'] + ')\n')
+ f.write(output_string + "(" + parameter['function'] + ", " + parameter['function'] + ')\n')
finally:
f.close()
'ustring' : 'char *',
}
+
def make_s3_param_proto(path_in, path_out):
file_out = open(path_out, 'w')
try:
output_string += 'const '
param_type = mapping.get(parameter['type'])
if param_type is None:
- raise Exception(parameter['name'] + " has an invalid context " + parameter['context'])
+ raise Exception(parameter['name'] + " has an invalid context " + parameter['context'])
output_string += param_type
output_string += "lp_%s" % parameter['function']
output_string += 'const '
param_type = mapping.get(parameter['type'])
if param_type is None:
- raise Exception(parameter['name'] + " has an invalid context " + parameter['context'])
+ raise Exception(parameter['name'] + " has an invalid context " + parameter['context'])
output_string += param_type
output_string += "lpcfg_%s" % parameter['function']
else:
raise Exception(parameter['name'] + " has an invalid param type " + parameter['type'])
-
file_out.write(output_string)
finally:
file_out.close()
+
def get_header(path):
header = os.path.basename(path).upper()
header = header.replace(".", "_").replace("\\", "_").replace("-", "_")
return "__%s__" % header
+
def make_param_defs(path_in, path_out, scope):
file_out = open(path_out, 'w')
try:
file_out.write("struct loadparm_service \n")
file_out.write("{\n")
file_out.write("\tbool autoloaded;\n")
-
+
for parameter in iterate_all(path_in):
# filter out parameteric options
if ':' in parameter['name']:
output_string = "\t"
param_type = mapping.get(parameter['type'])
if param_type is None:
- raise Exception(parameter['name'] + " has an invalid context " + parameter['context'])
+ raise Exception(parameter['name'] + " has an invalid context " + parameter['context'])
output_string += param_type
output_string += " %s;\n" % parameter['function']
"ustring" : "P_USTRING",
}
+
def make_param_table(path_in, path_out):
file_out = open(path_out, 'w')
try: