Bug 1523562 [wpt PR 14965] - Sync Mozilla CSS tests as of 2019-01-20, a=testonly
[gecko.git] / config / printconfigsetting.py
blobc85f3ff4bca2146b19607c5fbb8ea857fc9f2f2e
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 import configobj
6 import sys
7 import re
8 from StringIO import StringIO
10 try:
11 (file, section, key) = sys.argv[1:]
12 except ValueError:
13 print("Usage: printconfigsetting.py <file> <section> <setting>")
14 sys.exit(1)
16 with open(file) as fh:
17 content = re.sub('^\s*;', '#', fh.read(), flags=re.M)
19 c = configobj.ConfigObj(StringIO(content))
21 try:
22 s = c[section]
23 except KeyError:
24 print >>sys.stderr, "Section [%s] not found." % section
25 sys.exit(1)
27 try:
28 print(s[key])
29 except KeyError:
30 print >>sys.stderr, "Key %s not found." % key
31 sys.exit(1)