本文整理汇总了Python中tornado.options.OptionParser.parse_config_file方法的典型用法代码示例。如果您正苦于以下问题:Python OptionParser.parse_config_file方法的具体用法?Python OptionParser.parse_config_file怎么用?Python OptionParser.parse_config_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tornado.options.OptionParser
的用法示例。
在下文中一共展示了OptionParser.parse_config_file方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_parse_config_file
# 需要导入模块: from tornado.options import OptionParser [as 别名]
# 或者: from tornado.options.OptionParser import parse_config_file [as 别名]
def test_parse_config_file(self):
options = OptionParser()
options.define("port", default=80)
options.define("username", default='foo')
options.parse_config_file(os.path.join(os.path.dirname(__file__),
"options_test.cfg"))
self.assertEquals(options.port, 443)
self.assertEqual(options.username, "李康")
示例2: test_dash_underscore_file
# 需要导入模块: from tornado.options import OptionParser [as 别名]
# 或者: from tornado.options.OptionParser import parse_config_file [as 别名]
def test_dash_underscore_file(self):
# No matter how an option was defined, it can be set with underscores
# in a config file.
for defined_name in ['foo-bar', 'foo_bar']:
options = OptionParser()
options.define(defined_name)
options.parse_config_file(os.path.join(os.path.dirname(__file__),
"options_test.cfg"))
self.assertEqual(options.foo_bar, 'a')
示例3: test_parse_config_file
# 需要导入模块: from tornado.options import OptionParser [as 别名]
# 或者: from tornado.options.OptionParser import parse_config_file [as 别名]
def test_parse_config_file(self):
options = OptionParser()
options.define("port", default=80)
options.define("username", default="foo")
options.define("my_path")
config_path = os.path.join(
os.path.dirname(os.path.abspath(__file__)), "options_test.cfg"
)
options.parse_config_file(config_path)
self.assertEqual(options.port, 443)
self.assertEqual(options.username, "李康")
self.assertEqual(options.my_path, config_path)
示例4: load_config
# 需要导入模块: from tornado.options import OptionParser [as 别名]
# 或者: from tornado.options.OptionParser import parse_config_file [as 别名]
def load_config():
options = OptionParser()
options.define('port', default=8888, help='run on the given port', type=int)
options.define('debug', default=False, help='run in debug mode')
options.define('api_allowed_host', default='localhost', help='origin host that has access to API')
options.define('history_size', default=50, help='number of tweets stored in memoty', type=int)
options.define('config', type=str, help='path to config file',
callback=lambda path: options.parse_config_file(path, final=False))
options.define('logging', default='error', help='logging level')
options.parse_command_line()
return options