2012-05-21 15:12:37 +04:00
|
|
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
2013-02-27 21:00:56 +04:00
|
|
|
from __future__ import print_function
|
2012-05-21 15:12:37 +04:00
|
|
|
|
2007-07-02 22:20:24 +04:00
|
|
|
import configobj, sys
|
|
|
|
|
|
|
|
try:
|
|
|
|
(file, section, key) = sys.argv[1:]
|
|
|
|
except ValueError:
|
2013-02-27 21:00:56 +04:00
|
|
|
print("Usage: printconfigsetting.py <file> <section> <setting>")
|
2007-07-02 22:20:24 +04:00
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
c = configobj.ConfigObj(file)
|
|
|
|
|
|
|
|
try:
|
|
|
|
s = c[section]
|
|
|
|
except KeyError:
|
2013-02-27 21:00:56 +04:00
|
|
|
print("Section [{0}] not found.".format(section), file=sys.stderr)
|
2007-07-02 22:20:24 +04:00
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
try:
|
2013-02-27 21:00:56 +04:00
|
|
|
print(s[key])
|
2007-07-02 22:20:24 +04:00
|
|
|
except KeyError:
|
2013-02-27 21:00:56 +04:00
|
|
|
print("Key {0} not found.".format(key), file=sys.stderr)
|
2007-07-02 22:20:24 +04:00
|
|
|
sys.exit(1)
|