Debian Codegraph @

tests/syntax/compare_data.py

raw symbols SCIP
1 import data_3_6
2 import data_3_7
3 import data_3_8
4 import data_3_9
5 import data_3_10
6
7 info_36 = data_3_6.info
8 info_37 = data_3_7.info
9 info_38 = data_3_8.info
10 info_39 = data_3_9.info
11 info_310 = data_3_10.info
12
13 output = open("compare_data.html", "w", encoding="utf8")
14
15 output.write("<div>\n")
16 files = set([])
17
18
19 def print_different(filename, in_36, in_37, in_38, in_39, in_310, topic):
20 # Just tracking changes going forward in time, from
21 # one version to the next.
22 if topic == "message":
23 header = "<h5>Different messages - from Python</h5>\n"
24 else:
25 header = "<h5>Different explanation - by Friendly-traceback</h5>\n"
26 header_added = False
27
28 inputs = {in_36, in_37, in_38, in_39, in_310}
29
30 if in_36 != in_37:
31 if filename not in files:
32 output.write("<div class='filename-header'>\n")
33 files.add(filename)
34 output.write(filename)
35 output.write("</div>\n")
36 if not header_added:
37 output.write(header)
38 header_added = True
39 output.write("<pre class='highlight friendly-small-pre'>")
40 output.write("<b>3.6: </b>" + in_36 + "\n")
41 output.write("<b>3.7: </b>" + in_37 + "\n")
42 output.write("</pre>\n")
43 inputs.remove(in_36)
44 inputs.remove(in_37)
45 if in_37 != in_38:
46 if filename not in files:
47 output.write("<div class='filename-header'>\n")
48 files.add(filename)
49 output.write(filename)
50 output.write("</div>\n")
51 if not header_added:
52 output.write(header)
53 header_added = True
54 output.write("<pre class='highlight friendly-small-pre'>")
55 if in_37 in inputs:
56 output.write("<b>3.7: </b>" + in_37 + "\n")
57 inputs.remove(in_37)
58 output.write("<b>3.8: </b>" + in_38 + "\n")
59 output.write("</pre>\n")
60 inputs.remove(in_38)
61 if in_38 != in_39:
62 if filename not in files:
63 output.write("<div class='filename-header'>")
64 files.add(filename)
65 output.write(filename)
66 output.write("</div>\n")
67 if not header_added:
68 output.write(header)
69 header_added = True
70 output.write("<pre class='highlight friendly-small-pre'>")
71 if in_38 in inputs:
72 output.write("<b>3.8: </b>" + in_38 + "\n")
73 inputs.remove(in_38)
74 output.write("<b>3.9: </b>" + in_39 + "\n")
75 output.write("</pre>\n")
76 try:
77 inputs.remove(in_39)
78 except KeyError:
79 pass
80 if in_39 != in_310:
81 if filename not in files:
82 output.write("<div class='filename-header'>")
83 files.add(filename)
84 output.write(filename)
85 output.write("</div>\n")
86 if not header_added:
87 output.write(header)
88 output.write("<pre class='highlight friendly-small-pre'>")
89 if in_39 in inputs:
90 output.write("<b>3.9: </b>" + in_39 + "\n")
91 inputs.remove(in_39)
92 output.write("<b>3.10: </b>" + in_310 + "\n")
93 output.write("</pre>\n")
94 try:
95 inputs.remove(in_310)
96 except KeyError:
97 pass
98
99
100 all_names = (
101 set(info_36.keys())
102 | set(info_37.keys())
103 | set(info_38.keys())
104 | set(info_39.keys())
105 | set(info_310.keys())
106 )
107
108 not_an_error = (
109 "Either not a SyntaxError for this Python version,"
110 " or case excluded for some other reason."
111 )
112
113
114 for filename in all_names:
115 if filename in info_36:
116 data_36 = info_36[filename]
117 else:
118 data_36 = {
119 "message": not_an_error,
120 "cause": not_an_error,
121 }
122
123 if filename in info_37:
124 data_37 = info_37[filename]
125 else:
126 data_37 = {
127 "message": not_an_error,
128 "cause": not_an_error,
129 }
130
131 if filename in info_38:
132 data_38 = info_38[filename]
133 else:
134 data_38 = {
135 "message": not_an_error,
136 "cause": not_an_error,
137 }
138
139 if filename in info_39:
140 data_39 = info_39[filename]
141 else:
142 data_39 = {
143 "message": not_an_error,
144 "cause": not_an_error,
145 }
146
147 if filename in info_310:
148 data_310 = info_310[filename]
149 else:
150 data_310 = {
151 "message": not_an_error,
152 "cause": not_an_error,
153 }
154
155 # attempt = "I will attempt to be give a bit more information."
156 # guess = "guess what caused the problem, but I might be wrong."
157 # for data in [data_36, data_37, data_38, data_39, data_310]:
158 # if "cause" in data and data["cause"]:
159 # if attempt in data["cause"]:
160 # data["cause"] = data["cause"].split(attempt)[1]
161 # if guess in data["cause"]:
162 # data["cause"] = data["cause"].split(guess)[1]
163 # data["cause"] = data["cause"].strip()
164
165 print_different(
166 filename,
167 data_36["message"],
168 data_37["message"],
169 data_38["message"],
170 data_39["message"],
171 data_310["message"],
172 "message",
173 )
174 print_different(
175 filename,
176 data_36["cause"],
177 data_37["cause"],
178 data_38["cause"],
179 data_39["cause"],
180 data_310["cause"],
181 "explanation",
182 )
183
184 output.write("</div>\n")
185 output.close()