MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / generate_java_source

Function generate_java_source

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

Source from the content-addressed store, hash-verified

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