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

Side by Side Diff: third_party/WebKit/Source/platform/inspector_protocol/CodeGenerator.py

Issue 2420423002: [DevTools] pass v8_inspector_js_protocol as default for .imported.path in conf (Closed)
Patch Set: Created 4 years, 2 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 # Copyright 2016 The Chromium Authors. All rights reserved. 1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import os.path 5 import os.path
6 import sys 6 import sys
7 import optparse 7 import optparse
8 import collections 8 import collections
9 import functools 9 import functools
10 try: 10 try:
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 if optional_key.find(".") == -1 and optional_key not in keys: 45 if optional_key.find(".") == -1 and optional_key not in keys:
46 keys.append(optional_key) 46 keys.append(optional_key)
47 values.append(defaults[optional]) 47 values.append(defaults[optional])
48 return collections.namedtuple('X', keys)(*values) 48 return collections.namedtuple('X', keys)(*values)
49 49
50 try: 50 try:
51 cmdline_parser = optparse.OptionParser() 51 cmdline_parser = optparse.OptionParser()
52 cmdline_parser.add_option("--output_base") 52 cmdline_parser.add_option("--output_base")
53 cmdline_parser.add_option("--jinja_dir") 53 cmdline_parser.add_option("--jinja_dir")
54 cmdline_parser.add_option("--config") 54 cmdline_parser.add_option("--config")
55 cmdline_parser.add_option("--imported_protocol_path")
dgozman 2016/10/17 19:16:38 I don't really like this parameter being that spec
55 arg_options, _ = cmdline_parser.parse_args() 56 arg_options, _ = cmdline_parser.parse_args()
56 jinja_dir = arg_options.jinja_dir 57 jinja_dir = arg_options.jinja_dir
57 if not jinja_dir: 58 if not jinja_dir:
58 raise Exception("jinja directory must be specified") 59 raise Exception("jinja directory must be specified")
59 output_base = arg_options.output_base 60 output_base = arg_options.output_base
60 if not output_base: 61 if not output_base:
61 raise Exception("Base output directory must be specified") 62 raise Exception("Base output directory must be specified")
62 config_file = arg_options.config 63 config_file = arg_options.config
63 if not config_file: 64 if not config_file:
64 raise Exception("Config file name must be specified") 65 raise Exception("Config file name must be specified")
66 imported_protocol_path = arg_options.imported_protocol_path
65 config_base = os.path.dirname(config_file) 67 config_base = os.path.dirname(config_file)
66 except Exception: 68 except Exception:
67 # Work with python 2 and 3 http://docs.python.org/py3k/howto/pyporting.h tml 69 # Work with python 2 and 3 http://docs.python.org/py3k/howto/pyporting.h tml
68 exc = sys.exc_info()[1] 70 exc = sys.exc_info()[1]
69 sys.stderr.write("Failed to parse command-line arguments: %s\n\n" % exc) 71 sys.stderr.write("Failed to parse command-line arguments: %s\n\n" % exc)
70 exit(1) 72 exit(1)
71 73
72 try: 74 try:
73 config_json_file = open(config_file, "r") 75 config_json_file = open(config_file, "r")
74 config_json_string = config_json_file.read() 76 config_json_string = config_json_file.read()
75 config_partial = json_to_object(config_json_string, output_base, config_ base) 77 config_partial = json_to_object(config_json_string, output_base, config_ base)
76 config_json_file.close() 78 config_json_file.close()
77 defaults = { 79 defaults = {
78 ".imported": False, 80 ".imported": False,
79 ".imported.export_macro": "", 81 ".imported.export_macro": "",
80 ".imported.export_header": False, 82 ".imported.export_header": False,
81 ".imported.header": False, 83 ".imported.header": False,
82 ".imported.package": False, 84 ".imported.package": False,
83 ".protocol.export_macro": "", 85 ".protocol.export_macro": "",
84 ".protocol.export_header": False, 86 ".protocol.export_header": False,
85 ".exported": False, 87 ".exported": False,
86 ".exported.export_macro": "", 88 ".exported.export_macro": "",
87 ".exported.export_header": False, 89 ".exported.export_header": False,
88 ".lib": False, 90 ".lib": False,
89 ".lib.export_macro": "", 91 ".lib.export_macro": "",
90 ".lib.export_header": False, 92 ".lib.export_header": False,
91 } 93 }
94 if imported_protocol_path:
95 defaults[".imported.path"] = imported_protocol_path
92 return (jinja_dir, config_file, init_defaults(config_partial, "", defaul ts)) 96 return (jinja_dir, config_file, init_defaults(config_partial, "", defaul ts))
93 except Exception: 97 except Exception:
94 # Work with python 2 and 3 http://docs.python.org/py3k/howto/pyporting.h tml 98 # Work with python 2 and 3 http://docs.python.org/py3k/howto/pyporting.h tml
95 exc = sys.exc_info()[1] 99 exc = sys.exc_info()[1]
96 sys.stderr.write("Failed to parse config file: %s\n\n" % exc) 100 sys.stderr.write("Failed to parse config file: %s\n\n" % exc)
97 exit(1) 101 exit(1)
98 102
99 103
100 def to_title_case(name): 104 def to_title_case(name):
101 return name[:1].upper() + name[1:] 105 return name[:1].upper() + name[1:]
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 if up_to_date: 494 if up_to_date:
491 sys.exit() 495 sys.exit()
492 496
493 for file_name, content in outputs.iteritems(): 497 for file_name, content in outputs.iteritems():
494 out_file = open(file_name, "w") 498 out_file = open(file_name, "w")
495 out_file.write(content) 499 out_file.write(content)
496 out_file.close() 500 out_file.close()
497 501
498 502
499 main() 503 main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698