本文整理匯總了Python中configuration.Config.set_cwd方法的典型用法代碼示例。如果您正苦於以下問題:Python Config.set_cwd方法的具體用法?Python Config.set_cwd怎麽用?Python Config.set_cwd使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類configuration.Config
的用法示例。
在下文中一共展示了Config.set_cwd方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: build_default
# 需要導入模塊: from configuration import Config [as 別名]
# 或者: from configuration.Config import set_cwd [as 別名]
def build_default(deployment_home, cwd, CommandClasses):
"""
Create a runtime from the command line arguments and configuration on
disk.
If you want something more custom, e.g. in testing, you can build
it yourself ;)
"""
if len(CommandClasses):
arg_parser = CommandClasses[0].build_arg_parser()
else:
arg_parser = Runtime.__create_placeholder_arg_parser()
Runtime.add_default_arguments(arg_parser)
runtime = Runtime()
for CommandClass in CommandClasses:
CommandClass.register_services(runtime)
for ServiceClass in runtime.each_service_class():
add_default_arguments_method = getattr(ServiceClass, 'add_default_arguments', None)
if add_default_arguments_method and callable(add_default_arguments_method):
ServiceClass.add_default_arguments(arg_parser)
options = arg_parser.parse_args()
if not hasattr(options, 'deployment_home'):
options.deployment_home = deployment_home
config = Config()
config.set_options(options)
config.set_cwd(cwd)
if hasattr(CommandClass, 'DOTFILE_NAME'):
config.set_dotfile_name(CommandClass.DOTFILE_NAME)
try:
config.read()
except Exception as e:
if not hasattr(CommandClass, 'is_config_required') or CommandClass.is_config_required():
exc_info = sys.exc_info()
raise e, None, exc_info[2]
log = Log()
log.set_options(options)
runtime.set_options(options)
runtime.set_config(config)
runtime.set_log(log)
runtime.set_cwd(cwd)
return runtime