Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(170)

Side by Side Diff: third_party/WebKit/Source/devtools/scripts/CodeGeneratorFrontend.py

Issue 2035653005: DevTools: split protocol.json into files per domain. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2011 Google Inc. All rights reserved. 2 # Copyright (c) 2011 Google Inc. All rights reserved.
3 # Copyright (c) 2012 Intel Corporation. All rights reserved. 3 # Copyright (c) 2012 Intel Corporation. All rights reserved.
4 # 4 #
5 # Redistribution and use in source and binary forms, with or without 5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are 6 # modification, are permitted provided that the following conditions are
7 # met: 7 # met:
8 # 8 #
9 # * Redistributions of source code must retain the above copyright 9 # * Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer. 10 # notice, this list of conditions and the following disclaimer.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 if (len(arg_values) != 1): 46 if (len(arg_values) != 1):
47 raise Exception("Exactly one plain argument expected (found %s)" % len(a rg_values)) 47 raise Exception("Exactly one plain argument expected (found %s)" % len(a rg_values))
48 input_json_filename = arg_values[0] 48 input_json_filename = arg_values[0]
49 output_js_dirname = arg_options.output_js_dir 49 output_js_dirname = arg_options.output_js_dir
50 if not output_js_dirname: 50 if not output_js_dirname:
51 raise Exception("Output .js directory must be specified") 51 raise Exception("Output .js directory must be specified")
52 except Exception: 52 except Exception:
53 # Work with python 2 and 3 http://docs.python.org/py3k/howto/pyporting.html 53 # Work with python 2 and 3 http://docs.python.org/py3k/howto/pyporting.html
54 exc = sys.exc_info()[1] 54 exc = sys.exc_info()[1]
55 sys.stderr.write("Failed to parse command-line arguments: %s\n\n" % exc) 55 sys.stderr.write("Failed to parse command-line arguments: %s\n\n" % exc)
56 sys.stderr.write("Usage: <script> protocol.json --output_js_dir <output_js_d ir>\n") 56 sys.stderr.write("Usage: <script> some.json --output_js_dir <output_js_dir>\ n")
57 exit(1) 57 exit(1)
58 58
59 59
60 def fix_camel_case(name): 60 def fix_camel_case(name):
61 refined = re.sub(r'-(\w)', lambda pat: pat.group(1).upper(), name) 61 refined = re.sub(r'-(\w)', lambda pat: pat.group(1).upper(), name)
62 refined = to_title_case(refined) 62 refined = to_title_case(refined)
63 return re.sub(r'(?i)HTML|XML|WML|API', lambda pat: pat.group(0).upper(), ref ined) 63 return re.sub(r'(?i)HTML|XML|WML|API', lambda pat: pat.group(0).upper(), ref ined)
64 64
65 65
66 def to_title_case(name): 66 def to_title_case(name):
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 Generator.backend_js_domain_initializer_list.append("InspectorBackend.re gisterCommand(\"%s.%s\", [%s], %s, %s);\n" % (domain_name, json_command_name, js _parameters_text, js_reply_list, has_error_data_param)) 276 Generator.backend_js_domain_initializer_list.append("InspectorBackend.re gisterCommand(\"%s.%s\", [%s], %s, %s);\n" % (domain_name, json_command_name, js _parameters_text, js_reply_list, has_error_data_param))
277 277
278 Generator.go() 278 Generator.go()
279 279
280 backend_js_file = open(output_js_dirname + "/InspectorBackendCommands.js", "w") 280 backend_js_file = open(output_js_dirname + "/InspectorBackendCommands.js", "w")
281 281
282 backend_js_file.write(Templates.backend_js.substitute(None, 282 backend_js_file.write(Templates.backend_js.substitute(None,
283 domainInitializers="".join(Generator.backend_js_domain_initializer_list))) 283 domainInitializers="".join(Generator.backend_js_domain_initializer_list)))
284 284
285 backend_js_file.close() 285 backend_js_file.close()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698