MCPcopy Index your code
hub / github.com/SeleniumHQ/selenium / generate_java_source

Function generate_java_source

javascript/private/gen_file.py:150–189  ·  view source on GitHub ↗
(file_name, out, preamble, js_map)

Source from the content-addressed store, hash-verified

148
149
150def generate_java_source(file_name, out, preamble, js_map):
151 if not file_name.endswith(".java"):
152 raise RuntimeError("File name must end in .java")
153 class_name = os.path.basename(file_name[:-5])
154
155 out.write(_copyright)
156 out.write("\n")
157 out.write(preamble)
158 out.write("")
159 out.write(
160 f"""
161public enum {class_name} {{
162
163 // AUTO GENERATED - DO NOT EDIT BY HAND
164"""
165 )
166
167 for name, file in js_map.items():
168 contents = open(file).read()
169 write_atom_literal(out, name, contents, "java", True)
170
171 out.write(
172 f"""
173 ;
174 private final String value;
175
176 public String getValue() {{
177 return value;
178 }}
179
180 public String toString() {{
181 return getValue();
182 }}
183
184 {class_name}(String value) {{
185 this.value = value;
186 }}
187}}
188"""
189 )
190
191
192def main(argv=[]):

Callers 1

mainFunction · 0.85

Calls 3

write_atom_literalFunction · 0.85
readMethod · 0.65
writeMethod · 0.45

Tested by

no test coverage detected