From 0736367675404bc6d918835002d7b6ef43cb2f3d Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Thu, 3 Apr 2014 21:02:18 -0400 Subject: [PATCH] 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. --- fdroidserver/init.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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) -- 2.30.2