def parse_config(self, config_file):
"""Parses the config file, and assign their values to our local traits.
"""
# Keep the file line parser isolated, but use the global one
# so that we can get the help of the command line options.
file_line_parser = tornado.options.OptionParser()
for traitlet_name, traitlet in self.traits().items():
# tornado.OptionParser defines an option with a Python type
# and performs type validation.
default_value = getattr(self, traitlet_name)
file_line_parser.define(
traitlet_name,
default=default_value,
type=type(default_value),
help=traitlet.help)
# Let it raise the exception if the file is not there.
# We always want the config file to be present, even if empty
try:
file_line_parser.parse_config_file(config_file)
except FileNotFoundError:
raise tornado.options.Error(
'Could not find specified configuration'
' file "{}"'.format(config_file))
set_traits_from_dict(self, file_line_parser.as_dict())
if self.tls or self.tls_verify:
self.docker_host = self.docker_host.replace('tcp://', 'https://')
评论列表
文章目录