1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-09-17 10:40:12 +02:00

when generating config.py during init, uncomment changed options

The defaults are set in config.py and are often commented out.  Before, the
regex would only change the value, but leave it commented out.  Now, it
will also uncomment it.
This commit is contained in:
Hans-Christoph Steiner 2014-04-03 21:02:18 -04:00
parent 40fdc2a943
commit 0736367675

View File

@ -38,8 +38,8 @@ def write_to_config(key, value):
'''write a key/value to the local config.py'''
with open('config.py', 'r') as f:
data = f.read()
pattern = key + '\s*=.*'
repl = key + ' = "' + value + '"'
pattern = '\n[\s#]*' + key + '\s*=\s*"[^"]*"'
repl = '\n' + key + ' = "' + value + '"'
data = re.sub(pattern, repl, data)
with open('config.py', 'w') as f:
f.writelines(data)