3131
3232class BzSchemaProcessingException (Exception ):
3333 def __init__ (self , errors ):
34- message = 'foobar' #' <br />\n'.join(errors)
34+ message = '<br />\n ' .join (errors )
3535 super ().__init__ (message )
3636 self .message = message
3737 self .errors = errors
@@ -384,8 +384,8 @@ def output_schema(schema, remarks, colours, bugzilla_versions):
384384 ' ' , [process (r , bugzilla_versions , dict ) for r in thisremarks ]
385385 )
386386 tables_table_rows .append (
387- ( '<th%s><a href="#table-%s">%s</a></th>\n \n ' % (colour , table , table ) )
388- + ( ' <td%s>%s</td>\n \n ' % (colour , remark ) )
387+ '<th%s><a href="#table-%s">%s</a></th>\n \n ' % (colour , table , table )
388+ + ' <td%s>%s</td>\n \n ' % (colour , remark )
389389 )
390390 quick_tables_table_rows .append (
391391 '<th%s><a href="#table-%s">%s</a></th>\n \n ' % (colour , table , table )
@@ -787,13 +787,15 @@ def get_versioned_tables(first, last):
787787 if not first in schema_remarks .version_schema_map :
788788 raise BzSchemaProcessingException (
789789 [
790- f"I know version '{ first } ' exists, but I seem to be missing the data for it."
790+ f"I know version '{ first } ' exists, but I seem to be missing the data"
791+ " for it."
791792 ]
792793 )
793794 if not last in schema_remarks .version_schema_map :
794795 raise BzSchemaProcessingException (
795796 [
796- f"I know version '{ last } ' exists, but I seem to be missing the data for it."
797+ f"I know version '{ last } ' exists, but I seem to be missing the data"
798+ " for it."
797799 ]
798800 )
799801 schema_name = schema_remarks .version_schema_map [first ]
@@ -872,10 +874,12 @@ def make_tables(first, last):
872874 raise BzSchemaProcessingException (errors )
873875 return (header , body , footer )
874876
877+
875878def make_body (first , last ):
876879 (header , body , footer ) = make_tables (first , last )
877880 return body
878881
882+
879883def write_file (first , last , file ):
880884 # file = open(filename, 'w')
881885 # file is an already-open filehandle
@@ -983,27 +987,138 @@ def generate_schema_remarks(args):
983987 case _:
984988 print (f"Unhandled error: { error } " )
985989 var_dict = {
986- 'version_order' : format_str ('version_order = %s' % pformat (schema_remarks .version_order ), mode = FileMode (string_normalization = False ,experimental_string_processing = True )),
987- 'default_first_version' : format_str ('default_first_version = %s' % pformat (schema_remarks .default_first_version ), mode = FileMode (string_normalization = False ,experimental_string_processing = True )),
988- 'default_last_version' : format_str ('default_last_version = %s' % pformat (schema_remarks .default_last_version ), mode = FileMode (string_normalization = False ,experimental_string_processing = True )),
989- 'version_schema_map' : format_str ('version_schema_map = %s' % pformat (schema_remarks .version_schema_map ), mode = FileMode (string_normalization = False ,experimental_string_processing = True )),
990- 'version_remark' : format_str ('version_remark = %s' % pformat (schema_remarks .version_remark ), mode = FileMode (string_normalization = False ,experimental_string_processing = True )),
991- 'table_remark' : format_str ('table_remark = %s' % pformat (schema_remarks .table_remark ), mode = FileMode (string_normalization = False ,experimental_string_processing = True )),
992- 'table_added_remark' : format_str ('table_added_remark = %s' % pformat (schema_remarks .table_added_remark ), mode = FileMode (string_normalization = False ,experimental_string_processing = True )),
993- 'table_removed_remark' : format_str ('table_removed_remark = %s' % pformat (schema_remarks .table_removed_remark ), mode = FileMode (string_normalization = False ,experimental_string_processing = True )),
994- 'column_remark' : format_str ('column_remark = %s' % pformat (schema_remarks .column_remark ), mode = FileMode (string_normalization = False ,experimental_string_processing = True )),
995- 'column_renamed' : format_str ('column_renamed = %s' % pformat (schema_remarks .column_renamed ), mode = FileMode (string_normalization = False ,experimental_string_processing = True )),
996- 'column_added_remark' : format_str ('column_added_remark = %s' % pformat (schema_remarks .column_added_remark ), mode = FileMode (string_normalization = False ,experimental_string_processing = True )),
997- 'column_removed_remark' : format_str ('column_removed_remark = %s' % pformat (schema_remarks .column_removed_remark ), mode = FileMode (string_normalization = False ,experimental_string_processing = True )),
998- 'index_remark' : format_str ('index_remark = %s' % pformat (schema_remarks .index_remark ), mode = FileMode (string_normalization = False ,experimental_string_processing = True )),
999- 'index_renamed' : format_str ('index_renamed = %s' % pformat (schema_remarks .index_renamed ), mode = FileMode (string_normalization = False ,experimental_string_processing = True )),
1000- 'index_removed_remark' : format_str ('index_removed_remark = %s' % pformat (schema_remarks .index_removed_remark ), mode = FileMode (string_normalization = False ,experimental_string_processing = True )),
1001- 'index_added_remark' : format_str ('index_added_remark = %s' % pformat (schema_remarks .index_added_remark ), mode = FileMode (string_normalization = False ,experimental_string_processing = True )),
1002- 'notation_guide' : format_str ('notation_guide = %s' % pformat (schema_remarks .notation_guide ), mode = FileMode (string_normalization = False ,experimental_string_processing = True )),
1003- 'header' : format_str ('header = %s' % pformat (schema_remarks .header ), mode = FileMode (string_normalization = False ,experimental_string_processing = True )),
1004- 'footer' : format_str ('footer = %s' % pformat (schema_remarks .footer ), mode = FileMode (string_normalization = False ,experimental_string_processing = True )),
1005- 'prelude' : format_str ('prelude = %s' % pformat (schema_remarks .prelude ), mode = FileMode (string_normalization = False ,experimental_string_processing = True )),
1006- 'afterword' : format_str ('afterword = %s' % pformat (schema_remarks .afterword ), mode = FileMode (string_normalization = False ,experimental_string_processing = True )),
990+ 'version_order' : format_str (
991+ 'version_order = %s' % pformat (schema_remarks .version_order ),
992+ mode = FileMode (
993+ string_normalization = False , experimental_string_processing = True
994+ ),
995+ ),
996+ 'default_first_version' : format_str (
997+ 'default_first_version = %s'
998+ % pformat (schema_remarks .default_first_version ),
999+ mode = FileMode (
1000+ string_normalization = False , experimental_string_processing = True
1001+ ),
1002+ ),
1003+ 'default_last_version' : format_str (
1004+ 'default_last_version = %s'
1005+ % pformat (schema_remarks .default_last_version ),
1006+ mode = FileMode (
1007+ string_normalization = False , experimental_string_processing = True
1008+ ),
1009+ ),
1010+ 'version_schema_map' : format_str (
1011+ 'version_schema_map = %s' % pformat (schema_remarks .version_schema_map ),
1012+ mode = FileMode (
1013+ string_normalization = False , experimental_string_processing = True
1014+ ),
1015+ ),
1016+ 'version_remark' : format_str (
1017+ 'version_remark = %s' % pformat (schema_remarks .version_remark ),
1018+ mode = FileMode (
1019+ string_normalization = False , experimental_string_processing = True
1020+ ),
1021+ ),
1022+ 'table_remark' : format_str (
1023+ 'table_remark = %s' % pformat (schema_remarks .table_remark ),
1024+ mode = FileMode (
1025+ string_normalization = False , experimental_string_processing = True
1026+ ),
1027+ ),
1028+ 'table_added_remark' : format_str (
1029+ 'table_added_remark = %s' % pformat (schema_remarks .table_added_remark ),
1030+ mode = FileMode (
1031+ string_normalization = False , experimental_string_processing = True
1032+ ),
1033+ ),
1034+ 'table_removed_remark' : format_str (
1035+ 'table_removed_remark = %s'
1036+ % pformat (schema_remarks .table_removed_remark ),
1037+ mode = FileMode (
1038+ string_normalization = False , experimental_string_processing = True
1039+ ),
1040+ ),
1041+ 'column_remark' : format_str (
1042+ 'column_remark = %s' % pformat (schema_remarks .column_remark ),
1043+ mode = FileMode (
1044+ string_normalization = False , experimental_string_processing = True
1045+ ),
1046+ ),
1047+ 'column_renamed' : format_str (
1048+ 'column_renamed = %s' % pformat (schema_remarks .column_renamed ),
1049+ mode = FileMode (
1050+ string_normalization = False , experimental_string_processing = True
1051+ ),
1052+ ),
1053+ 'column_added_remark' : format_str (
1054+ 'column_added_remark = %s'
1055+ % pformat (schema_remarks .column_added_remark ),
1056+ mode = FileMode (
1057+ string_normalization = False , experimental_string_processing = True
1058+ ),
1059+ ),
1060+ 'column_removed_remark' : format_str (
1061+ 'column_removed_remark = %s'
1062+ % pformat (schema_remarks .column_removed_remark ),
1063+ mode = FileMode (
1064+ string_normalization = False , experimental_string_processing = True
1065+ ),
1066+ ),
1067+ 'index_remark' : format_str (
1068+ 'index_remark = %s' % pformat (schema_remarks .index_remark ),
1069+ mode = FileMode (
1070+ string_normalization = False , experimental_string_processing = True
1071+ ),
1072+ ),
1073+ 'index_renamed' : format_str (
1074+ 'index_renamed = %s' % pformat (schema_remarks .index_renamed ),
1075+ mode = FileMode (
1076+ string_normalization = False , experimental_string_processing = True
1077+ ),
1078+ ),
1079+ 'index_removed_remark' : format_str (
1080+ 'index_removed_remark = %s'
1081+ % pformat (schema_remarks .index_removed_remark ),
1082+ mode = FileMode (
1083+ string_normalization = False , experimental_string_processing = True
1084+ ),
1085+ ),
1086+ 'index_added_remark' : format_str (
1087+ 'index_added_remark = %s' % pformat (schema_remarks .index_added_remark ),
1088+ mode = FileMode (
1089+ string_normalization = False , experimental_string_processing = True
1090+ ),
1091+ ),
1092+ 'notation_guide' : format_str (
1093+ 'notation_guide = %s' % pformat (schema_remarks .notation_guide ),
1094+ mode = FileMode (
1095+ string_normalization = False , experimental_string_processing = True
1096+ ),
1097+ ),
1098+ 'header' : format_str (
1099+ 'header = %s' % pformat (schema_remarks .header ),
1100+ mode = FileMode (
1101+ string_normalization = False , experimental_string_processing = True
1102+ ),
1103+ ),
1104+ 'footer' : format_str (
1105+ 'footer = %s' % pformat (schema_remarks .footer ),
1106+ mode = FileMode (
1107+ string_normalization = False , experimental_string_processing = True
1108+ ),
1109+ ),
1110+ 'prelude' : format_str (
1111+ 'prelude = %s' % pformat (schema_remarks .prelude ),
1112+ mode = FileMode (
1113+ string_normalization = False , experimental_string_processing = True
1114+ ),
1115+ ),
1116+ 'afterword' : format_str (
1117+ 'afterword = %s' % pformat (schema_remarks .afterword ),
1118+ mode = FileMode (
1119+ string_normalization = False , experimental_string_processing = True
1120+ ),
1121+ ),
10071122 }
10081123
10091124 with open ('schema_remarks_template.txt' , 'r' ) as infile :
@@ -1012,7 +1127,10 @@ def generate_schema_remarks(args):
10121127 output = template .format (** var_dict )
10131128 outfile .write (output )
10141129 print ("Wrote changes to schema_remarks_new.py." )
1015- print ("diff the changes from schema_remarks.py and if you like them, move it overtop of it." )
1130+ print (
1131+ "diff the changes from schema_remarks.py and if you like them, move it"
1132+ " overtop of it."
1133+ )
10161134 sys .exit ()
10171135 print ("No changes detected." )
10181136
@@ -1021,7 +1139,8 @@ def validate_schema_remarks(args):
10211139 for v in schema_remarks .version_order :
10221140 if not v in schema_remarks .version_schema_map :
10231141 errors .append (
1024- f"Version { v } found in version_order is not listed in version_schema_map"
1142+ f"Version { v } found in version_order is not listed in"
1143+ " version_schema_map"
10251144 )
10261145 if len ([item for item in schema_remarks .version_remark if item [0 ] == v ]) < 1 :
10271146 errors .append (
@@ -1030,11 +1149,13 @@ def validate_schema_remarks(args):
10301149 for v in schema_remarks .version_schema_map .keys ():
10311150 if not v in schema_remarks .version_order :
10321151 errors .append (
1033- f"Version { v } found in version_schema_map is not listed in version_order"
1152+ f"Version { v } found in version_schema_map is not listed in"
1153+ " version_order"
10341154 )
10351155 if len ([item for item in schema_remarks .version_remark if item [0 ] == v ]) < 1 :
10361156 errors .append (
1037- f"Version { v } found in version_schema_map is not listed in version_remark"
1157+ f"Version { v } found in version_schema_map is not listed in"
1158+ " version_remark"
10381159 )
10391160 for item in schema_remarks .version_remark :
10401161 v = item [0 ]
@@ -1044,7 +1165,8 @@ def validate_schema_remarks(args):
10441165 )
10451166 if not v in schema_remarks .version_schema_map :
10461167 errors .append (
1047- f"Version { v } found in version_remark is not listed in version_schema_map"
1168+ f"Version { v } found in version_remark is not listed in"
1169+ " version_schema_map"
10481170 )
10491171 if errors :
10501172 print (str .join ('\n ' , errors ))
@@ -1065,19 +1187,30 @@ def validate_schema_remarks(args):
10651187 parser_validate = subparsers .add_parser (
10661188 'validate' ,
10671189 help = 'Validate that the version-related lists are in sync with each other' ,
1068- description = 'Validate that the version-related lists are in sync with each other' ,
1190+ description = (
1191+ 'Validate that the version-related lists are in sync with each other'
1192+ ),
10691193 )
10701194 parser_validate .set_defaults (func = validate_schema_remarks )
10711195 parser_test = subparsers .add_parser (
10721196 'test' ,
1073- help = 'Test schema document generation. By default it only prints errors or a success message.' ,
1074- description = 'Test schema document generation. By default it only prints errors or a success message.' ,
1197+ help = (
1198+ 'Test schema document generation. By default it only prints errors or a'
1199+ ' success message.'
1200+ ),
1201+ description = (
1202+ 'Test schema document generation. By default it only prints errors or a'
1203+ ' success message.'
1204+ ),
10751205 )
10761206 parser_test .add_argument (
10771207 'first' ,
10781208 metavar = "first" ,
10791209 choices = schema_remarks .version_order ,
1080- help = "The starting version of the schemas to compare, or the single version to display if 'last' is not provided." ,
1210+ help = (
1211+ "The starting version of the schemas to compare, or the single version to"
1212+ " display if 'last' is not provided."
1213+ ),
10811214 )
10821215 parser_test .add_argument (
10831216 'last' ,
@@ -1092,19 +1225,35 @@ def validate_schema_remarks(args):
10921225 dest = "file" ,
10931226 metavar = 'FILENAME' ,
10941227 type = argparse .FileType ('w' ),
1095- help = "A file to write the generated schema doc to. Passing - will write it to standard out." ,
1228+ help = (
1229+ "A file to write the generated schema doc to. Passing - will write it to"
1230+ " standard out."
1231+ ),
10961232 )
10971233 parser_test .set_defaults (func = test_schema_remarks )
10981234 parser_generate = subparsers .add_parser (
10991235 'generate' ,
1100- help = 'Add all of the missing remarks from a new schema to schema_remarks.py for you as TODO items.' ,
1101- description = 'Add all of the missing remarks from a new schema to schema_remarks.py for you to as TODO items. Saves you the trouble of searching through the massive file looking for the right spot in alphabetical order to put them. Two benefits: gets a schema live faster (just without things documented), and you can search for TODO in the file to find the things that need updating.' ,
1236+ help = (
1237+ 'Add all of the missing remarks from a new schema to schema_remarks.py for'
1238+ ' you as TODO items.'
1239+ ),
1240+ description = (
1241+ 'Add all of the missing remarks from a new schema to schema_remarks.py for'
1242+ ' you to as TODO items. Saves you the trouble of searching through the'
1243+ ' massive file looking for the right spot in alphabetical order to put'
1244+ ' them. Two benefits: gets a schema live faster (just without things'
1245+ ' documented), and you can search for TODO in the file to find the things'
1246+ ' that need updating.'
1247+ ),
11021248 )
11031249 parser_generate .add_argument (
11041250 'first' ,
11051251 metavar = "first" ,
11061252 choices = schema_remarks .version_order ,
1107- help = "The starting version of the schemas to compare, or the single version to display if 'last' is not provided." ,
1253+ help = (
1254+ "The starting version of the schemas to compare, or the single version to"
1255+ " display if 'last' is not provided."
1256+ ),
11081257 )
11091258 parser_generate .add_argument (
11101259 'last' ,
0 commit comments