From: Hans-Christoph Steiner Date: Fri, 4 Apr 2014 01:02:18 +0000 (-0400) Subject: when generating config.py during init, uncomment changed options X-Git-Tag: 0.2~141^2~10 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=0736367675404bc6d918835002d7b6ef43cb2f3d;p=fdroidserver.git 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. --- diff --git a/fdroidserver/init.py b/fdroidserver/init.py index 5cd126c1..4ecc3910 100644 --- a/fdroidserver/init.py +++ b/fdroidserver/init.py @@ -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)