config/printconfigsetting.py
author Tooru Fujisawa <arai_a@mac.com>
Wed, 18 Nov 2015 19:13:22 +0900
changeset 339821 c91821911d5566d7fd01cde2fef6bf74d4325bd4
parent 299734 211d62ae4c2710b6a46a4bd11251b77fca7b9ef8
child 317331 d1a4b331d80bc4daea15a7df4057205483b1f276
child 798277 b0cb40ec96bfb8ab1e872af60c94820a44c0b6e6
permissions -rw-r--r--
Bug 933257 - Part 3: Add build scripts for fdlibm. r=jwalden

# 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/.

import configobj
import sys
import re
from StringIO import StringIO

try:
    (file, section, key) = sys.argv[1:]
except ValueError:
    print "Usage: printconfigsetting.py <file> <section> <setting>"
    sys.exit(1)

with open(file) as fh:
    content = re.sub('^\s*;', '#', fh.read(), flags=re.M)

c = configobj.ConfigObj(StringIO(content))

try:
    s = c[section]
except KeyError:
    print >>sys.stderr, "Section [%s] not found." % section
    sys.exit(1)

try:
    print s[key]
except KeyError:
    print >>sys.stderr, "Key %s not found." % key
    sys.exit(1)