Bug 1613457 [wpt PR 21606] - Update interfaces/cookie-store.idl, a=testonly
[gecko.git] / config / printconfigsetting.py
blobe8e99ae947876281da3ab55bf8be5fbcd075a9ca
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/.
5 from __future__ import absolute_import
6 from __future__ import print_function
7 import configobj
8 import sys
9 import re
10 from StringIO import StringIO
12 try:
13 (file, section, key) = sys.argv[1:]
14 except ValueError:
15 print("Usage: printconfigsetting.py <file> <section> <setting>")
16 sys.exit(1)
18 with open(file) as fh:
19 content = re.sub('^\s*;', '#', fh.read(), flags=re.M)
21 c = configobj.ConfigObj(StringIO(content))
23 try:
24 s = c[section]
25 except KeyError:
26 print >>sys.stderr, "Section [%s] not found." % section
27 sys.exit(1)
29 try:
30 print(s[key])
31 except KeyError:
32 print >>sys.stderr, "Key %s not found." % key
33 sys.exit(1)