INI 設定ファイルをいくつかの場所 ( /usr/share、/usr/local/share、~/.local/share、および現在のディレクトリ) で探すツールを作成しました。
c = ConfigParser.RawConfigParser()
filenames = ['/usr/share/myconfig.conf',
'/usr/local/share/myconfig.conf',
os.path.expanduser('~/.local/share/myconfig.conf'),
os.path.expanduser('./myconfig.conf')]
parsed_names = c.read(filenames)
for name in parsed_names:
print 'using configuration file: ' + name
virtualenv の使用を開始しましたが、setup.pyスクリプトが にインストールmyconfig.confされるようになりまし/path/to/virtual/env/share/た。virtualenv へのパスが毎回異なる場合、このパスを ConfigParser によって検索されるパスのリストに追加するにはどうすればよいですか? また、virtualenv にインストールした場合でも、システム/usr/shareと/usr/local/shareディレクトリを検索する必要がありますか?