0

プロセスの開始時にcmd行(--config-file)で渡したくない.confファイルがあります。代わりに、私はそれが動的に読み込まれるようにします。オンザフライで設定ファイルをロードする方法はありますか?

oslo_configライブラリを使用して構成オプションを登録しました。私は、oslo_configライブラリによって解析されるconfファイルが必要です。

PS:このoslo_config CONFオブジェクトは私のマルチプロセスフレームワークで既に流通しているので、ConfigParserなどの他のライブラリを使用したくないです。

ありがとうございました。

答えて

0

だけ

self.conf = cfg.ConfigOpts() 
self.conf(
    sys.argv[1:], # if there is, can be [] 
    project="whatever", # but will affect the searching directories 
    default_config_files=["path/to/my/conf"] # if not set, will do a auto searching 
) 
# use it via self.conf.example_section.example_option 
別olslo_config.cfg.ConfigOpts()インスタンスを初期化します
関連する問題