Skip to content

Commit

Permalink
Bug 957911 - Work around the lack of support for semi-colon comments …
Browse files Browse the repository at this point in the history
…in python/configobj. r=gps
  • Loading branch information
glandium committed Oct 8, 2015
1 parent e948cf7 commit cb814d9
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions config/printconfigsetting.py
Expand Up @@ -2,15 +2,21 @@
# 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]
Expand Down

0 comments on commit cb814d9

Please sign in to comment.