mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-05 23:10:29 +03: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:
parent
40fdc2a943
commit
0736367675
1 changed files with 2 additions and 2 deletions
|
|
@ -38,8 +38,8 @@ def write_to_config(key, value):
|
||||||
'''write a key/value to the local config.py'''
|
'''write a key/value to the local config.py'''
|
||||||
with open('config.py', 'r') as f:
|
with open('config.py', 'r') as f:
|
||||||
data = f.read()
|
data = f.read()
|
||||||
pattern = key + '\s*=.*'
|
pattern = '\n[\s#]*' + key + '\s*=\s*"[^"]*"'
|
||||||
repl = key + ' = "' + value + '"'
|
repl = '\n' + key + ' = "' + value + '"'
|
||||||
data = re.sub(pattern, repl, data)
|
data = re.sub(pattern, repl, data)
|
||||||
with open('config.py', 'w') as f:
|
with open('config.py', 'w') as f:
|
||||||
f.writelines(data)
|
f.writelines(data)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue