printconfigsetting.py 626 B

1234567891011121314151617181920212223242526
  1. # This Source Code Form is subject to the terms of the Mozilla Public
  2. # License, v. 2.0. If a copy of the MPL was not distributed with this
  3. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
  4. import configobj, sys
  5. try:
  6. (file, section, key) = sys.argv[1:]
  7. except ValueError:
  8. print "Usage: printconfigsetting.py <file> <section> <setting>"
  9. sys.exit(1)
  10. c = configobj.ConfigObj(file)
  11. try:
  12. s = c[section]
  13. except KeyError:
  14. print >>sys.stderr, "Section [%s] not found." % section
  15. sys.exit(1)
  16. try:
  17. print s[key]
  18. except KeyError:
  19. print >>sys.stderr, "Key %s not found." % key
  20. sys.exit(1)