@@ -38,7 +38,7 @@ def write_atom_literal(out, name, contents, lang, utf8):
3838 else :
3939 line_format = " L\" {}\" ,\n "
4040 elif "java" == lang :
41- line_format = " .append\(\" {}\" )\n "
41+ line_format = " .append\\ (\" {}\" )\n "
4242 else :
4343 raise RuntimeError ("Unknown language: %s " % lang )
4444
@@ -47,7 +47,7 @@ def write_atom_literal(out, name, contents, lang, utf8):
4747 if "cc" == lang or "hh" == lang :
4848 string_type = "std::string" if utf8 else "std::wstring"
4949 char_type = "char" if utf8 else "wchar_t"
50- out .write ("const %s * const %s [] = {\n " % (char_type , name ))
50+ out .write ("const {} * const {} [] = {{ \n " . format (char_type , name ))
5151 elif "java" == lang :
5252 out .write (" %s(new StringBuilder()\n " % name )
5353 else :
@@ -75,43 +75,43 @@ def write_atom_literal(out, name, contents, lang, utf8):
7575def generate_header (file_name , out , js_map , just_declare , utf8 ):
7676 define_guard = "WEBDRIVER_%s" % os .path .basename (file_name .upper ()).replace ("." , "_" )
7777 include_stddef = "" if utf8 else "\n #include <stddef.h> // For wchar_t."
78- out .write ("""%s
78+ out .write ("""{}
7979
8080/* AUTO GENERATED - DO NOT EDIT BY HAND */
81- #ifndef %s
82- #define %s
83- %s
81+ #ifndef {}
82+ #define {}
83+ {}
8484#include <string> // For std::(w)string.
8585
86- namespace webdriver {
87- namespace atoms {
86+ namespace webdriver {{
87+ namespace atoms {{
8888
89- """ % (_copyright , define_guard , define_guard , include_stddef ))
89+ """ . format (_copyright , define_guard , define_guard , include_stddef ))
9090
9191 string_type = "std::string" if utf8 else "std::wstring"
9292 char_type = "char" if utf8 else "wchar_t"
9393
9494 for (name , file ) in js_map .items ():
9595 if just_declare :
96- out .write ("extern const %s * const %s [];\n " % (char_type , name .upper ()))
96+ out .write ("extern const {} * const {} [];\n " . format (char_type , name .upper ()))
9797 else :
98- contents = open (file , "r" ).read ()
98+ contents = open (file ).read ()
9999 write_atom_literal (out , name , contents , "hh" , utf8 )
100100
101101 out .write ("""
102- static inline %s asString(const %s * const atom[]) {
103- %s source;
104- for (int i = 0; atom[i] != NULL; i++) {
102+ static inline {} asString(const {} * const atom[]) { {
103+ {} source;
104+ for (int i = 0; atom[i] != NULL; i++) {{
105105 source += atom[i];
106- }
106+ }}
107107 return source;
108- }
108+ }}
109109
110- } // namespace atoms
111- } // namespace webdriver
110+ }} // namespace atoms
111+ }} // namespace webdriver
112112
113- #endif // %s
114- """ % (string_type , char_type , string_type , define_guard ))
113+ #endif // {}
114+ """ . format (string_type , char_type , string_type , define_guard ))
115115
116116def generate_cc_source (out , js_map , utf8 ):
117117 out .write ("""%s
@@ -127,7 +127,7 @@ def generate_cc_source(out, js_map, utf8):
127127""" % _copyright )
128128
129129 for (name , file ) in js_map .items ():
130- contents = open (file , "r" ).read ()
130+ contents = open (file ).read ()
131131 write_atom_literal (out , name , contents , "cc" , utf8 )
132132
133133 out .write ("""
@@ -152,7 +152,7 @@ def generate_java_source(file_name, out, preamble, js_map):
152152""" % class_name )
153153
154154 for (name , file ) in js_map .items ():
155- contents = open (file , "r" ).read ()
155+ contents = open (file ).read ()
156156 write_atom_literal (out , name , contents , "java" , True )
157157
158158 out .write ("""
0 commit comments