PEP8: fix E303: too many blank lines (2)
[sfrench/samba-autobuild/.git] / script / generate_param.py
index d31507c9cfc1dac7edea85bd2d62a10ca1cd5212..34930494ba374f42ee4cf4880cdb66c7be7a1296 100644 (file)
@@ -36,9 +36,9 @@ parser.add_option("-f", "--file", dest="filename",
 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()
 
@@ -47,6 +47,7 @@ if options.filename is None:
 if options.output is None:
     parser.error("No output file specified")
 
+
 def iterate_all(path):
     """Iterate and yield all the parameters. 
 
@@ -116,11 +117,12 @@ param_type_dict = {
                     "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
@@ -142,7 +144,7 @@ def generate_functions(path_in, path_out):
             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()
 
@@ -160,6 +162,7 @@ mapping = {
             'ustring'      : 'char *',
           }
 
+
 def make_s3_param_proto(path_in, path_out):
     file_out = open(path_out, 'w')
     try:
@@ -181,7 +184,7 @@ def make_s3_param_proto(path_in, path_out):
                 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']
 
@@ -231,7 +234,7 @@ def make_lib_proto(path_in, path_out):
                 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']
@@ -251,16 +254,17 @@ def make_lib_proto(path_in, path_out):
                 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:
@@ -282,7 +286,7 @@ def make_param_defs(path_in, path_out, scope):
             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']:
@@ -297,7 +301,7 @@ def make_param_defs(path_in, path_out, scope):
             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']
@@ -324,6 +328,7 @@ type_dict = {
               "ustring"      : "P_USTRING",
             }
 
+
 def make_param_table(path_in, path_out):
     file_out = open(path_out, 'w')
     try: