Bug 957911 - Work around the lack of support for semi-colon comments in python/configobj. r=gps
authorMike Hommey <mh+mozilla@glandium.org>
Tue, 06 Oct 2015 16:51:19 +0900
changeset 301966 211d62ae4c2710b6a46a4bd11251b77fca7b9ef8
parent 301965 61235b7b074827d2f6d5070bd761e713bac655f1
child 301967 8d60143991365b92b3ac8b94108ec612f1bd2144
push id1001
push userraliiev@mozilla.com
push dateMon, 18 Jan 2016 19:06:03 +0000
treeherdermozilla-release@8b89261f3ac4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps
bugs957911
milestone44.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 957911 - Work around the lack of support for semi-colon comments in python/configobj. r=gps
config/printconfigsetting.py
--- a/config/printconfigsetting.py
+++ b/config/printconfigsetting.py
@@ -1,21 +1,27 @@
 # 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, sys
+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)
 
-c = configobj.ConfigObj(file)
+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: